[llvm] [AMDGPU] Promote allocas used by phi/select (PR #221870)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 02:21:01 PDT 2026


================
@@ -376,28 +448,87 @@ bool AMDGPUPromoteAllocaImpl::run(Function &F, bool PromoteToLDS) {
       VGPRBudgetRatio;
 
   std::vector<AllocaAnalysis> Allocas;
-  for (Instruction &I : F.getEntryBlock()) {
-    if (AllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
+  {
+    // Collect uses for every candidate alloca independently. This also
+    // records phi/select links between distinct allocas (see collectAllocaUses).
+    std::vector<AllocaAnalysis> Raw;
+    DenseMap<AllocaInst *, int> Index; // -> position in Raw, or -1 if rejected.
----------------
ruiling wrote:

This is the most tricky part of the change. I have tried to simplify the code. Since the order matters during analyzing the links, I am using a mapvector here.

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


More information about the llvm-commits mailing list