From dbef8f1791cc79da4eef6a5a78c30ae286a7ca4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 9 May 2025 10:47:05 -0400 Subject: [PATCH] nir/opt_vectorize_io: fix a failure when vectorizing different bit sizes Fixes: 2514999c9c5 - nir: add nir_opt_vectorize_io, vectorizing lowered IO Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13085 Reviewed-by: Georg Lehmann Part-of: --- src/compiler/nir/nir_opt_vectorize_io.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/compiler/nir/nir_opt_vectorize_io.c b/src/compiler/nir/nir_opt_vectorize_io.c index 1c357dc1827..01706d1caec 100644 --- a/src/compiler/nir/nir_opt_vectorize_io.c +++ b/src/compiler/nir/nir_opt_vectorize_io.c @@ -76,6 +76,19 @@ compare_is_not_vectorizable(nir_intrinsic_instr *a, nir_intrinsic_instr *b) sem0.high_16bits != sem1.high_16bits) return sem0.high_16bits > sem1.high_16bits ? 1 : -1; + /* TODO: vectorize (f32, f32, f16vec2, f16vec2) -> vec4 + * For now, different bit sizes are not vectorized together. + */ + if (nir_intrinsic_has_src_type(a)) { + /* Stores. */ + if (a->src[0].ssa->bit_size != b->src[0].ssa->bit_size) + return a->src[0].ssa->bit_size > b->src[0].ssa->bit_size ? 1 : -1; + } else { + /* Loads. */ + if (a->def.bit_size != b->def.bit_size) + return a->def.bit_size > b->def.bit_size ? 1 : -1; + } + nir_shader *shader = nir_cf_node_get_function(&a->instr.block->cf_node)->function->shader;