<div dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com">jason.ekstrand@intel.com</a>></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 22, 2015 at 3:41 AM, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Most of these exist in the GLSL IR algebraic pass already. However,<br>
SSA allows us to find more instances of the patterns.<br>
<br>
total NIR instructions in shared programs: 2015593 -> 2011430 (-0.21%)<br>
NIR instructions in affected programs: 124189 -> 120026 (-3.35%)<br>
helped: 604<br>
<br>
total i965 instructions in shared programs: 6025508 -> 6018718 (-0.11%)<br>
i965 instructions in affected programs: 261070 -> 254280 (-2.60%)<br>
helped: 1295<br>
HURT: 2 (by 1 instruction each)<br>
GAINED: 6<br>
<br>
Signed-off-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
---<br>
src/glsl/nir/nir_opt_algebraic.py | 10 ++++++++++<br>
1 file changed, 10 insertions(+)<br>
<br>
diff --git a/src/glsl/nir/nir_opt_algebraic.py b/src/glsl/nir/nir_opt_algebraic.py<br>
index dec250b..a5b5715 100644<br>
--- a/src/glsl/nir/nir_opt_algebraic.py<br>
+++ b/src/glsl/nir/nir_opt_algebraic.py<br>
@@ -99,6 +99,16 @@ optimizations = [<br>
(('ishr', a, 0), 0),<br>
(('ushr', 0, a), 0),<br>
(('ushr', a, 0), 0),<br>
+ # Exponential/logarithmic identities<br>
+ (('fexp2', ('flog2', a)), a), # 2^lg2(a) = a<br>
+ (('fexp', ('flog', a)), a), # e^ln(a) = a<br>
+ (('flog2', ('fexp2', a)), a), # lg2(2^a) = a<br>
+ (('flog', ('fexp', a)), a), # ln(e^a) = a<br>
+ (('fexp2', ('fmul', ('flog2', a), b)), ('fpow', a, b)), # 2^(lg2(a)*b) = a^b<br>
+ (('fexp', ('fmul', ('flog', a), b)), ('fpow', a, b)), # e^(ln(a)*b) = a^b<br>
+ (('fpow', a, 1.0), a),<br>
+ (('fpow', a, 2.0), ('fmul', a, a)),<br>
+ (('fpow', 2.0, a), ('fexp2', a)),<br>
<br>
# This one may not be exact<br>
(('feq', ('fadd', a, b), 0.0), ('feq', a, ('fneg', b))),<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.2.2<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>
</font></span></blockquote></div><br></div>