[llvm] [SLP] Fix crash of shuffle poison (PR #106857)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 31 10:53:40 PDT 2024
alexey-bataev wrote:
Imean, something like this:
```
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index b7bcfba7f86d..993fd6ab1b0b 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11204,6 +11204,10 @@ BoUpSLP::tryToGatherSingleRegisterExtractElements(
UndefVectorExtracts.push_back(I);
continue;
}
+ if (Idx >= VecTy->getNumElements()) {
+ UndefVectorExtracts.push_back(I);
+ continue;
+ }
SmallBitVector ExtractMask(VecTy->getNumElements(), true);
ExtractMask.reset(*Idx);
if (isUndefVector(EI->getVectorOperand(), ExtractMask).all()) {
@@ -11251,7 +11255,7 @@ BoUpSLP::tryToGatherSingleRegisterExtractElements(
// shuffle of a single/two vectors the scalars are extracted from.
std::optional<TTI::ShuffleKind> Res =
isFixedVectorShuffle(GatheredExtracts, Mask);
- if (!Res) {
+ if (!Res || all_of(Mask, [](int Idx) { return Idx == PoisonMaskElem; })) {
// TODO: try to check other subsets if possible.
// Restore the original VL if attempt was not successful.
copy(SavedVL, VL.begin());
```
https://github.com/llvm/llvm-project/pull/106857
More information about the llvm-commits
mailing list