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

Author: Georg Lehmann <[email protected]>
Date:   Tue Oct  4 15:38:58 2022 +0200

nir/opt_algebraic: Add an option to lower uclz.

Signed-off-by: Georg Lehmann <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Reviewed-by: Rhys Perry <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18951>

---

 src/compiler/nir/nir.h                | 5 +++++
 src/compiler/nir/nir_opt_algebraic.py | 2 ++
 2 files changed, 7 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index c7372301f4a..a460faad950 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3507,6 +3507,11 @@ typedef struct nir_shader_compiler_options {
     */
    bool lower_mul_32x16;
 
+   /**
+    * Set if uclz should be lowered to find_msb_rev.
+    */
+   bool lower_uclz;
+
    /**
     * Should IO be re-vectorized?  Some scalar ISAs still operate on vec4's
     * for IO purposes and would prefer loads/stores be vectorized.
diff --git a/src/compiler/nir/nir_opt_algebraic.py 
b/src/compiler/nir/nir_opt_algebraic.py
index 39ca3be927b..b8209f732d8 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -1889,6 +1889,8 @@ optimizations.extend([
       ('ufind_msb_rev', 'value')),
      'options->lower_find_msb_to_reverse'),
 
+   (('uclz', a), ('umin', 32, ('ufind_msb_rev', a)), 'options->lower_uclz'),
+
    (('find_lsb', 'value'),
     ('ufind_msb', ('iand', 'value', ('ineg', 'value'))),
     'options->lower_find_lsb'),

Reply via email to