Mesa (main): nir/algebraic: Add some boolean optimizations

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Oct 7 18:53:01 UTC 2021


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

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Wed Oct 28 22:32:16 2020 -0500

nir/algebraic: Add some boolean optimizations

Reviewed-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13167>

---

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

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 2cfbc277b1a..1862fe98e0f 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -1241,9 +1241,22 @@ optimizations.extend([
    (('ieq', ('ineg', ('b2i', 'a at 1')), -1), a),
    (('ine', ('ineg', ('b2i', 'a at 1')), 0), a),
    (('ine', ('ineg', ('b2i', 'a at 1')), -1), ('inot', a)),
+   (('ige', ('ineg', ('b2i', 'a at 1')), 0), ('inot', a)),
+   (('ilt', ('ineg', ('b2i', 'a at 1')), 0), a),
+   (('ult', 0, ('ineg', ('b2i', 'a at 1'))), a),
    (('iand', ('ineg', ('b2i', a)), 1.0), ('b2f', a)),
    (('iand', ('ineg', ('b2i', a)), 1),   ('b2i', a)),
 
+   # With D3D booleans, imax is AND and umax is OR
+   (('imax', ('ineg', ('b2i', 'a at 1')), ('ineg', ('b2i', 'b at 1'))),
+    ('ineg', ('b2i', ('iand', a, b)))),
+   (('imin', ('ineg', ('b2i', 'a at 1')), ('ineg', ('b2i', 'b at 1'))),
+    ('ineg', ('b2i', ('ior', a, b)))),
+   (('umax', ('ineg', ('b2i', 'a at 1')), ('ineg', ('b2i', 'b at 1'))),
+    ('ineg', ('b2i', ('ior', a, b)))),
+   (('umin', ('ineg', ('b2i', 'a at 1')), ('ineg', ('b2i', 'b at 1'))),
+    ('ineg', ('b2i', ('iand', a, b)))),
+
    # Conversions
    (('i2b16', ('b2i', 'a at 16')), a),
    (('i2b32', ('b2i', 'a at 32')), a),



More information about the mesa-commit mailing list