pan/bi: Handle small vectors in bi_src_index()

bit_size <= 32 does not actually guarantee a single component, which
nir_src_as_uint() requires.  We could just check num_components == 1 but
it's easy enough to support any vector that fits in 32 bits.

Cc: mesa-stable
Reviewed-by: Romaric Jodin <rjodin@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38772>
This commit is contained in:
Faith Ekstrand 2025-12-05 13:55:49 -05:00 committed by Marge Bot
parent a051d4ee6b
commit d3a890a58e

View file

@ -1229,11 +1229,18 @@ bi_def_index(nir_def *def)
static inline bi_index
bi_src_index(nir_src *src)
{
if (nir_src_is_const(*src) && nir_src_bit_size(*src) <= 32) {
return bi_imm_u32(nir_src_as_uint(*src));
} else {
return bi_def_index(src->ssa);
if (nir_src_is_const(*src)) {
unsigned bit_size = nir_src_bit_size(*src);
unsigned num_comps = nir_src_num_components(*src);
if (bit_size * num_comps <= 32) {
uint32_t imm = 0;
for (uint32_t i = 0; i < num_comps; i++)
imm |= nir_src_comp_as_uint(*src, i) << (i * bit_size);
return bi_imm_u32(imm);
}
}
return bi_def_index(src->ssa);
}
/* Iterators for Bifrost IR */