nir/opt_algebraic: Add an option to lower uclz.
authorGeorg Lehmann <dadschoorse@gmail.com>
Tue, 4 Oct 2022 13:38:58 +0000 (15:38 +0200)
committerGeorg Lehmann <dadschoorse@gmail.com>
Sat, 22 Oct 2022 09:57:10 +0000 (11:57 +0200)
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18951>

src/compiler/nir/nir.h
src/compiler/nir/nir_opt_algebraic.py

index c737230..a460faa 100644 (file)
@@ -3508,6 +3508,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.
     */
index 39ca3be..b8209f7 100644 (file)
@@ -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'),