[Mesa-dev] [PATCH 1/6] glsl: Optimize ~~x into x.

Kenneth Graunke kenneth at whitecape.org
Mon Jan 20 10:43:35 PST 2014


On 01/20/2014 12:38 AM, Erik Faye-Lund wrote:
> On Mon, Jan 20, 2014 at 8:18 AM, Eric Anholt <eric at anholt.net> wrote:
>> ---
>>  src/glsl/opt_algebraic.cpp | 12 ++++++++++++
>>  1 file changed, 12 insertions(+)
>>
>> diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
>> index 332f0b7..6b0d992 100644
>> --- a/src/glsl/opt_algebraic.cpp
>> +++ b/src/glsl/opt_algebraic.cpp
>> @@ -218,6 +218,18 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
>>        this->mem_ctx = ralloc_parent(ir);
>>
>>     switch (ir->operation) {
>> +   case ir_unop_bit_not:
>> +      if (op_expr[0] == NULL)
>> +        break;
> 
> How can this happen?!

Easy.  op_expr[i] == ir->operand[i]->as_expression().  If the operand is
not an ir_expression object, this will be NULL.  For example, it could
be an ir_swizzle, ir_constant, ir_dereference_variable...or pretty much
any other ir_rvalue derivative.

--Ken



More information about the mesa-dev mailing list