Mesa (master): glsl: Optimize pow(x, 1) -> x.
Eric Anholt
anholt at kemper.freedesktop.org
Fri Feb 7 20:49:52 UTC 2014
Module: Mesa
Branch: master
Commit: d72956790fed5f62b8eea5938ed432544530f7bd
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d72956790fed5f62b8eea5938ed432544530f7bd
Author: Eric Anholt <eric at anholt.net>
Date: Sat Jan 18 10:57:29 2014 -0800
glsl: Optimize pow(x, 1) -> x.
total instructions in shared programs: 1627826 -> 1627754 (-0.00%)
instructions in affected programs: 6640 -> 6568 (-1.08%)
GAINED: 0
LOST: 0
(HoN and savage2)
Reviewed-by: Matt Turner <mattst88 at gmail.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 1e71581..953b03c 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -520,6 +520,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]);
More information about the mesa-commit
mailing list