Skip to content

Commit a0f69be

Browse files
committed
[RISCV] Continue with early return for shuffle lowering [nfc]
Move two cases where we're not actually going to use any of our computed index vectors or mask values above the computation of the same.
1 parent c5a33be commit a0f69be

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4875,6 +4875,19 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
48754875
return DAG.getNode(ISD::VSELECT, DL, VT, SelectMask, V1, V2);
48764876
}
48774877

4878+
// We might be able to express the shuffle as a bitrotate. But even if we
4879+
// don't have Zvkb and have to expand, the expanded sequence of approx. 2
4880+
// shifts and a vor will have a higher throughput than a vrgather.
4881+
if (SDValue V = lowerVECTOR_SHUFFLEAsRotate(SVN, DAG, Subtarget))
4882+
return V;
4883+
4884+
if (VT.getScalarSizeInBits() == 8 && VT.getVectorNumElements() > 256) {
4885+
// On such a large vector we're unable to use i8 as the index type.
4886+
// FIXME: We could promote the index to i16 and use vrgatherei16, but that
4887+
// may involve vector splitting if we're already at LMUL=8, or our
4888+
// user-supplied maximum fixed-length LMUL.
4889+
return SDValue();
4890+
}
48784891

48794892
// As a backup, shuffles can be lowered via a vrgather instruction, possibly
48804893
// merged with a second vrgather.
@@ -4913,20 +4926,6 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
49134926
MVT MaskVT = MVT::getVectorVT(MVT::i1, NumElts);
49144927
SDValue SelectMask = DAG.getBuildVector(MaskVT, DL, MaskVals);
49154928

4916-
// We might be able to express the shuffle as a bitrotate. But even if we
4917-
// don't have Zvkb and have to expand, the expanded sequence of approx. 2
4918-
// shifts and a vor will have a higher throughput than a vrgather.
4919-
if (SDValue V = lowerVECTOR_SHUFFLEAsRotate(SVN, DAG, Subtarget))
4920-
return V;
4921-
4922-
if (VT.getScalarSizeInBits() == 8 && VT.getVectorNumElements() > 256) {
4923-
// On such a large vector we're unable to use i8 as the index type.
4924-
// FIXME: We could promote the index to i16 and use vrgatherei16, but that
4925-
// may involve vector splitting if we're already at LMUL=8, or our
4926-
// user-supplied maximum fixed-length LMUL.
4927-
return SDValue();
4928-
}
4929-
49304929
unsigned GatherVXOpc = RISCVISD::VRGATHER_VX_VL;
49314930
unsigned GatherVVOpc = RISCVISD::VRGATHER_VV_VL;
49324931
MVT IndexVT = VT.changeTypeToInteger();

0 commit comments

Comments
 (0)