Module: Mesa
Branch: staging/20.2
Commit: a66268d3f4f700b37bd09a87a1fe73f3dba33ac7
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a66268d3f4f700b37bd09a87a1fe73f3dba33ac7

Author: Jose Maria Casanova Crespo <[email protected]>
Date:   Fri Oct  9 18:33:26 2020 +0200

nir/algebraic: optimize iand/ior of (n)eq zero when umax/umin not available

Before 8e1b75b330954a ("nir/algebraic: optimize iand/ior of (n)eq zero") this
optimization didn't need the use of umax/umin. VC4 HW supports only signed
integer max/min operations.

lower_umin and lower_umax are added to allow enabling previous optimizations
behaviour for this cases.

Fixes: 8e1b75b330954a ("nir/algebraic: optimize iand/ior of (n)eq zero")
Reviewed-by: Alejandro Piñeiro <[email protected]>
Reviewed-by: Daniel Schürmann <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7083>
(cherry picked from commit e7127b3468cbaa888bfd21ebeb2f34ab8dd8b78d)

---

 .pick_status.json                     |  2 +-
 src/compiler/nir/nir.h                |  6 ++++++
 src/compiler/nir/nir_opt_algebraic.py | 10 ++++++----
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 27367ea6ec7..0d642859000 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -5917,7 +5917,7 @@
         "description": "nir/algebraic: optimize iand/ior of (n)eq zero when 
umax/umin not available",
         "nominated": true,
         "nomination_type": 1,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": "8e1b75b330954a2e40e8ed0c04871e43120d4f4a"
     },
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 0f3578e7f8a..e3328962ea2 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3017,6 +3017,12 @@ typedef struct nir_shader_compiler_options {
    /** enables rules to lower fsign to fsub and flt */
    bool lower_fsign;
 
+   /** enable rules that avoid generating umax from signed integer ops */
+   bool lower_umax;
+
+   /** enable rules that avoid generating umin from signed integer ops */
+   bool lower_umin;
+
    /* lower fdph to fdot4 */
    bool lower_fdph;
 
diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index b3462536222..f0dff6835b2 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -652,10 +652,12 @@ optimizations.extend([
    (('ine', ('ineg', ('b2i32', 'a@1')), ('ineg', ('b2i32', 'b@1'))), ('ine', 
a, b)),
    (('b2i32', ('ine', 'a@1', 'b@1')), ('b2i32', ('ixor', a, b))),
 
-   (('iand', ('ieq', 'a@32', 0), ('ieq', 'b@32', 0)), ('ieq', ('umax', a, b), 
0)),
-   (('ior',  ('ieq', 'a@32', 0), ('ieq', 'b@32', 0)), ('ieq', ('umin', a, b), 
0)),
-   (('iand', ('ine', 'a@32', 0), ('ine', 'b@32', 0)), ('ine', ('umin', a, b), 
0)),
-   (('ior',  ('ine', 'a@32', 0), ('ine', 'b@32', 0)), ('ine', ('umax', a, b), 
0)),
+   (('iand', ('ieq', 'a@{}'.format(s), 0), ('ieq', 'b@{}'.format(s), 0)), 
('ieq', ('ior', a, b), 0), 'options->lower_umax'),
+   (('ior',  ('ine', 'a@{}'.format(s), 0), ('ine', 'b@{}'.format(s), 0)), 
('ine', ('ior', a, b), 0), 'options->lower_umin'),
+   (('iand', ('ieq', 'a@{}'.format(s), 0), ('ieq', 'b@{}'.format(s), 0)), 
('ieq', ('umax', a, b), 0), '!options->lower_umax'),
+   (('ior',  ('ieq', 'a@{}'.format(s), 0), ('ieq', 'b@{}'.format(s), 0)), 
('ieq', ('umin', a, b), 0), '!options->lower_umin'),
+   (('iand', ('ine', 'a@{}'.format(s), 0), ('ine', 'b@{}'.format(s), 0)), 
('ine', ('umin', a, b), 0), '!options->lower_umin'),
+   (('ior',  ('ine', 'a@{}'.format(s), 0), ('ine', 'b@{}'.format(s), 0)), 
('ine', ('umax', a, b), 0), '!options->lower_umax'),
 
    # This pattern occurs coutresy of __flt64_nonnan in the soft-fp64 code.
    # The first part of the iand comes from the !__feq64_nonnan.

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to