nir: Fix nir_chase_binding() vecN handling

In the comments we claimed to handle vecN instructions, for the case
where an offset is trimmed from the descriptor, but we didn't ignore the
offset itself and in effect only handled identity vecN's (which copy
propagation would normally remove already!), so the handling of vecN was
useless and this relied on copy propagation cleaning things up. Fix it
to ignore everything except the components in the original source.

Reviewed-by: Emma Anholt <emma@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18703>
This commit is contained in:
Connor Abbott 2022-09-16 16:00:07 +02:00 committed by Marge Bot
parent bd51305943
commit e402d2dbe9

View file

@ -2804,17 +2804,18 @@ nir_binding nir_chase_binding(nir_src rsrc)
* instructions to skip trimming of vec2_index_32bit_offset addresses after
* lowering ALU to scalar.
*/
unsigned num_components = nir_src_num_components(rsrc);
while (true) {
nir_alu_instr *alu = nir_src_as_alu_instr(rsrc);
nir_intrinsic_instr *intrin = nir_src_as_intrinsic(rsrc);
if (alu && alu->op == nir_op_mov) {
for (unsigned i = 0; i < alu->dest.dest.ssa.num_components; i++) {
for (unsigned i = 0; i < num_components; i++) {
if (alu->src[0].swizzle[i] != i)
return (nir_binding){0};
}
rsrc = alu->src[0].src;
} else if (alu && nir_op_is_vec(alu->op)) {
for (unsigned i = 0; i < nir_op_infos[alu->op].num_inputs; i++) {
for (unsigned i = 0; i < num_components; i++) {
if (alu->src[i].swizzle[0] != i || alu->src[i].src.ssa != alu->src[0].src.ssa)
return (nir_binding){0};
}