nir/builder: Do not generate 8- or 16-bit find_msb
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 8 Mar 2023 17:35:07 +0000 (09:35 -0800)
committerMarge Bot <emma+marge@anholt.net>
Fri, 10 Mar 2023 15:27:17 +0000 (15:27 +0000)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19042>

src/compiler/nir/nir_builtin_builder.h

index ca28dd1..acbf0c6 100644 (file)
@@ -237,7 +237,8 @@ static inline nir_ssa_def *
 nir_clz_u(nir_builder *b, nir_ssa_def *a)
 {
    nir_ssa_def *val;
-   val = nir_isub(b, nir_imm_intN_t(b, a->bit_size - 1, 32), nir_ufind_msb(b, a));
+   val = nir_isub(b, nir_imm_intN_t(b, a->bit_size - 1, 32),
+                  nir_ufind_msb(b, nir_u2uN(b, a, MAX2(a->bit_size, 32))));
    return nir_u2uN(b, val, a->bit_size);
 }