Mesa (main): nir/algebraic: optimize extract of extract

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 8 09:19:34 UTC 2021


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

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Fri Apr  3 14:41:38 2020 +0100

nir/algebraic: optimize extract of extract

Found in some sottr shaders (originally iand(ishr(a, 16), 0xffff))

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3151>

---

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

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index fa9ecf7c531..6339ebb5079 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -1258,6 +1258,9 @@ optimizations.extend([
    (('ibfe', a, 16, 8), ('extract_i8', a, 2), '!options->lower_extract_byte'),
    (('ibfe', a, 24, 8), ('extract_i8', a, 3), '!options->lower_extract_byte'),
 
+   (('extract_u8', ('extract_i8', a, b), 0), ('extract_u8', a, b)),
+   (('extract_u8', ('extract_u8', a, b), 0), ('extract_u8', a, b)),
+
     # Word extraction
    (('ushr', ('ishl', 'a at 32', 16), 16), ('extract_u16', a, 0), '!options->lower_extract_word'),
    (('ushr', 'a at 32', 16), ('extract_u16', a, 1), '!options->lower_extract_word'),
@@ -1270,6 +1273,9 @@ optimizations.extend([
    (('ibfe', a,  0, 16), ('extract_i16', a, 0), '!options->lower_extract_word'),
    (('ibfe', a, 16, 16), ('extract_i16', a, 1), '!options->lower_extract_word'),
 
+   (('extract_u16', ('extract_i16', a, b), 0), ('extract_u16', a, b)),
+   (('extract_u16', ('extract_u16', a, b), 0), ('extract_u16', a, b)),
+
    # Lower pack/unpack
    (('pack_64_2x32_split', a, b), ('ior', ('u2u64', a), ('ishl', ('u2u64', b), 32)), 'options->lower_pack_64_2x32_split'),
    (('pack_32_2x16_split', a, b), ('ior', ('u2u32', a), ('ishl', ('u2u32', b), 16)), 'options->lower_pack_32_2x16_split'),



More information about the mesa-commit mailing list