diff options
author | Ian Romanick <[email protected]> | 2018-08-01 19:27:01 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2018-08-04 01:12:03 -0700 |
commit | 4425f4786a2ea2fe8aeca4a6be3ae82b468049b0 (patch) | |
tree | 347f89ee310f1a536efc9f2ca5a2bf170fb838ce /src/compiler/nir | |
parent | 6b3670ae8045c4469dc918068a2f2c1c90a64ddf (diff) |
nir: Transform expressions of b2f(a) and b2f(b) to !(a || b)
All Gen6+ platforms had similar results. (Skylake shown)
total instructions in shared programs: 14276961 -> 14276892 (<.01%)
instructions in affected programs: 3215 -> 3146 (-2.15%)
helped: 28
HURT: 0
helped stats (abs) min: 1 max: 6 x̄: 2.46 x̃: 2
helped stats (rel) min: 0.47% max: 9.52% x̄: 4.34% x̃: 1.92%
95% mean confidence interval for instructions value: -2.87 -2.06
95% mean confidence interval for instructions %-change: -5.73% -2.95%
Instructions are helped.
total cycles in shared programs: 532577068 -> 532578400 (<.01%)
cycles in affected programs: 121864 -> 123196 (1.09%)
helped: 35
HURT: 30
helped stats (abs) min: 2 max: 268 x̄: 42.34 x̃: 22
helped stats (rel) min: 0.12% max: 12.14% x̄: 3.22% x̃: 1.86%
HURT stats (abs) min: 2 max: 246 x̄: 93.80 x̃: 36
HURT stats (rel) min: 0.09% max: 13.63% x̄: 4.47% x̃: 2.58%
95% mean confidence interval for cycles value: -5.02 46.01
95% mean confidence interval for cycles %-change: -0.99% 1.65%
Inconclusive result (value mean confidence interval includes 0).
Iron Lake and GM45 had similar results. (Iron Lake shown)
total instructions in shared programs: 7781299 -> 7781342 (<.01%)
instructions in affected programs: 22300 -> 22343 (0.19%)
helped: 13
HURT: 40
helped stats (abs) min: 2 max: 3 x̄: 2.85 x̃: 3
helped stats (rel) min: 1.15% max: 7.69% x̄: 3.72% x̃: 3.33%
HURT stats (abs) min: 2 max: 2 x̄: 2.00 x̃: 2
HURT stats (rel) min: 0.26% max: 1.30% x̄: 0.47% x̃: 0.43%
95% mean confidence interval for instructions value: 0.23 1.39
95% mean confidence interval for instructions %-change: -1.18% 0.07%
Inconclusive result (%-change mean confidence interval includes 0).
total cycles in shared programs: 177878928 -> 177879332 (<.01%)
cycles in affected programs: 383298 -> 383702 (0.11%)
helped: 7
HURT: 43
helped stats (abs) min: 2 max: 18 x̄: 10.00 x̃: 10
helped stats (rel) min: 0.17% max: 4.81% x̄: 2.62% x̃: 3.40%
HURT stats (abs) min: 2 max: 38 x̄: 11.02 x̃: 12
HURT stats (rel) min: 0.08% max: 1.54% x̄: 0.25% x̃: 0.09%
95% mean confidence interval for cycles value: 5.21 10.95
95% mean confidence interval for cycles %-change: -0.51% 0.21%
Inconclusive result (%-change mean confidence interval includes 0).
v2: s/fmin/fmax/. Noticed by Thomas Helland.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Thomas Helland <[email protected]>
Diffstat (limited to 'src/compiler/nir')
-rw-r--r-- | src/compiler/nir/nir_opt_algebraic.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index fd260650d8b..341d52d677b 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -170,6 +170,10 @@ optimizations = [ (('fne', ('fmax', ('b2f', a), ('b2f', b)), 0.0), ('ior', a, b)), (('fne', ('bcsel', a, 1.0, ('b2f', b)) , 0.0), ('ior', a, b)), (('fne', ('b2f', a), ('fneg', ('b2f', b))), ('ior', a, b)), + (('feq', ('fadd', ('b2f', a), ('b2f', b)), 0.0), ('inot', ('ior', a, b))), + (('feq', ('fmax', ('b2f', a), ('b2f', b)), 0.0), ('inot', ('ior', a, b))), + (('feq', ('bcsel', a, 1.0, ('b2f', b)) , 0.0), ('inot', ('ior', a, b))), + (('feq', ('b2f', a), ('fneg', ('b2f', b))), ('inot', ('ior', a, b))), # -(b2f(a) + b2f(b)) < 0 # 0 < b2f(a) + b2f(b) @@ -178,6 +182,13 @@ optimizations = [ (('flt', ('fneg', ('fadd', ('b2f', a), ('b2f', b))), 0.0), ('ior', a, b)), (('flt', 0.0, ('fadd', ('b2f', a), ('b2f', b))), ('ior', a, b)), + # -(b2f(a) + b2f(b)) >= 0 + # 0 >= b2f(a) + b2f(b) + # 0 == b2f(a) + b2f(b) b2f must be 0 or 1, so the sum is non-negative + # !(a || b) + (('fge', ('fneg', ('fadd', ('b2f', a), ('b2f', b))), 0.0), ('inot', ('ior', a, b))), + (('fge', 0.0, ('fadd', ('b2f', a), ('b2f', b))), ('inot', ('ior', a, b))), + # Some optimizations (below) convert things like (a < b || c < b) into # (min(a, c) < b). However, this interfers with the previous optimizations # that try to remove comparisons with negated sums of b2f. This just |