Mesa (main): nir/algebraic: Mark some more logic-joined comparison reductions as exact

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu May 20 02:09:22 UTC 2021


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Jan 28 18:15:26 2021 -0800

nir/algebraic: Mark some more logic-joined comparison reductions as exact

If the values are known to be numbers, the the replacements are exact.
This is only applied to the patterns with constants.  Constants should
always be numbers, and shaders with NaN constants should be handled in a
different way.

No shader-db or fossil-db changes on any Intel platform.  The intention
is to make these patterns more future proof.

Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10012>

---

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

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 639e44509f1..748fae79be9 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -663,10 +663,10 @@ optimizations.extend([
    (('~iand', ('flt(is_used_once)', a, c), ('flt', b, c)), ('flt', ('fmax', a, b), c)),
    (('~iand', ('fge(is_used_once)', a, b), ('fge', a, c)), ('fge', a, ('fmax', b, c))),
    (('~iand', ('fge(is_used_once)', a, c), ('fge', b, c)), ('fge', ('fmin', a, b), c)),
-   (('~iand', ('flt', a, '#b'), ('flt', a, '#c')), ('flt', a, ('fmin', b, c))),
-   (('~iand', ('flt', '#a', c), ('flt', '#b', c)), ('flt', ('fmax', a, b), c)),
-   (('~iand', ('fge', a, '#b'), ('fge', a, '#c')), ('fge', a, ('fmax', b, c))),
-   (('~iand', ('fge', '#a', c), ('fge', '#b', c)), ('fge', ('fmin', a, b), c)),
+   (('iand', ('flt', a, '#b(is_a_number)'), ('flt', a, '#c(is_a_number)')), ('flt', a, ('fmin', b, c))),
+   (('iand', ('flt', '#a(is_a_number)', c), ('flt', '#b(is_a_number)', c)), ('flt', ('fmax', a, b), c)),
+   (('iand', ('fge', a, '#b(is_a_number)'), ('fge', a, '#c(is_a_number)')), ('fge', a, ('fmax', b, c))),
+   (('iand', ('fge', '#a(is_a_number)', c), ('fge', '#b(is_a_number)', c)), ('fge', ('fmin', a, b), c)),
 
    (('ior', ('ilt(is_used_once)', a, b), ('ilt', a, c)), ('ilt', a, ('imax', b, c))),
    (('ior', ('ilt(is_used_once)', a, c), ('ilt', b, c)), ('ilt', ('imin', a, b), c)),



More information about the mesa-commit mailing list