<p dir="ltr">Looks fine to me but why are we still adding algebraic optimizations to GLSL-IR?</p>
<p dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>></p>
<div class="gmail_quote">On Feb 10, 2015 12:36 PM, "Matt Turner" <<a href="mailto:mattst88@gmail.com">mattst88@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Lots of shaders divide by exp2(...) which we turn into a multiplication<br>
by the reciprocal. We can avoid the reciprocal by simply negating exp2's<br>
argument.<br>
<br>
total instructions in shared programs: 5947154 -> 5946695 (-0.01%)<br>
instructions in affected programs:     118661 -> 118202 (-0.39%)<br>
helped:                                380<br>
---<br>
 src/glsl/opt_algebraic.cpp | 6 ++++++<br>
 1 file changed, 6 insertions(+)<br>
<br>
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp<br>
index c6f4a9c..616ed37 100644<br>
--- a/src/glsl/opt_algebraic.cpp<br>
+++ b/src/glsl/opt_algebraic.cpp<br>
@@ -747,6 +747,12 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)<br>
       if (op_expr[0] && op_expr[0]->operation == ir_unop_rcp)<br>
         return op_expr[0]->operands[0];<br>
<br>
+      if (op_expr[0] && (op_expr[0]->operation == ir_unop_exp2 ||<br>
+                         op_expr[0]->operation == ir_unop_exp)) {<br>
+         return new(mem_ctx) ir_expression(op_expr[0]->operation, ir->type,<br>
+                                           neg(op_expr[0]->operands[0]));<br>
+      }<br>
+<br>
       /* While ir_to_mesa.cpp will lower sqrt(x) to rcp(rsq(x)), it does so at<br>
        * its IR level, so we can always apply this transformation.<br>
        */<br>
--<br>
2.0.5<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>