@@ -4875,6 +4875,19 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
4875
4875
return DAG.getNode(ISD::VSELECT, DL, VT, SelectMask, V1, V2);
4876
4876
}
4877
4877
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
+ }
4878
4891
4879
4892
// As a backup, shuffles can be lowered via a vrgather instruction, possibly
4880
4893
// merged with a second vrgather.
@@ -4913,20 +4926,6 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
4913
4926
MVT MaskVT = MVT::getVectorVT(MVT::i1, NumElts);
4914
4927
SDValue SelectMask = DAG.getBuildVector(MaskVT, DL, MaskVals);
4915
4928
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
-
4930
4929
unsigned GatherVXOpc = RISCVISD::VRGATHER_VX_VL;
4931
4930
unsigned GatherVVOpc = RISCVISD::VRGATHER_VV_VL;
4932
4931
MVT IndexVT = VT.changeTypeToInteger();
0 commit comments