glsl: Apply the transformation "(a && a) -> a" in opt_algebraic.
authorEric Anholt <eric@anholt.net>
Thu, 31 Oct 2013 16:32:42 +0000 (09:32 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 15 Nov 2013 19:33:07 +0000 (11:33 -0800)
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
src/glsl/opt_algebraic.cpp

index 3da27e5d61c389cfe18423708e285faf8b503e66..ea3c386edf6d892c50e8c3f7fd5b6c2bfc299b69 100644 (file)
@@ -357,7 +357,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       break;
 
    case ir_binop_logic_and:
-      /* FINISHME: Also simplify (a && a) to (a). */
       if (is_vec_one(op_const[0])) {
         return ir->operands[1];
       } else if (is_vec_one(op_const[1])) {
@@ -371,6 +370,9 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
           */
          return logic_not(logic_or(op_expr[0]->operands[0],
                                    op_expr[1]->operands[0]));
+      } else if (ir->operands[0]->equals(ir->operands[1])) {
+         /* (a && a) == a */
+         return ir->operands[0];
       }
       break;