glsl: Optimize ~~x into x.

v2: Fix pasteo of an extra abs being inserted (caught by many).  Rewrite
    to drop the silly switch statement.

Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
This commit is contained in:
Eric Anholt
2014-01-18 10:36:28 -08:00
parent 0f6279bab2
commit 2c2aa35336

View File

@@ -218,6 +218,11 @@ 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] && op_expr[0]->operation == ir_unop_bit_not)
return op_expr[0]->operands[0];
break;
case ir_unop_abs:
if (op_expr[0] == NULL)
break;