Mesa (main): nir/algebraic: don't optimize umod/imod/irem if lower_bitops=true

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 9 11:39:13 UTC 2021


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

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Wed Jul 21 17:08:52 2021 +0100

nir/algebraic: don't optimize umod/imod/irem if lower_bitops=true

Match the udiv/idiv/imul by power-of-two optimizations.

Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12039>

---

 src/compiler/nir/nir_opt_algebraic.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 32547027679..bbc89b6ad86 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -112,11 +112,11 @@ optimizations = [
    (('udiv', a, '#b(is_pos_power_of_two)'), ('ushr', a, ('find_lsb', b)), '!options->lower_bitops'),
    (('idiv', a, '#b(is_pos_power_of_two)'), ('imul', ('isign', a), ('ushr', ('iabs', a), ('find_lsb', b))), '!options->lower_bitops'),
    (('idiv', a, '#b(is_neg_power_of_two)'), ('ineg', ('imul', ('isign', a), ('ushr', ('iabs', a), ('find_lsb', ('iabs', b))))), '!options->lower_bitops'),
-   (('umod', a, '#b(is_pos_power_of_two)'),    ('iand', a, ('isub', b, 1))),
-   (('imod', a, '#b(is_pos_power_of_two)'),    ('iand', a, ('isub', b, 1))),
-   (('imod', a, '#b(is_neg_power_of_two)'),    ('bcsel', ('ieq', ('ior', a, b), b), 0, ('ior', a, b))),
-   (('irem', a, '#b(is_pos_power_of_two)'),    ('bcsel', ('ige', a, 0), ('iand', a, ('isub', b, 1)), ('imod', a, ('ineg', b)))),
-   (('irem', a, '#b(is_neg_power_of_two)'),    ('bcsel', ('ige', a, 0), ('iand', a, ('inot', b)), ('imod', a, b))),
+   (('umod', a, '#b(is_pos_power_of_two)'),    ('iand', a, ('isub', b, 1)), '!options->lower_bitops'),
+   (('imod', a, '#b(is_pos_power_of_two)'),    ('iand', a, ('isub', b, 1)), '!options->lower_bitops'),
+   (('imod', a, '#b(is_neg_power_of_two)'),    ('bcsel', ('ieq', ('ior', a, b), b), 0, ('ior', a, b)), '!options->lower_bitops'),
+   (('irem', a, '#b(is_pos_power_of_two)'),    ('bcsel', ('ige', a, 0), ('iand', a, ('isub', b, 1)), ('imod', a, ('ineg', b))), '!options->lower_bitops'),
+   (('irem', a, '#b(is_neg_power_of_two)'),    ('bcsel', ('ige', a, 0), ('iand', a, ('inot', b)), ('imod', a, b)), '!options->lower_bitops'),
 
    (('~fneg', ('fneg', a)), a),
    (('ineg', ('ineg', a)), a),



More information about the mesa-commit mailing list