From 3305c9602df65d08f586ee520de9d8f0c46b14f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Ondra=C4=8Dka?= Date: Sat, 31 Dec 2022 12:04:28 +0100 Subject: [PATCH] nir: fix shrinking of load_const for large vectors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Specifically when shrinking load_const with number of components > 5, if the final number of components is not allowed (for example 8->6) it would report false for progress even if we actually did some reshuffling and also it would skip on the rewrite of the readers. Signed-off-by: Pavel Ondračka Reviewed-by: Daniel Schürmann Part-of: --- src/compiler/nir/nir_opt_shrink_vectors.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/compiler/nir/nir_opt_shrink_vectors.c b/src/compiler/nir/nir_opt_shrink_vectors.c index bd842021cdc..fc123ac8ee7 100644 --- a/src/compiler/nir/nir_opt_shrink_vectors.c +++ b/src/compiler/nir/nir_opt_shrink_vectors.c @@ -304,6 +304,7 @@ opt_shrink_vectors_load_const(nir_load_const_instr *instr) uint8_t reswizzle[NIR_MAX_VEC_COMPONENTS] = { 0 }; unsigned num_components = 0; + bool progress = false; for (unsigned i = 0; i < def->num_components; i++) { if (!((mask >> i) & 0x1)) continue; @@ -313,6 +314,7 @@ opt_shrink_vectors_load_const(nir_load_const_instr *instr) for (j = 0; j < num_components; j++) { if (instr->value[i].u64 == instr->value[j].u64) { reswizzle[i] = j; + progress = true; break; } } @@ -320,21 +322,20 @@ opt_shrink_vectors_load_const(nir_load_const_instr *instr) /* Otherwise, just append the value */ if (j == num_components) { instr->value[num_components] = instr->value[i]; + if (i != num_components) + progress = true; reswizzle[i] = num_components++; } } unsigned rounded = round_up_components(num_components); assert(rounded <= def->num_components); - num_components = rounded; - if (num_components == def->num_components) - return false; + def->num_components = rounded; + if (progress) + reswizzle_alu_uses(def, reswizzle); - def->num_components = num_components; - reswizzle_alu_uses(def, reswizzle); - - return true; + return progress; } static bool