glsl: calculate number of operands in an expression once
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 9 Aug 2017 03:34:02 +0000 (13:34 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 11 Aug 2017 00:43:12 +0000 (10:43 +1000)
commite2e2c5abd279df1b3aa99c52b81c9cb48fea35fb
tree814dcc8cf5c292ebaead53f75580c93b7f95f1ce
parent5563872dbfbf733ed56e1b367bc8944ca59b1c3e
glsl: calculate number of operands in an expression once

Extra validation is added to ir_validate to make sure this is
always updated to the correct numer of operands, as passes like
lower_instructions modify the instructions directly rather then
generating a new one.

The reduction in time is so small that it is not really
measurable. However callgrind was reporting this function as
being called just under 34 million times while compiling the
Deus Ex shaders (just pre-linking was profiled) with 0.20%
spent in this function.

v2:
 - make num_operands a unit8_t
 - fix unsigned/signed mismatches

Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
22 files changed:
src/compiler/glsl/glsl_to_nir.cpp
src/compiler/glsl/ir.cpp
src/compiler/glsl/ir.h
src/compiler/glsl/ir_builder_print_visitor.cpp
src/compiler/glsl/ir_clone.cpp
src/compiler/glsl/ir_constant_expression.cpp
src/compiler/glsl/ir_equals.cpp
src/compiler/glsl/ir_hv_accept.cpp
src/compiler/glsl/ir_print_visitor.cpp
src/compiler/glsl/ir_rvalue_visitor.cpp
src/compiler/glsl/ir_validate.cpp
src/compiler/glsl/lower_instructions.cpp
src/compiler/glsl/lower_int64.cpp
src/compiler/glsl/lower_mat_op_to_vec.cpp
src/compiler/glsl/lower_ubo_reference.cpp
src/compiler/glsl/lower_vec_index_to_cond_assign.cpp
src/compiler/glsl/lower_vector.cpp
src/compiler/glsl/opt_algebraic.cpp
src/compiler/glsl/opt_constant_folding.cpp
src/compiler/glsl/opt_tree_grafting.cpp
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp