[Mesa-dev] [PATCH 3/6] glsl: Optimize pow(x, 1) -> x.
Eric Anholt
eric at anholt.net
Sun Jan 19 23:18:35 PST 2014
total instructions in shared programs: 1627826 -> 1627754 (-0.00%)
instructions in affected programs: 6640 -> 6568 (-1.08%)
GAINED: 0
LOST: 0
(HoN and savage2)
---
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 4aa49e5..918982a 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -475,6 +475,10 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
if (is_vec_one(op_const[0]))
return op_const[0];
+ /* x^1 == x */
+ if (is_vec_one(op_const[1]))
+ return ir->operands[0];
+
/* pow(2,x) == exp2(x) */
if (is_vec_two(op_const[0]))
return expr(ir_unop_exp2, ir->operands[1]);
--
1.8.5.2
More information about the mesa-dev
mailing list