nir: fix shrinking of load_const for large vectors
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 <pavel.ondracka@gmail.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20213>
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user