@@ -4618,51 +4618,31 @@ static int isElementRotate(int &LoSrc, int &HiSrc, ArrayRef<int> Mask) {
46184618// VT is the type of the vector to return, <[vscale x ]n x ty>
46194619// Src is the vector to deinterleave of type <[vscale x ]n*2 x ty>
46204620static SDValue getDeinterleaveViaVNSRL(const SDLoc &DL, MVT VT, SDValue Src,
4621- bool EvenElts,
4622- const RISCVSubtarget &Subtarget,
4623- SelectionDAG &DAG) {
4624- // The result is a vector of type <m x n x ty>
4625- MVT ContainerVT = VT;
4626- // Convert fixed vectors to scalable if needed
4627- if (ContainerVT.isFixedLengthVector()) {
4628- assert(Src.getSimpleValueType().isFixedLengthVector());
4629- ContainerVT = getContainerForFixedLengthVector(DAG, ContainerVT, Subtarget);
4630-
4631- // The source is a vector of type <m x n*2 x ty> (For the single source
4632- // case, the high half is undefined)
4633- MVT SrcContainerVT =
4634- MVT::getVectorVT(ContainerVT.getVectorElementType(),
4635- ContainerVT.getVectorElementCount() * 2);
4636- Src = convertToScalableVector(SrcContainerVT, Src, DAG, Subtarget);
4621+ bool EvenElts, SelectionDAG &DAG) {
4622+ // The result is a vector of type <m x n x ty>. The source is a vector of
4623+ // type <m x n*2 x ty> (For the single source case, the high half is undef)
4624+ if (Src.getValueType() == VT) {
4625+ EVT WideVT = VT.getDoubleNumVectorElementsVT();
4626+ Src = DAG.getNode(ISD::INSERT_SUBVECTOR, DL, WideVT, DAG.getUNDEF(WideVT),
4627+ Src, DAG.getVectorIdxConstant(0, DL));
46374628 }
46384629
4639- auto [TrueMask, VL] = getDefaultVLOps(VT, ContainerVT, DL, DAG, Subtarget);
4640-
46414630 // Bitcast the source vector from <m x n*2 x ty> -> <m x n x ty*2>
46424631 // This also converts FP to int.
4643- unsigned EltBits = ContainerVT .getScalarSizeInBits();
4644- MVT WideSrcContainerVT = MVT::getVectorVT(
4645- MVT::getIntegerVT(EltBits * 2), ContainerVT .getVectorElementCount());
4646- Src = DAG.getBitcast(WideSrcContainerVT , Src);
4632+ unsigned EltBits = VT .getScalarSizeInBits();
4633+ MVT WideSrcVT = MVT::getVectorVT(MVT::getIntegerVT(EltBits * 2),
4634+ VT .getVectorElementCount());
4635+ Src = DAG.getBitcast(WideSrcVT , Src);
46474636
4648- // The integer version of the container type.
4649- MVT IntContainerVT = ContainerVT.changeVectorElementTypeToInteger();
4637+ MVT IntVT = VT.changeVectorElementTypeToInteger();
46504638
46514639 // If we want even elements, then the shift amount is 0. Otherwise, shift by
46524640 // the original element size.
46534641 unsigned Shift = EvenElts ? 0 : EltBits;
4654- SDValue SplatShift = DAG.getNode(
4655- RISCVISD::VMV_V_X_VL, DL, IntContainerVT, DAG.getUNDEF(ContainerVT),
4656- DAG.getConstant(Shift, DL, Subtarget.getXLenVT()), VL);
4657- SDValue Res =
4658- DAG.getNode(RISCVISD::VNSRL_VL, DL, IntContainerVT, Src, SplatShift,
4659- DAG.getUNDEF(IntContainerVT), TrueMask, VL);
4660- // Cast back to FP if needed.
4661- Res = DAG.getBitcast(ContainerVT, Res);
4662-
4663- if (VT.isFixedLengthVector())
4664- Res = convertFromScalableVector(VT, Res, DAG, Subtarget);
4665- return Res;
4642+ SDValue Res = DAG.getNode(ISD::SRL, DL, WideSrcVT, Src,
4643+ DAG.getConstant(Shift, DL, WideSrcVT));
4644+ Res = DAG.getNode(ISD::TRUNCATE, DL, IntVT, Res);
4645+ return DAG.getBitcast(VT, Res);
46664646}
46674647
46684648// Lower the following shuffle to vslidedown.
@@ -5356,7 +5336,7 @@ static SDValue lowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG,
53565336 // vnsrl to deinterleave.
53575337 if (SDValue Src =
53585338 isDeinterleaveShuffle(VT, ContainerVT, V1, V2, Mask, Subtarget))
5359- return getDeinterleaveViaVNSRL(DL, VT, Src, Mask[0] == 0, Subtarget, DAG);
5339+ return getDeinterleaveViaVNSRL(DL, VT, Src, Mask[0] == 0, DAG);
53605340
53615341 if (SDValue V =
53625342 lowerVECTOR_SHUFFLEAsVSlideup(DL, VT, V1, V2, Mask, Subtarget, DAG))
@@ -6258,7 +6238,7 @@ static bool hasPassthruOp(unsigned Opcode) {
62586238 Opcode <= RISCVISD::LAST_RISCV_STRICTFP_OPCODE &&
62596239 "not a RISC-V target specific op");
62606240 static_assert(RISCVISD::LAST_VL_VECTOR_OP - RISCVISD::FIRST_VL_VECTOR_OP ==
6261- 128 &&
6241+ 127 &&
62626242 RISCVISD::LAST_RISCV_STRICTFP_OPCODE -
62636243 ISD::FIRST_TARGET_STRICTFP_OPCODE ==
62646244 21 &&
@@ -6284,7 +6264,7 @@ static bool hasMaskOp(unsigned Opcode) {
62846264 Opcode <= RISCVISD::LAST_RISCV_STRICTFP_OPCODE &&
62856265 "not a RISC-V target specific op");
62866266 static_assert(RISCVISD::LAST_VL_VECTOR_OP - RISCVISD::FIRST_VL_VECTOR_OP ==
6287- 128 &&
6267+ 127 &&
62886268 RISCVISD::LAST_RISCV_STRICTFP_OPCODE -
62896269 ISD::FIRST_TARGET_STRICTFP_OPCODE ==
62906270 21 &&
@@ -10763,10 +10743,8 @@ SDValue RISCVTargetLowering::lowerVECTOR_DEINTERLEAVE(SDValue Op,
1076310743 // We can deinterleave through vnsrl.wi if the element type is smaller than
1076410744 // ELEN
1076510745 if (VecVT.getScalarSizeInBits() < Subtarget.getELen()) {
10766- SDValue Even =
10767- getDeinterleaveViaVNSRL(DL, VecVT, Concat, true, Subtarget, DAG);
10768- SDValue Odd =
10769- getDeinterleaveViaVNSRL(DL, VecVT, Concat, false, Subtarget, DAG);
10746+ SDValue Even = getDeinterleaveViaVNSRL(DL, VecVT, Concat, true, DAG);
10747+ SDValue Odd = getDeinterleaveViaVNSRL(DL, VecVT, Concat, false, DAG);
1077010748 return DAG.getMergeValues({Even, Odd}, DL);
1077110749 }
1077210750
@@ -20494,7 +20472,6 @@ const char *RISCVTargetLowering::getTargetNodeName(unsigned Opcode) const {
2049420472 NODE_NAME_CASE(VWMACC_VL)
2049520473 NODE_NAME_CASE(VWMACCU_VL)
2049620474 NODE_NAME_CASE(VWMACCSU_VL)
20497- NODE_NAME_CASE(VNSRL_VL)
2049820475 NODE_NAME_CASE(SETCC_VL)
2049920476 NODE_NAME_CASE(VMERGE_VL)
2050020477 NODE_NAME_CASE(VMAND_VL)
0 commit comments