[llvm] [IA] Recognize repeated masks which come from shuffle vectors (PR #150285)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 24 18:58:24 PDT 2025
================
@@ -587,6 +587,26 @@ static Value *getMask(Value *WideMask, unsigned Factor,
}
}
+ if (auto *SVI = dyn_cast<ShuffleVectorInst>(WideMask)) {
+ // Check that the shuffle mask is: a) an interleave, b) all of the same
+ // set of the elements, and c) contained by the first source. (c) could
+ // be relaxed if desired.
+ unsigned NumSrcElts =
+ cast<FixedVectorType>(SVI->getOperand(1)->getType())->getNumElements();
+ SmallVector<unsigned> StartIndexes;
+ if (ShuffleVectorInst::isInterleaveMask(SVI->getShuffleMask(), Factor,
+ NumSrcElts * 2, StartIndexes) &&
+ llvm::all_of(StartIndexes, [](unsigned Start) { return Start == 0; }) &&
+ llvm::all_of(SVI->getShuffleMask(),
+ [&](int Idx) { return Idx < (int)NumSrcElts; })) {
----------------
lukel97 wrote:
```suggestion
[&NumSrcElts](int Idx) { return Idx < (int)NumSrcElts; })) {
```
https://github.com/llvm/llvm-project/pull/150285
More information about the llvm-commits
mailing list