From 42a4c09b728b1e117f96994d9b3003fbba11fdf7 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 2 Jul 2023 09:46:12 -0400 Subject: [PATCH] agx: Try to allocate phi sources with loop phis total instructions in shared programs: 1788666 -> 1788606 (<.01%) instructions in affected programs: 7953 -> 7893 (-0.75%) helped: 29 HURT: 0 Instructions are helped. total bytes in shared programs: 12196852 -> 12196492 (<.01%) bytes in affected programs: 53908 -> 53548 (-0.67%) helped: 29 HURT: 0 Bytes are helped. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_register_allocate.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/asahi/compiler/agx_register_allocate.c b/src/asahi/compiler/agx_register_allocate.c index 7679a27..0452888 100644 --- a/src/asahi/compiler/agx_register_allocate.c +++ b/src/asahi/compiler/agx_register_allocate.c @@ -877,6 +877,14 @@ pick_regs(struct ra_ctx *rctx, agx_instr *I, unsigned d) if (try_coalesce_with(rctx, phi->src[s], count, true, &out)) return out; } + + /* If we're in a loop, we may have already allocated the phi. Try that. */ + if (phi->dest[0].type == AGX_INDEX_REGISTER) { + unsigned base = phi->dest[0].value; + + if (!BITSET_TEST_RANGE(rctx->used_regs, base, base + count - 1)) + return base; + } } /* Default to any contiguous sequence of registers */ -- 2.7.4