glsl: Optimize ~~x into x.
authorEric Anholt <eric@anholt.net>
Sat, 18 Jan 2014 18:36:28 +0000 (10:36 -0800)
committerEric Anholt <eric@anholt.net>
Fri, 7 Feb 2014 20:46:47 +0000 (12:46 -0800)
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)
src/glsl/opt_algebraic.cpp

index d1f6435f44f9870eebba9e8f42b66c161b803f5a..681973dda0ee4c1960814042a7b04f0f11b5c22c 100644 (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;