diff options
author | Ian Romanick <[email protected]> | 2018-09-10 10:39:42 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2018-10-09 13:56:42 -0700 |
commit | 1546204cdd45476a2cc4ff4adcc742505366398f (patch) | |
tree | 0e89e92c8fe2ab0d5076c5d2ec4c514811cf54f5 /src/compiler/nir/nir_opt_algebraic.py | |
parent | 10f4a8871ec694b9d2835d670dfc1436736c23d2 (diff) |
nir/algebraic: sign(x)*x*x is abs(x)*x
shader-db results:
All Gen7+ platforms had similar results. (Skylake shown)
total instructions in shared programs: 15106023 -> 15105981 (<.01%)
instructions in affected programs: 300 -> 258 (-14.00%)
helped: 6
HURT: 0
helped stats (abs) min: 7 max: 7 x̄: 7.00 x̃: 7
helped stats (rel) min: 14.00% max: 14.00% x̄: 14.00% x̃: 14.00%
95% mean confidence interval for instructions value: -7.00 -7.00
95% mean confidence interval for instructions %-change: -14.00% -14.00%
Instructions are helped.
total cycles in shared programs: 566050327 -> 566050075 (<.01%)
cycles in affected programs: 2826 -> 2574 (-8.92%)
helped: 6
HURT: 0
helped stats (abs) min: 40 max: 44 x̄: 42.00 x̃: 42
helped stats (rel) min: 8.89% max: 8.94% x̄: 8.92% x̃: 8.92%
95% mean confidence interval for cycles value: -44.30 -39.70
95% mean confidence interval for cycles %-change: -8.95% -8.88%
Cycles are helped.
No changes on Gen6 or earlier.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Thomas Helland <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_opt_algebraic.py')
-rw-r--r-- | src/compiler/nir/nir_opt_algebraic.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index ae1261f8744..3267e93a583 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -105,6 +105,11 @@ optimizations = [ (('imul', a, 1), a), (('fmul', a, -1.0), ('fneg', a)), (('imul', a, -1), ('ineg', a)), + # If a < 0: fsign(a)*a*a => -1*a*a => -a*a => abs(a)*a + # If a > 0: fsign(a)*a*a => 1*a*a => a*a => abs(a)*a + # If a == 0: fsign(a)*a*a => 0*0*0 => abs(0)*0 + (('fmul', ('fsign', a), ('fmul', a, a)), ('fmul', ('fabs', a), a)), + (('fmul', ('fmul', ('fsign', a), a), a), ('fmul', ('fabs', a), a)), (('~ffma', 0.0, a, b), b), (('~ffma', a, 0.0, b), b), (('~ffma', a, b, 0.0), ('fmul', a, b)), |