summaryrefslogtreecommitdiffstats
path: root/src/glsl/opt_algebraic.cpp
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2015-03-17 23:28:27 -0700
committerMatt Turner <mattst88@gmail.com>2015-03-24 14:43:37 -0700
commitc8e8f660365515560af029651e593f7ee700401c (patch)
tree6000a3fc9cc44e589a13c889f4891d0984020113 /src/glsl/opt_algebraic.cpp
parent95729d2458515788ed84c81698033b8ef170bd4e (diff)
downloadexternal_mesa3d-c8e8f660365515560af029651e593f7ee700401c.zip
external_mesa3d-c8e8f660365515560af029651e593f7ee700401c.tar.gz
external_mesa3d-c8e8f660365515560af029651e593f7ee700401c.tar.bz2
glsl: Recognize mul(b2f(a), b2f(b)) as a logical AND.
Transform this into b2f(and(a, b)). total instructions in shared programs: 6190291 -> 6189225 (-0.02%) instructions in affected programs: 267247 -> 266181 (-0.40%) helped: 866 Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/glsl/opt_algebraic.cpp')
-rw-r--r--src/glsl/opt_algebraic.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 69c03ea..0d1f3fc 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -518,6 +518,10 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
if (is_vec_negative_one(op_const[1]))
return neg(ir->operands[0]);
+ if (op_expr[0] && op_expr[0]->operation == ir_unop_b2f &&
+ op_expr[1] && op_expr[1]->operation == ir_unop_b2f) {
+ return b2f(logic_and(op_expr[0]->operands[0], op_expr[1]->operands[0]));
+ }
/* Reassociate multiplication of constants so that we can do
* constant folding.