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

Yoonseo Choi via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 17:03:49 PDT 2026


================
@@ -1080,15 +1266,16 @@ void AMDGPUPromoteAllocaImpl::analyzePromoteToVector(AllocaAnalysis &AA) const {
                                 "not a multiple of the vector element size");
 
       auto getConstIndexIntoAlloca = [&](Value *Ptr) -> ConstantInt * {
-        if (Ptr == AA.Alloca)
+        if (Ptr == AA.getLeaderAlloca())
           return ConstantInt::get(Ptr->getContext(), APInt(32, 0));
 
-        GetElementPtrInst *GEP = cast<GetElementPtrInst>(Ptr);
-        const auto &GEPI = AA.Vector.GEPVectorIdx.find(GEP)->second;
-        if (GEPI.VarIndex)
+        auto Index = computeGEPToVectorIndex(cast<GetElementPtrInst>(Ptr), AA,
----------------
yoonseoch wrote:

llvm/test/CodeGen/AMDGPU/promote-alloca-vector-memcpy-phi-select.ll in https://github.com/llvm/llvm-project/pull/226353 crashes here. 
(memcpy_phi_dest and memcpy_select_dest)

Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.

memcpy's dest was a phi of alloca not a direct GEP. 

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


More information about the llvm-commits mailing list