<div dir="auto"><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br><div class="gmail_extra"><br><div class="gmail_quote">On Jan 18, 2017 3:23 AM, "Elie Tournier" <<a href="mailto:tournier.elie@gmail.com">tournier.elie@gmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Add the following optimisations:<br>
<br>
min(x, -x) = -abs(x)<br>
min(x, -abs(x)) = -abs(x)<br>
min(x, abs(x)) = x<br>
max(x, -abs(x)) = x<br>
max(x, abs(x)) = abs(x)<br>
max(x, -x) = abs(x)<br>
<br>
shader-db:<br>
<br>
total instructions in shared programs: 13067779 -> 13067775 (-0.00%)<br>
instructions in affected programs: 249 -> 245 (-1.61%)<br>
helped: 4<br>
HURT: 0<br>
<br>
total cycles in shared programs: 252054838 -> 252054806 (-0.00%)<br>
cycles in affected programs: 504 -> 472 (-6.35%)<br>
helped: 2<br>
HURT: 0<br>
<br>
Signed-off-by: Elie Tournier <<a href="mailto:tournier.elie@gmail.com">tournier.elie@gmail.com</a>><br>
---<br>
src/compiler/nir/nir_opt_<wbr>algebraic.py | 12 ++++++++++++<br>
1 file changed, 12 insertions(+)<br>
<br>
diff --git a/src/compiler/nir/nir_opt_<wbr>algebraic.py b/src/compiler/nir/nir_opt_<wbr>algebraic.py<br>
index a557f7bf37..0dfa53fbf4 100644<br>
--- a/src/compiler/nir/nir_opt_<wbr>algebraic.py<br>
+++ b/src/compiler/nir/nir_opt_<wbr>algebraic.py<br>
@@ -171,6 +171,18 @@ optimizations = [<br>
(('imax', a, a), a),<br>
(('umin', a, a), a),<br>
(('umax', a, a), a),<br>
+ (('fmin', a, ('fneg', a)), ('fneg', ('fabs', a))),<br>
+ (('imin', a, ('ineg', a)), ('ineg', ('iabs', a))),<br>
+ (('fmin', a, ('fneg', ('fabs', a))), ('fneg', ('fabs', a))),<br>
+ (('imin', a, ('ineg', ('iabs', a))), ('ineg', ('iabs', a))),<br>
+ (('fmin', a, ('fabs', a)), a),<br>
+ (('imin', a, ('iabs', a)), a),<br>
+ (('fmax', a, ('fneg', ('fabs', a))), a),<br>
+ (('imax', a, ('ineg', ('iabs', a))), a),<br>
+ (('fmax', a, ('fabs', a)), ('fabs', a)),<br>
+ (('imax', a, ('iabs', a)), ('iabs', a)),<br>
+ (('fmax', a, ('fneg', a)), ('fabs', a)),<br>
+ (('imax', a, ('ineg', a)), ('iabs', a)),<br>
(('~fmin', ('fmax', a, 0.0), 1.0), ('fsat', a), '!options->lower_fsat'),<br>
(('~fmax', ('fmin', a, 1.0), 0.0), ('fsat', a), '!options->lower_fsat'),<br>
(('fsat', a), ('fmin', ('fmax', a, 0.0), 1.0), 'options->lower_fsat'),<br>
<font color="#888888">--<br>
2.11.0<br>
<br>
</font></blockquote></div><br></div></div></div>