Mesa (master): glsl: Apply the transformation "(a ^^ a) -> false" in opt_algebraic.

Eric Anholt anholt at kemper.freedesktop.org
Fri Nov 15 19:34:01 UTC 2013


Module: Mesa
Branch: master
Commit: 477f8cd08bb8467d28fdfd6c25fe358957e3da58
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=477f8cd08bb8467d28fdfd6c25fe358957e3da58

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Nov  7 12:10:25 2013 -0800

glsl: Apply the transformation "(a ^^ a) -> false" in opt_algebraic.

Reviewed-by: Jordan Justen <jordan.l.justen at intel.com>

---

 src/glsl/opt_algebraic.cpp |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index ea3c386..448f27e 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -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;
 




More information about the mesa-commit mailing list