summaryrefslogtreecommitdiffstats
path: root/src/glsl/opt_algebraic.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2013-10-31 09:32:42 -0700
committerEric Anholt <eric@anholt.net>2013-11-15 11:33:07 -0800
commit58a98d32e451762934ca8c38135357f36e29654f (patch)
tree9318b6555e30e2855ef806d03843fafd4c5836ee /src/glsl/opt_algebraic.cpp
parentee2704826264eba22d095c3e1e03a8532b7bd1e6 (diff)
downloadexternal_mesa3d-58a98d32e451762934ca8c38135357f36e29654f.zip
external_mesa3d-58a98d32e451762934ca8c38135357f36e29654f.tar.gz
external_mesa3d-58a98d32e451762934ca8c38135357f36e29654f.tar.bz2
glsl: Apply the transformation "(a && a) -> a" in opt_algebraic.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Diffstat (limited to 'src/glsl/opt_algebraic.cpp')
-rw-r--r--src/glsl/opt_algebraic.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 3da27e5..ea3c386 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -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;