Mesa (master): nir/algebraic: Optimize comparing unpacked values

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 17 19:02:27 UTC 2019


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

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Fri Jul 12 23:26:48 2019 -0500

nir/algebraic: Optimize comparing unpacked values

We could, in theory, add the same optimization for 64-bit unpack
operations but that's likely to fight with 64-bit integer lowering on
platforms which require it so it will require more infrastructure before
that will be a good idea.

Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

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

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 6ae937651e0..42462d5befa 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -722,6 +722,14 @@ optimizations = [
    (('pack_64_2x32_split', ('unpack_64_2x32_split_x', a),
                            ('unpack_64_2x32_split_y', a)), a),
 
+   # Comparing two halves of an unpack separately.  While this optimization
+   # should be correct for non-constant values, it's less obvious that it's
+   # useful in that case.  For constant values, the pack will fold and we're
+   # guaranteed to reduce the whole tree to one instruction.
+   (('iand', ('ieq', ('unpack_32_2x16_split_x', a), '#b'),
+             ('ieq', ('unpack_32_2x16_split_y', a), '#c')),
+    ('ieq', a, ('pack_32_2x16_split', b, c))),
+
    # Byte extraction
    (('ushr', 'a at 16',  8), ('extract_u8', a, 1), '!options->lower_extract_byte'),
    (('ushr', 'a at 32', 24), ('extract_u8', a, 3), '!options->lower_extract_byte'),




More information about the mesa-commit mailing list