diff --git a/src/asahi/compiler/agx_register_allocate.c b/src/asahi/compiler/agx_register_allocate.c index 7c9364f629e..4c0f5df9cc5 100644 --- a/src/asahi/compiler/agx_register_allocate.c +++ b/src/asahi/compiler/agx_register_allocate.c @@ -769,6 +769,18 @@ pick_regs(struct ra_ctx *rctx, agx_instr *I, unsigned d) unsigned align = count; + /* Try to allocate phis compatibly with their sources */ + if (I->op == AGX_OPCODE_PHI) { + agx_foreach_ssa_src(I, s) { + /* Loop headers have phis with a source preceding the definition */ + bool may_be_unvisited = rctx->block->loop_header; + + unsigned out; + if (try_coalesce_with(rctx, I->src[s], count, may_be_unvisited, &out)) + return out; + } + } + /* Try to allocate collects compatibly with their sources */ if (I->op == AGX_OPCODE_COLLECT) { agx_foreach_ssa_src(I, s) {