From d3a890a58e722e22b8e8d2550603273fd12d82d1 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Fri, 5 Dec 2025 13:55:49 -0500 Subject: [PATCH] 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 Part-of: --- src/panfrost/compiler/bifrost/compiler.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/panfrost/compiler/bifrost/compiler.h b/src/panfrost/compiler/bifrost/compiler.h index 29d54fa2071..6985d9f2191 100644 --- a/src/panfrost/compiler/bifrost/compiler.h +++ b/src/panfrost/compiler/bifrost/compiler.h @@ -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 */