summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElie TOURNIER <[email protected]>2017-01-18 11:23:22 +0000
committerJason Ekstrand <[email protected]>2017-01-19 21:44:28 -0800
commit9fdaeb7776c51e45646502ce4b6420a9652cd824 (patch)
tree2aba551c9da0875a707430be9db3c8826120a8c8
parentf22ee14644143b5edeed7f345b93fb361c16c71b (diff)
nir: add min/max optimisation
Add the following optimisations: min(x, -x) = -abs(x) min(x, -abs(x)) = -abs(x) min(x, abs(x)) = x max(x, -abs(x)) = x max(x, abs(x)) = abs(x) max(x, -x) = abs(x) shader-db: total instructions in shared programs: 13067779 -> 13067775 (-0.00%) instructions in affected programs: 249 -> 245 (-1.61%) helped: 4 HURT: 0 total cycles in shared programs: 252054838 -> 252054806 (-0.00%) cycles in affected programs: 504 -> 472 (-6.35%) helped: 2 HURT: 0 Signed-off-by: Elie Tournier <[email protected]> Reviewed-by: Plamena Manolova <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
-rw-r--r--src/compiler/nir/nir_opt_algebraic.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index d7ad1f2fbf3..68938000098 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -171,6 +171,18 @@ optimizations = [
(('imax', a, a), a),
(('umin', a, a), a),
(('umax', a, a), a),
+ (('fmin', a, ('fneg', a)), ('fneg', ('fabs', a))),
+ (('imin', a, ('ineg', a)), ('ineg', ('iabs', a))),
+ (('fmin', a, ('fneg', ('fabs', a))), ('fneg', ('fabs', a))),
+ (('imin', a, ('ineg', ('iabs', a))), ('ineg', ('iabs', a))),
+ (('fmin', a, ('fabs', a)), a),
+ (('imin', a, ('iabs', a)), a),
+ (('fmax', a, ('fneg', ('fabs', a))), a),
+ (('imax', a, ('ineg', ('iabs', a))), a),
+ (('fmax', a, ('fabs', a)), ('fabs', a)),
+ (('imax', a, ('iabs', a)), ('iabs', a)),
+ (('fmax', a, ('fneg', a)), ('fabs', a)),
+ (('imax', a, ('ineg', a)), ('iabs', a)),
(('~fmin', ('fmax', a, 0.0), 1.0), ('fsat', a), '!options->lower_fsat'),
(('~fmax', ('fmin', a, 1.0), 0.0), ('fsat', a), '!options->lower_fsat'),
(('fsat', a), ('fmin', ('fmax', a, 0.0), 1.0), 'options->lower_fsat'),