summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2019-03-06 14:07:18 -0800
committerIan Romanick <[email protected]>2019-05-14 11:38:22 -0700
commit281f20e26d840939133209e9f1fc91270b55574e (patch)
tree5a75e8d5349249730324afb584d83e27432c37ba /src/compiler
parent45c7ff95fc7de2dd631aa79093f92de3d19e4e26 (diff)
nir/algebraic: Strip double negatives from comparison sources
All Intel platforms had similar results. (Ice Lake shown) total instructions in shared programs: 17224623 -> 17224337 (<.01%) instructions in affected programs: 32648 -> 32362 (-0.88%) helped: 148 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.93 x̃: 2 helped stats (rel) min: 0.16% max: 2.74% x̄: 1.07% x̃: 1.08% 95% mean confidence interval for instructions value: -1.97 -1.89 95% mean confidence interval for instructions %-change: -1.15% -1.00% Instructions are helped. total cycles in shared programs: 360828714 -> 360826090 (<.01%) cycles in affected programs: 347416 -> 344792 (-0.76%) helped: 148 HURT: 26 helped stats (abs) min: 1 max: 426 x̄: 26.33 x̃: 18 helped stats (rel) min: 0.03% max: 15.10% x̄: 1.78% x̃: 1.41% HURT stats (abs) min: 2 max: 337 x̄: 48.96 x̃: 6 HURT stats (rel) min: 0.04% max: 18.82% x̄: 2.15% x̃: 0.27% 95% mean confidence interval for cycles value: -23.78 -6.38 95% mean confidence interval for cycles %-change: -1.59% -0.79% Cycles are helped. Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Thomas Helland <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_opt_algebraic.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index b984df0b1c7..5fc6fd80de4 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -199,6 +199,20 @@ optimizations = [
(('inot', ('ieq', a, b)), ('ine', a, b)),
(('inot', ('ine', a, b)), ('ieq', a, b)),
+ # This helps some shaders because, after some optimizations, they end up
+ # with patterns like (-a < -b) || (b < a). In an ideal world, this sort of
+ # matching would be handled by CSE.
+ (('flt', ('fneg', a), ('fneg', b)), ('flt', b, a)),
+ (('fge', ('fneg', a), ('fneg', b)), ('fge', b, a)),
+ (('feq', ('fneg', a), ('fneg', b)), ('feq', b, a)),
+ (('fne', ('fneg', a), ('fneg', b)), ('fne', b, a)),
+ (('flt', ('fneg', a), -1.0), ('flt', 1.0, a)),
+ (('flt', -1.0, ('fneg', a)), ('flt', a, 1.0)),
+ (('fge', ('fneg', a), -1.0), ('fge', 1.0, a)),
+ (('fge', -1.0, ('fneg', a)), ('fge', a, 1.0)),
+ (('fne', ('fneg', a), -1.0), ('fne', 1.0, a)),
+ (('feq', -1.0, ('fneg', a)), ('feq', a, 1.0)),
+
# 0.0 >= b2f(a)
# b2f(a) <= 0.0
# b2f(a) == 0.0 because b2f(a) can only be 0 or 1
@@ -1124,6 +1138,20 @@ late_optimizations = [
(('~fge', ('fmin(is_used_once)', ('fadd(is_used_once)', a, b), ('fadd', c, d)), 0.0), ('iand', ('fge', a, ('fneg', b)), ('fge', c, ('fneg', d)))),
+ (('flt', ('fneg', a), ('fneg', b)), ('flt', b, a)),
+ (('fge', ('fneg', a), ('fneg', b)), ('fge', b, a)),
+ (('feq', ('fneg', a), ('fneg', b)), ('feq', b, a)),
+ (('fne', ('fneg', a), ('fneg', b)), ('fne', b, a)),
+ (('flt', ('fneg', a), -1.0), ('flt', 1.0, a)),
+ (('flt', -1.0, ('fneg', a)), ('flt', a, 1.0)),
+ (('fge', ('fneg', a), -1.0), ('fge', 1.0, a)),
+ (('fge', -1.0, ('fneg', a)), ('fge', a, 1.0)),
+ (('fne', ('fneg', a), -1.0), ('fne', 1.0, a)),
+ (('feq', -1.0, ('fneg', a)), ('feq', a, 1.0)),
+
+ (('ior', a, a), a),
+ (('iand', a, a), a),
+
(('fdot2', a, b), ('fdot_replicated2', a, b), 'options->fdot_replicates'),
(('fdot3', a, b), ('fdot_replicated3', a, b), 'options->fdot_replicates'),
(('fdot4', a, b), ('fdot_replicated4', a, b), 'options->fdot_replicates'),