Skip to content

Commit fc10ad1

Browse files
authored
[RISCV] Make single source reverse legal in isShuffleMaskLegal (#125949)
This enables DAG combines to form this mask. Reverse is generally linear in LMUL so this is reasonable, and results in better codegen for the 2 source variants. For <= m1, the change is only slightly profitable if at all. We trade some mask creation and an extract vrsub for a vslideup.vi. This is likely roughly neutral. At >= m2, this is distinctly profitable as generic DAG pushes the reverse into the two operands. We effectively already did this for one operand, but the other was hitting a full O(LMUL^2) shuffle. Moving that to be O(LMUL/2) operation is a big win.
1 parent e1c63bb commit fc10ad1

File tree

2 files changed

+139
-240
lines changed

2 files changed

+139
-240
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5815,14 +5815,16 @@ bool RISCVTargetLowering::isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const {
58155815
if (ShuffleVectorSDNode::isSplatMask(M.data(), VT))
58165816
return true;
58175817

5818+
const unsigned NumElts = M.size();
58185819
MVT SVT = VT.getSimpleVT();
58195820

58205821
// Not for i1 vectors.
58215822
if (SVT.getScalarType() == MVT::i1)
58225823
return false;
58235824

58245825
int Dummy1, Dummy2;
5825-
return (isElementRotate(Dummy1, Dummy2, M) > 0) ||
5826+
return ShuffleVectorInst::isReverseMask(M, NumElts) ||
5827+
(isElementRotate(Dummy1, Dummy2, M) > 0) ||
58265828
isInterleaveShuffle(M, SVT, Dummy1, Dummy2, Subtarget);
58275829
}
58285830

0 commit comments

Comments
 (0)