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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 7 23:40:40 PDT 2026


================
@@ -464,17 +598,56 @@ static bool isSupportedMemset(MemSetInst *I, AllocaInst *AI,
 }
 
 static Value *calculateVectorIndex(Value *Ptr, AllocaAnalysis &AA) {
-  IRBuilder<> B(Ptr->getContext());
-
+  LLVMContext &Ctx = Ptr->getContext();
   Ptr = Ptr->stripPointerCasts();
-  if (Ptr == AA.Alloca)
-    return B.getInt32(0);
+
+  // Already computed (also breaks cycles for pointer phis).
+  auto Cached = AA.Vector.IndexCache.find(Ptr);
+  if (Cached != AA.Vector.IndexCache.end())
+    return Cached->second;
+
+  const auto BaseLaneConst = [&](AllocaInst *Member) -> Value * {
----------------
arsenm wrote:

Too trivial for lambda 

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


More information about the llvm-commits mailing list