[llvm] [SLP][REVEC] The vectorized result for ShuffleVector may not be ShuffleVectorInst. (PR #116940)
Han-Kuan Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 06:52:09 PST 2024
================
@@ -15713,16 +15713,19 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
LLVM_DEBUG(dbgs() << "SLP: Diamond merged for " << *VL0 << ".\n");
return E->VectorizedValue;
}
- assert(isa<ShuffleVectorInst>(Src) &&
- "Not supported shufflevector usage.");
- auto *SVSrc = cast<ShuffleVectorInst>(Src);
- assert(isa<PoisonValue>(SVSrc->getOperand(1)) &&
- "Not supported shufflevector usage.");
SmallVector<int> ThisMask(calculateShufflevectorMask(E->Scalars));
- SmallVector<int> NewMask(ThisMask.size());
- transform(ThisMask, NewMask.begin(),
- [&SVSrc](int Mask) { return SVSrc->getShuffleMask()[Mask]; });
- V = Builder.CreateShuffleVector(SVSrc->getOperand(0), NewMask);
+ if (isa<ShuffleVectorInst>(Src)) {
+ auto *SVSrc = cast<ShuffleVectorInst>(Src);
+ assert(isa<PoisonValue>(SVSrc->getOperand(1)) &&
+ "Not supported shufflevector usage.");
+ SmallVector<int> NewMask(ThisMask.size());
+ transform(ThisMask, NewMask.begin(), [&SVSrc](int Mask) {
+ return SVSrc->getShuffleMask()[Mask];
+ });
+ V = Builder.CreateShuffleVector(SVSrc->getOperand(0), NewMask);
----------------
HanKuanChen wrote:
No. `SVSrc` has its own mask. But the current shufflevector has its own mask (from `calculateShufflevectorMask(E->Scalars)`) too. We are trying to blend the mask from `calculateShufflevectorMask` and `SVSrc`.
https://github.com/llvm/llvm-project/pull/116940
More information about the llvm-commits
mailing list