[llvm] [SROA] Allow canonicalizing homogeneous array allocas to vectors (PR #216456)
Yonah Goldberg via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 20:56:48 PDT 2026
YonahGoldberg wrote:
So unfortunately after looking into this a little more, even if we restrict the allocas to power of 2 size and even if we make the limit 16-bytes, we still get regressions in llvm-opt-benchmark. 12 improvements and 13 regressions. The problem is that X86 will always legalize the `i128` to 64-bit halves in two different registers. It's still an improvement if 2 registers exist, but about half the time they don't and we have to spill to the stack. We spill into two slots with two loads/stores, whereas memcpy will use XMM and 1 load/store. The reason why we have high register pressure so frequently is because you often have a function call in between the two memcpys and that increases pressure a lot. So IDK if we can do this for >=16-bytes unless we add a register pressure heuristic or X86 and Aarch64 legalize better in these cases.
The good news is that the Julia bug is actually a a 64-bit alloca difference (`[2 x i32]` vs `[2 x float]`) and I think we can load this as `i64` no problem, so I can get a fix in for that. But there's potentially a lot of improvements on the table to get with a register pressure heuristic or better CodeGen. Adding a register pressure heuristic to SROA might not be viable though.
https://github.com/llvm/llvm-project/pull/216456
More information about the llvm-commits
mailing list