[llvm] [RISCV] Lower disjoint shuffle of shuffles to MERGE-GATHER sequence (PR #178095)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 3 19:54:35 PST 2026
================
@@ -5966,10 +6068,6 @@ static bool isCompressMask(ArrayRef<int> Mask) {
static SDValue lowerDisjointIndicesShuffle(ShuffleVectorSDNode *SVN,
SelectionDAG &DAG,
const RISCVSubtarget &Subtarget) {
- MVT VT = SVN->getSimpleValueType(0);
- MVT XLenVT = Subtarget.getXLenVT();
- SDLoc DL(SVN);
-
const ArrayRef<int> Mask = SVN->getMask();
----------------
lukel97 wrote:
I haven't looked into this too closely but is it possible to share the detection part of the code too?
I was thinking we would just have the one `lowerDisjointIndicesShuffle`, and extend it to look through the nested shuffles themselves. Something like:
```
v1 = SVN->getOperand(0), v2 = SVN->getOperand(1)
Mask = SVN->getMask()
if (match(v1, m_shuffle(x, undef, othermask)) {
v1 = x
for (unsigned i = 0; i < mask.length; i++)
if (mask[i] < mask.length)
mask[i] = othermask[mask[i]]
}
if (match(v2, m_shuffle(x, undef, othermask)) {
v2 = x
for (unsigned i = mask.length; i < mask.length * 2; i++)
if (mask[i] >= mask.length)
mask[i] = othermask[mask[i]]
}
... do the rest of lowerDisjointIndicesShuffle as normal
```
But I could be missing something.
https://github.com/llvm/llvm-project/pull/178095
More information about the llvm-commits
mailing list