Mesa (master): nir/algebraic: a & ~(a >> 31) -> imax(a, 0)

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 14 18:15:37 UTC 2020


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

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Tue Dec 10 16:20:56 2019 +0000

nir/algebraic: a & ~(a >> 31) -> imax(a, 0)

Found in some Doom shaders

Totals from affected shaders:
SGPRS: 30056 -> 30064 (0.03 %)
VGPRS: 28024 -> 28024 (0.00 %)
Spilled SGPRs: 0 -> 0 (0.00 %)
Spilled VGPRs: 0 -> 0 (0.00 %)
Code Size: 4278648 -> 4270852 (-0.18 %) bytes
Max Waves: 1476 -> 1476 (0.00 %)
Instructions: 835287 -> 833338 (-0.23 %)

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3089>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3089>

---

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

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 633ee8792d9..fbf0f694430 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -480,6 +480,7 @@ optimizations.extend([
    (('fmin', ('fmin', a, b), b), ('fmin', a, b)),
    (('umin', ('umin', a, b), b), ('umin', a, b)),
    (('imin', ('imin', a, b), b), ('imin', a, b)),
+   (('iand at 32', a, ('inot', ('ishr', a, 31))), ('imax', a, 0)),
    (('fmax', a, ('fneg', a)), ('fabs', a)),
    (('imax', a, ('ineg', a)), ('iabs', a)),
    (('fmin', a, ('fneg', a)), ('fneg', ('fabs', a))),



More information about the mesa-commit mailing list