[Mesa-dev] [PATCH] glsl: Optimize logic operation A || (A && B)

Matt Turner mattst88 at gmail.com
Thu Jul 10 17:35:55 PDT 2014


On Thu, Jul 10, 2014 at 4:12 PM, Brian Paul <brianp at vmware.com> wrote:
> BTW, looking at these algebraic simplifications in general, where do we
> check for operands with side-effects?  For example, in the "1^x == 1"
> optimization, suppose x is a function call which modifies a global. Removing
> x would be invalid, right?

Function calls (ir_call) are not R-values (ir_rvalues), so they can
never appear in an expression tree. They can only appear as top-level
ir_instructions, so return_something() in 1^return_something() would
appear as an ir_call in the instruction list, and then its result (an
ir_variable) could be used in an expression tree.

GLSL IR's expression trees are pure, i.e., they have no side effects.


More information about the mesa-dev mailing list