ir3/array_to_ssa: skip remove_trivial_phi for non-array phis

remove_trivial_phi() mostly does nothing for non-array phis, but it
rewrites sources if their definining instruction are trivial phis.

In the case of trivial phis in the loop continue block (for loops with
divergent non-trivial continues), we might need to keep those if they
write a shared register, because the source of the trivial phi will not be
reachable from the loop header phi.

In this example, the predecessors of the continue block should be block2,
but the physical predecessors are block2 and block3, requiring a phi in
the continue block which will then be lowered by ir3_lower_shared_phis.
loop {
   block1:
   a = phi 0, b
   if (divergent) {
      block2:
      b = a + 1
      continue;
   }
   block3:
   break;
}

Fixes RA validation error when compiling blackmythwukong/5645a84e669a6179
from radv_fossils.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Backport-to: 26.0
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40480>
This commit is contained in:
Rhys Perry 2026-03-17 14:32:37 +00:00 committed by Marge Bot
parent 3be57aa4c3
commit 4f0fb5784f

View file

@ -236,10 +236,13 @@ ir3_array_to_ssa(struct ir3 *ir)
foreach_block (block, &ir->block_list) {
foreach_instr_safe (instr, &block->instr_list) {
if (instr->opc == OPC_META_PHI)
if (instr->opc == OPC_META_PHI) {
if (!(instr->dsts[0]->flags & IR3_REG_ARRAY))
continue;
remove_trivial_phi(instr);
else
} else {
break;
}
}
}