[llvm] Limit Alloca->LDS promotion based on speculations as to eventual register pressure (PR #152814)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 05:40:51 PDT 2025


arsenm wrote:

> * Perhaps the real problem for the user is that SROA is not promoting the alloca() to virtual registers, and SROA should therefore be examined to see if it's missing an opportunity for the user's testcase.

Yes, that's always preferable. No stack is better than LDS is better than stack, which is usually the single worst thing you can use. At some point you need a large junk of addressable memory, the stack is just the worst case.

> * Perhaps some optimization is able to eliminate unnecessary loads from and stores to the stack,

Those are the fundamentals of optimization

> because the stack is known to be thread-local (it is, right?), but that optimization is unaware of our LDS intrinsics, 

Ordinary LDS usage is just regular load/store with addrspace(3). There aren't special LDS intrinsics for these cases. In this example we're just swapping out the memory access type, which should be treated equivalently well by downstream optimizations 




https://github.com/llvm/llvm-project/pull/152814


More information about the llvm-commits mailing list