Skip to content

Commit fefa968

Browse files
preamesarichardson
authored andcommitted
[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.
2 parents 8f530c2 + a0f69be commit fefa968

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
@@ -4930,6 +4930,19 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
49304930
return DAG.getNode(ISD::VSELECT, DL, VT, SelectMask, V1, V2);
49314931
}
49324932

4933+
// We might be able to express the shuffle as a bitrotate. But even if we
4934+
// don't have Zvkb and have to expand, the expanded sequence of approx. 2
4935+
// shifts and a vor will have a higher throughput than a vrgather.
4936+
if (SDValue V = lowerVECTOR_SHUFFLEAsRotate(SVN, DAG, Subtarget))
4937+
return V;
4938+
4939+
if (VT.getScalarSizeInBits() == 8 && VT.getVectorNumElements() > 256) {
4940+
// On such a large vector we're unable to use i8 as the index type.
4941+
// FIXME: We could promote the index to i16 and use vrgatherei16, but that
4942+
// may involve vector splitting if we're already at LMUL=8, or our
4943+
// user-supplied maximum fixed-length LMUL.
4944+
return SDValue();
4945+
}
49334946

49344947
// As a backup, shuffles can be lowered via a vrgather instruction, possibly
49354948
// merged with a second vrgather.
@@ -4968,20 +4981,6 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
49684981
MVT MaskVT = MVT::getVectorVT(MVT::i1, NumElts);
49694982
SDValue SelectMask = DAG.getBuildVector(MaskVT, DL, MaskVals);
49704983

4971-
// We might be able to express the shuffle as a bitrotate. But even if we
4972-
// don't have Zvkb and have to expand, the expanded sequence of approx. 2
4973-
// shifts and a vor will have a higher throughput than a vrgather.
4974-
if (SDValue V = lowerVECTOR_SHUFFLEAsRotate(SVN, DAG, Subtarget))
4975-
return V;
4976-
4977-
if (VT.getScalarSizeInBits() == 8 && VT.getVectorNumElements() > 256) {
4978-
// On such a large vector we're unable to use i8 as the index type.
4979-
// FIXME: We could promote the index to i16 and use vrgatherei16, but that
4980-
// may involve vector splitting if we're already at LMUL=8, or our
4981-
// user-supplied maximum fixed-length LMUL.
4982-
return SDValue();
4983-
}
4984-
49854984
unsigned GatherVXOpc = RISCVISD::VRGATHER_VX_VL;
49864985
unsigned GatherVVOpc = RISCVISD::VRGATHER_VV_VL;
49874986
MVT IndexVT = VT.changeTypeToInteger();

0 commit comments

Comments
 (0)