glsl: Apply the transformation "(a ^^ a) -> false" in opt_algebraic.
authorEric Anholt <eric@anholt.net>
Thu, 7 Nov 2013 20:10:25 +0000 (12:10 -0800)
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 ea3c386edf6d892c50e8c3f7fd5b6c2bfc299b69..448f27ed954babc473c1fc25b51b91823428eb01 100644 (file)
@@ -377,7 +377,6 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
       break;
 
    case ir_binop_logic_xor:
-      /* FINISHME: Also simplify (a ^^ a) to (false). */
       if (is_vec_zero(op_const[0])) {
         return ir->operands[1];
       } else if (is_vec_zero(op_const[1])) {
@@ -386,6 +385,9 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
         return logic_not(ir->operands[1]);
       } else if (is_vec_one(op_const[1])) {
         return logic_not(ir->operands[0]);
+      } else if (ir->operands[0]->equals(ir->operands[1])) {
+         /* (a ^^ a) == false */
+        return ir_constant::zero(mem_ctx, ir->type);
       }
       break;