Module: Mesa
Branch: main
Commit: 60c9a45562255499a1adfe0983fcace3ea690d2a
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=60c9a45562255499a1adfe0983fcace3ea690d2a

Author: Georg Lehmann <[email protected]>
Date:   Mon May  9 11:52:26 2022 +0200

nir/opt_algebraic: Simple xor/ishr optimizations.

The first pattern here removes the xor-swap pattern.

Foz-DB GFX10_3:
Totals from 305 (0.23% of 134913) affected shaders:
CodeSize: 1589040 -> 1585164 (-0.24%)
Instrs: 284344 -> 283375 (-0.34%)
Latency: 4205148 -> 4198472 (-0.16%); split: -0.16%, +0.00%
InvThroughput: 708745 -> 708739 (-0.00%)

Signed-off-by: Georg Lehmann <[email protected]>
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Reviewed-by: Timur Kristóf <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16411>

---

 src/compiler/nir/nir_opt_algebraic.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index 222727d4f2a..3c78fc01a48 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -1210,6 +1210,8 @@ optimizations.extend([
    (('ior', a, True), True),
    (('ixor', a, a), 0),
    (('ixor', a, 0), a),
+   (('ixor', a, ('ixor', a, b)), b),
+   (('ixor', a, -1), ('inot', a)),
    (('inot', ('inot', a)), a),
    (('ior', ('iand', a, b), b), b),
    (('ior', ('ior', a, b), b), ('ior', a, b)),
@@ -1222,6 +1224,7 @@ optimizations.extend([
    (('ishl', 0, a), 0),
    (('ishl', a, 0), a),
    (('ishr', 0, a), 0),
+   (('ishr', -1, a), -1),
    (('ishr', a, 0), a),
    (('ushr', 0, a), 0),
    (('ushr', a, 0), a),

Reply via email to