Mesa (staging/20.1): nir/algebraic: Optimize ushr of pack_half, not ishr

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 13 12:45:23 UTC 2020


Module: Mesa
Branch: staging/20.1
Commit: 750a0125dffc7c43fa6927e2025bc19ed3d3244f
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=750a0125dffc7c43fa6927e2025bc19ed3d3244f

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Apr  2 12:14:12 2020 -0700

nir/algebraic: Optimize ushr of pack_half, not ishr

When a = -1.0, pack_half_2x16(vec2(0x0000, 0xBC00)) will produce
0xBC000000.  The ishr will produce 0xFFFFBC00.  The replacement
pack_half_2x16(vec2(0xBC00, 0x0000)) will produce 0x0000BC00.

Fixes: 1f72857739b ("nir/algebraic: add some half packing optimizations")
Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Matt Turner <mattst88 at gmail.com>
Cc: Connor Abbott <cwabbott0 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4515>
(cherry picked from commit a2bf41ec6527fbedc2a75a8072d7222298bca347)

---

 .pick_status.json                     | 2 +-
 src/compiler/nir/nir_opt_algebraic.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index a65e8bfe8a0..720636a7d89 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -661,7 +661,7 @@
         "description": "nir/algebraic: Optimize ushr of pack_half, not ishr",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "1f72857739beed55276f263f49b3802c336b8c58"
     },
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 58ff35af0b0..8ca3f77905e 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -998,7 +998,7 @@ optimizations.extend([
 
    # Optimize half packing
    (('ishl', ('pack_half_2x16', ('vec2', a, 0)), 16), ('pack_half_2x16', ('vec2', 0, a))),
-   (('ishr', ('pack_half_2x16', ('vec2', 0, a)), 16), ('pack_half_2x16', ('vec2', a, 0))),
+   (('ushr', ('pack_half_2x16', ('vec2', 0, a)), 16), ('pack_half_2x16', ('vec2', a, 0))),
 
    (('iadd', ('pack_half_2x16', ('vec2', a, 0)), ('pack_half_2x16', ('vec2', 0, b))),
     ('pack_half_2x16', ('vec2', a, b))),



More information about the mesa-commit mailing list