Mesa (master): nir/algebraic: add scmp algebraic optimizations

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jul 24 21:48:31 UTC 2019


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

Author: Jonathan Marek <jonathan at marek.ca>
Date:   Wed Jul 24 13:33:17 2019 -0400

nir/algebraic: add scmp algebraic optimizations

When 'x' is the result of a scmp op:

x != 0.0 or x == 1.0: passthrough
x == 0.0 or x != 1.0: invert

Signed-off-by: Jonathan Marek <jonathan at marek.ca>
Reviewed-by: Matt Turner <mattst88 at gmail.com>

---

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

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index e4f4a652c19..351f467b246 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -568,6 +568,22 @@ optimizations = [
    (('sge', a, b), ('b2f', ('fge', a, b)), 'options->lower_scmp'),
    (('seq', a, b), ('b2f', ('feq', a, b)), 'options->lower_scmp'),
    (('sne', a, b), ('b2f', ('fne', a, b)), 'options->lower_scmp'),
+   (('seq', ('seq', a, b), 1.0), ('seq', a, b)),
+   (('seq', ('sne', a, b), 1.0), ('sne', a, b)),
+   (('seq', ('slt', a, b), 1.0), ('slt', a, b)),
+   (('seq', ('sge', a, b), 1.0), ('sge', a, b)),
+   (('sne', ('seq', a, b), 0.0), ('seq', a, b)),
+   (('sne', ('sne', a, b), 0.0), ('sne', a, b)),
+   (('sne', ('slt', a, b), 0.0), ('slt', a, b)),
+   (('sne', ('sge', a, b), 0.0), ('sge', a, b)),
+   (('seq', ('seq', a, b), 0.0), ('sne', a, b)),
+   (('seq', ('sne', a, b), 0.0), ('seq', a, b)),
+   (('seq', ('slt', a, b), 0.0), ('sge', a, b)),
+   (('seq', ('sge', a, b), 0.0), ('slt', a, b)),
+   (('sne', ('seq', a, b), 1.0), ('sne', a, b)),
+   (('sne', ('sne', a, b), 1.0), ('seq', a, b)),
+   (('sne', ('slt', a, b), 1.0), ('sge', a, b)),
+   (('sne', ('sge', a, b), 1.0), ('slt', a, b)),
    (('fall_equal2', a, b), ('fmin', ('seq', 'a.x', 'b.x'), ('seq', 'a.y', 'b.y')), 'options->lower_vector_cmp'),
    (('fall_equal3', a, b), ('seq', ('fany_nequal3', a, b), 0.0), 'options->lower_vector_cmp'),
    (('fall_equal4', a, b), ('seq', ('fany_nequal4', a, b), 0.0), 'options->lower_vector_cmp'),




More information about the mesa-commit mailing list