aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2014-02-28 13:33:19 -0800
committerMatt Turner <[email protected]>2014-03-18 23:20:29 -0700
commit6cbc64c3cb416fadad6e80042e24cd1e1b682897 (patch)
tree906bd4d7ca4ad006ec3a922fff169992b4176f10 /src/glsl
parent9a9eaaa79a43e5fb249ff56a06c3f845e6a28a41 (diff)
glsl: Optimize pow(x, 2) into x * x.
Cuts two instructions out of SynMark's Gl32VSInstancing benchmark. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/opt_algebraic.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 5c49a785ccd..8494bd9ec53 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: