Mesa (master): glsl: Recognize mul(b2f(a), b2f(b)) as a logical AND.
Matt Turner
mattst88 at kemper.freedesktop.org
Tue Mar 24 21:45:16 UTC 2015
Module: Mesa
Branch: master
Commit: c8e8f660365515560af029651e593f7ee700401c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c8e8f660365515560af029651e593f7ee700401c
Author: Matt Turner <mattst88 at gmail.com>
Date: Tue Mar 17 23:28:27 2015 -0700
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 at intel.com>
---
src/glsl/opt_algebraic.cpp | 4 ++++
1 file changed, 4 insertions(+)
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.
More information about the mesa-commit
mailing list