[llvm] [SLP][REVEC] Fix insertelement legality checks (PR #146921)

Han-Kuan Chen via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 3 20:01:19 PDT 2025


HanKuanChen wrote:

REVEC should support PoisonValue.
```
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 0941bf61953f..7b422bc88686 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9060,6 +9060,10 @@ BoUpSLP::TreeEntry::EntryState BoUpSLP::getScalarsVectorizationState(
     // different vectors.
     ValueSet SourceVectors;
     for (Value *V : VL) {
+      if (isa<PoisonValue>(V)) {
+        SourceVectors.insert(PoisonValue::get(V->getType()));
+        continue;
+      }
       SourceVectors.insert(cast<Instruction>(V)->getOperand(0));
       assert(getElementIndex(V) != std::nullopt &&
              "Non-constant or undef index?");
```

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


More information about the llvm-commits mailing list