nir/opt_algebraic: Reduce int64
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sun, 1 Oct 2023 13:50:41 +0000 (09:50 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 12 Oct 2023 21:03:31 +0000 (21:03 +0000)
If we just want the bottom 32-bits we don't need a full 64-bit operation.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25625>

src/compiler/nir/nir_opt_algebraic.py

index a30eae0..22a1859 100644 (file)
@@ -1750,6 +1750,10 @@ optimizations.extend([
    (('extract_u8', ('pack_32_4x8_split', a, b, c, d), 1), ('u2u', b)),
    (('extract_u8', ('pack_32_4x8_split', a, b, c, d), 2), ('u2u', c)),
    (('extract_u8', ('pack_32_4x8_split', a, b, c, d), 3), ('u2u', d)),
+
+   # Reduce intermediate precision with int64.
+   (('u2u32', ('iadd(is_used_once)', 'a@64', b)),
+    ('iadd', ('u2u32', a), ('u2u32', b))),
 ])
 
 # After the ('extract_u8', a, 0) pattern, above, triggers, there will be