From 94124925caf177bfe8239ff6b591d62fc5e51772 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 19 Nov 2022 16:43:19 -0500 Subject: [PATCH] agx: Try to align sources of pack_64_2x32_split Helps with coalescing the pack. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_register_allocate.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/asahi/compiler/agx_register_allocate.c b/src/asahi/compiler/agx_register_allocate.c index 4ac3db81f61..a2fbc07065d 100644 --- a/src/asahi/compiler/agx_register_allocate.c +++ b/src/asahi/compiler/agx_register_allocate.c @@ -226,6 +226,20 @@ pick_regs(struct ra_ctx *rctx, agx_instr *I, unsigned d) if (!BITSET_TEST_RANGE(rctx->used_regs, our_reg, our_reg + align - 1)) return our_reg; } + + /* Try to respect the alignment requirement of the collect destination, + * which may be greater than the sources (e.g. pack_64_2x32_split). Look + * for a register for the source such that the collect base is aligned. + */ + unsigned collect_align = agx_size_align_16(collect->dest[0].size); + if (collect_align > align) { + unsigned offset = our_source * align; + + for (unsigned reg = offset; reg < rctx->bound; reg += collect_align) { + if (!BITSET_TEST_RANGE(rctx->used_regs, reg, reg + count - 1)) + return reg; + } + } } /* Default to any contiguous sequence of registers */