Mesa (master): glsl: Optimize pow(x, 2) into x * x.
Matt Turner
mattst88 at kemper.freedesktop.org
Wed Mar 19 06:19:50 UTC 2014
Module: Mesa
Branch: master
Commit: 6cbc64c3cb416fadad6e80042e24cd1e1b682897
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6cbc64c3cb416fadad6e80042e24cd1e1b682897
Author: Matt Turner <mattst88 at gmail.com>
Date: Fri Feb 28 13:33:19 2014 -0800
glsl: Optimize pow(x, 2) into x * x.
Cuts two instructions out of SynMark's Gl32VSInstancing benchmark.
Reviewed-by: Eric Anholt <eric at anholt.net>
---
src/glsl/opt_algebraic.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 5c49a78..8494bd9 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -528,6 +528,14 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
if (is_vec_two(op_const[0]))
return expr(ir_unop_exp2, ir->operands[1]);
+ if (is_vec_two(op_const[1])) {
+ ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x",
+ ir_var_temporary);
+ base_ir->insert_before(x);
+ base_ir->insert_before(assign(x, ir->operands[0]));
+ return mul(x, x);
+ }
+
break;
case ir_unop_rcp:
More information about the mesa-commit
mailing list