[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


================
@@ -998,15 +1133,57 @@ AMDGPUPromoteAllocaImpl::getVectorTypeForAlloca(Type *AllocaTy) const {
 }
 
 void AMDGPUPromoteAllocaImpl::analyzePromoteToVector(AllocaAnalysis &AA) const {
-  if (AA.HaveSelectOrPHI) {
-    LLVM_DEBUG(dbgs() << "  Cannot convert to vector due to select or phi\n");
+  // A phi/select that merges with null or a non-alloca object can't be given a
+  // vector lane, so the whole group is unpromotable to vector.
+  if (AA.HaveUnpromotableMerge) {
+    LLVM_DEBUG(dbgs() << "  Cannot convert to vector due to merge with "
+                         "null/unknown object\n");
+    return;
+  }
+
+  if (DisablePromoteAllocaToVector) {
+    LLVM_DEBUG(dbgs() << "  Promote alloca to vectors is disabled\n");
     return;
   }
----------------
yoonseoch wrote:

This is not the part of the main change of this PR. But if it is to be changed, checking it before bailing out on `AA.HaveUnpromotableMerger` makes more sense, possibly before calling this function, `analyzePromoteToVector`

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


More information about the llvm-commits mailing list