Mesa (master): nir: Optimize mask+downcast to just downcast

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 17 16:11:42 UTC 2020


Module: Mesa
Branch: master
Commit: a1ed83fddd7518cc92b609d60129426bd9b4158d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1ed83fddd7518cc92b609d60129426bd9b4158d

Author: Jesse Natalie <jenatali at microsoft.com>
Date:   Thu May 21 15:05:08 2020 -0700

nir: Optimize mask+downcast to just downcast

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Reviewed-by: Karol Herbst <kherbst at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6330>

---

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

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 423fd06b879..1762591bd12 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -1604,6 +1604,16 @@ for t in ['int', 'uint', 'float']:
                           ('ior', (xge, a, xN_max), (xge, (x2xN, a), b))), cond),
             ]
 
+# Convert masking followed by signed downcast to just unsigned downcast
+optimizations += [
+    (('i2i32', ('iand', 'a at 64', 0xffffffff)), ('u2u32', a)),
+    (('i2i16', ('iand', 'a at 32', 0xffff)), ('u2u16', a)),
+    (('i2i16', ('iand', 'a at 64', 0xffff)), ('u2u16', a)),
+    (('i2i8', ('iand', 'a at 16', 0xff)), ('u2u8', a)),
+    (('i2i8', ('iand', 'a at 32', 0xff)), ('u2u8', a)),
+    (('i2i8', ('iand', 'a at 64', 0xff)), ('u2u8', a)),
+]
+
 def fexp2i(exp, bits):
    # Generate an expression which constructs value 2.0^exp or 0.0.
    #



More information about the mesa-commit mailing list