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 */