[Mesa-dev] [PATCH v2 10/29] nir/algebraic: Optimize x2b(xneg(a)) -> a

Jason Ekstrand jason at jlekstrand.net
Thu Dec 6 19:45:01 UTC 2018


Shader-db results on Kaby Lake:

    total instructions in shared programs: 15072525 -> 15072525 (0.00%)
    instructions in affected programs: 0 -> 0
    helped: 0
    HURT: 0

This helps prevent regressions in later commits.
---
 src/compiler/nir/nir_opt_algebraic.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 28e8a96d4d5..ea24094a927 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -85,6 +85,8 @@ optimizations = [
    (('fabs', ('u2f', a)), ('u2f', a)),
    (('iabs', ('iabs', a)), ('iabs', a)),
    (('iabs', ('ineg', a)), ('iabs', a)),
+   (('f2b', ('fneg', a)), ('f2b', a)),
+   (('i2b', ('ineg', a)), ('i2b', a)),
    (('~fadd', a, 0.0), a),
    (('iadd', a, 0), a),
    (('usadd_4x8', a, 0), a),
-- 
2.19.2



More information about the mesa-dev mailing list