@@ -880,6 +880,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
880880 {ISD::VP_LOAD, ISD::VP_STORE, ISD::EXPERIMENTAL_VP_STRIDED_LOAD,
881881 ISD::EXPERIMENTAL_VP_STRIDED_STORE, ISD::VP_GATHER, ISD::VP_SCATTER},
882882 VT, Custom);
883+ setOperationAction(ISD::VP_LOAD_FF, VT, Custom);
883884
884885 setOperationAction({ISD::CONCAT_VECTORS, ISD::INSERT_SUBVECTOR,
885886 ISD::EXTRACT_SUBVECTOR, ISD::SCALAR_TO_VECTOR},
@@ -1031,6 +1032,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
10311032 {ISD::VP_LOAD, ISD::VP_STORE, ISD::EXPERIMENTAL_VP_STRIDED_LOAD,
10321033 ISD::EXPERIMENTAL_VP_STRIDED_STORE, ISD::VP_GATHER, ISD::VP_SCATTER},
10331034 VT, Custom);
1035+ setOperationAction(ISD::VP_LOAD_FF, VT, Custom);
10341036
10351037 setOperationAction(ISD::SELECT, VT, Custom);
10361038 setOperationAction(ISD::SELECT_CC, VT, Expand);
@@ -1101,6 +1103,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
11011103 ISD::EXPERIMENTAL_VP_STRIDED_STORE, ISD::VP_GATHER,
11021104 ISD::VP_SCATTER},
11031105 VT, Custom);
1106+ setOperationAction(ISD::VP_LOAD_FF, VT, Custom);
11041107
11051108 setOperationAction(ISD::FNEG, VT, Expand);
11061109 setOperationAction(ISD::FABS, VT, Expand);
@@ -1269,6 +1272,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
12691272 ISD::EXPERIMENTAL_VP_STRIDED_STORE, ISD::VP_GATHER,
12701273 ISD::VP_SCATTER},
12711274 VT, Custom);
1275+ setOperationAction(ISD::VP_LOAD_FF, VT, Custom);
12721276
12731277 setOperationAction({ISD::ADD, ISD::MUL, ISD::SUB, ISD::AND, ISD::OR,
12741278 ISD::XOR, ISD::SDIV, ISD::SREM, ISD::UDIV,
@@ -1357,6 +1361,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
13571361 ISD::VP_SCATTER, ISD::EXPERIMENTAL_VP_STRIDED_LOAD,
13581362 ISD::EXPERIMENTAL_VP_STRIDED_STORE},
13591363 VT, Custom);
1364+ setOperationAction(ISD::VP_LOAD_FF, VT, Custom);
13601365
13611366 setOperationAction({ISD::FP_ROUND, ISD::FP_EXTEND}, VT, Custom);
13621367 setOperationAction({ISD::STRICT_FP_ROUND, ISD::STRICT_FP_EXTEND}, VT,
@@ -7616,6 +7621,8 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
76167621 case ISD::MLOAD:
76177622 case ISD::VP_LOAD:
76187623 return lowerMaskedLoad(Op, DAG);
7624+ case ISD::VP_LOAD_FF:
7625+ return lowerLoadFF(Op, DAG);
76197626 case ISD::MSTORE:
76207627 case ISD::VP_STORE:
76217628 return lowerMaskedStore(Op, DAG);
@@ -11965,6 +11972,57 @@ SDValue RISCVTargetLowering::lowerMaskedLoad(SDValue Op,
1196511972 return DAG.getMergeValues({Result, Chain}, DL);
1196611973}
1196711974
11975+ SDValue RISCVTargetLowering::lowerLoadFF(SDValue Op, SelectionDAG &DAG) const {
11976+ assert(Op.getResNo() == 0);
11977+ SDLoc DL(Op);
11978+ MVT VT = Op.getSimpleValueType();
11979+
11980+ const auto *VPLoadFF = cast<VPLoadFFSDNode>(Op);
11981+ EVT MemVT = VPLoadFF->getMemoryVT();
11982+ MachineMemOperand *MMO = VPLoadFF->getMemOperand();
11983+ SDValue Chain = VPLoadFF->getChain();
11984+ SDValue BasePtr = VPLoadFF->getBasePtr();
11985+
11986+ SDValue Mask = VPLoadFF->getMask();
11987+ SDValue VL = VPLoadFF->getVectorLength();
11988+
11989+ bool IsUnmasked = ISD::isConstantSplatVectorAllOnes(Mask.getNode());
11990+
11991+ MVT XLenVT = Subtarget.getXLenVT();
11992+
11993+ MVT ContainerVT = VT;
11994+ if (VT.isFixedLengthVector()) {
11995+ ContainerVT = getContainerForFixedLengthVector(VT);
11996+ if (!IsUnmasked) {
11997+ MVT MaskVT = getMaskTypeFor(ContainerVT);
11998+ Mask = convertToScalableVector(MaskVT, Mask, DAG, Subtarget);
11999+ }
12000+ }
12001+
12002+ unsigned IntID =
12003+ IsUnmasked ? Intrinsic::riscv_vleff : Intrinsic::riscv_vleff_mask;
12004+ SmallVector<SDValue, 8> Ops{Chain, DAG.getTargetConstant(IntID, DL, XLenVT)};
12005+ Ops.push_back(DAG.getUNDEF(ContainerVT));
12006+ Ops.push_back(BasePtr);
12007+ if (!IsUnmasked)
12008+ Ops.push_back(Mask);
12009+ Ops.push_back(VL);
12010+ if (!IsUnmasked)
12011+ Ops.push_back(DAG.getTargetConstant(RISCVVType::TAIL_AGNOSTIC, DL, XLenVT));
12012+
12013+ SDVTList VTs = DAG.getVTList({ContainerVT, Op->getValueType(1), MVT::Other});
12014+
12015+ SDValue Result =
12016+ DAG.getMemIntrinsicNode(ISD::INTRINSIC_W_CHAIN, DL, VTs, Ops, MemVT, MMO);
12017+ SDValue OutVL = Result.getValue(1);
12018+ Chain = Result.getValue(2);
12019+
12020+ if (VT.isFixedLengthVector())
12021+ Result = convertFromScalableVector(VT, Result, DAG, Subtarget);
12022+
12023+ return DAG.getMergeValues({Result, OutVL, Chain}, DL);
12024+ }
12025+
1196812026SDValue RISCVTargetLowering::lowerMaskedStore(SDValue Op,
1196912027 SelectionDAG &DAG) const {
1197012028 SDLoc DL(Op);
0 commit comments