@@ -943,8 +943,9 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
943943 Expand);
944944 setOperationAction(ISD::VP_MERGE, VT, Custom);
945945
946- setOperationAction({ISD::VP_CTTZ_ELTS, ISD::VP_CTTZ_ELTS_ZERO_UNDEF}, VT,
947- Custom);
946+ setOperationAction({ISD::CTTZ_ELTS, ISD::CTTZ_ELTS_ZERO_POISON,
947+ ISD::VP_CTTZ_ELTS, ISD::VP_CTTZ_ELTS_ZERO_UNDEF},
948+ VT, Custom);
948949
949950 setOperationAction({ISD::VP_AND, ISD::VP_OR, ISD::VP_XOR}, VT, Custom);
950951
@@ -1567,6 +1568,9 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
15671568
15681569 setOperationAction(ISD::EXPERIMENTAL_VP_SPLICE, VT, Custom);
15691570 setOperationAction(ISD::EXPERIMENTAL_VP_REVERSE, VT, Custom);
1571+
1572+ setOperationAction({ISD::CTTZ_ELTS, ISD::CTTZ_ELTS_ZERO_POISON}, VT,
1573+ Custom);
15701574 continue;
15711575 }
15721576
@@ -7874,6 +7878,9 @@ RISCVTargetLowering::lowerXAndesBfHCvtBFloat16Store(SDValue Op,
78747878 ST->getMemOperand());
78757879}
78767880
7881+ static SDValue lowerCttzElts(SDValue Op, SelectionDAG &DAG,
7882+ const RISCVSubtarget &Subtarget);
7883+
78777884SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
78787885 SelectionDAG &DAG) const {
78797886 switch (Op.getOpcode()) {
@@ -9183,6 +9190,9 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
91839190 case ISD::PARTIAL_REDUCE_SMLA:
91849191 case ISD::PARTIAL_REDUCE_SUMLA:
91859192 return lowerPARTIAL_REDUCE_MLA(Op, DAG);
9193+ case ISD::CTTZ_ELTS:
9194+ case ISD::CTTZ_ELTS_ZERO_POISON:
9195+ return lowerCttzElts(Op, DAG, Subtarget);
91869196 }
91879197}
91889198
@@ -11518,20 +11528,20 @@ static SDValue lowerGetVectorLength(SDNode *N, SelectionDAG &DAG,
1151811528 return DAG.getNode(ISD::TRUNCATE, DL, N->getValueType(0), Res);
1151911529}
1152011530
11521- static SDValue lowerCttzElts(SDNode *N , SelectionDAG &DAG,
11531+ static SDValue lowerCttzElts(SDValue Op , SelectionDAG &DAG,
1152211532 const RISCVSubtarget &Subtarget) {
11523- SDValue Op0 = N-> getOperand(1 );
11533+ SDValue Op0 = Op. getOperand(0 );
1152411534 MVT OpVT = Op0.getSimpleValueType();
1152511535 MVT ContainerVT = OpVT;
1152611536 if (OpVT.isFixedLengthVector()) {
1152711537 ContainerVT = getContainerForFixedLengthVector(DAG, OpVT, Subtarget);
1152811538 Op0 = convertToScalableVector(ContainerVT, Op0, DAG, Subtarget);
1152911539 }
1153011540 MVT XLenVT = Subtarget.getXLenVT();
11531- SDLoc DL(N );
11541+ SDLoc DL(Op );
1153211542 auto [Mask, VL] = getDefaultVLOps(OpVT, ContainerVT, DL, DAG, Subtarget);
1153311543 SDValue Res = DAG.getNode(RISCVISD::VFIRST_VL, DL, XLenVT, Op0, Mask, VL);
11534- if (isOneConstant(N->getOperand(2)) )
11544+ if (Op.getOpcode() == ISD::CTTZ_ELTS_ZERO_POISON )
1153511545 return Res;
1153611546
1153711547 // Convert -1 to VL.
@@ -11686,8 +11696,6 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
1168611696 }
1168711697 case Intrinsic::experimental_get_vector_length:
1168811698 return lowerGetVectorLength(Op.getNode(), DAG, Subtarget);
11689- case Intrinsic::experimental_cttz_elts:
11690- return lowerCttzElts(Op.getNode(), DAG, Subtarget);
1169111699 case Intrinsic::riscv_vmv_x_s: {
1169211700 SDValue Res = DAG.getNode(RISCVISD::VMV_X_S, DL, XLenVT, Op.getOperand(1));
1169311701 return DAG.getNode(ISD::TRUNCATE, DL, Op.getValueType(), Res);
@@ -15888,11 +15896,6 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
1588815896 Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, Res));
1588915897 return;
1589015898 }
15891- case Intrinsic::experimental_cttz_elts: {
15892- SDValue Res = lowerCttzElts(N, DAG, Subtarget);
15893- Results.push_back(DAG.getZExtOrTrunc(Res, DL, N->getValueType(0)));
15894- return;
15895- }
1589615899 case Intrinsic::riscv_orc_b:
1589715900 case Intrinsic::riscv_brev8:
1589815901 case Intrinsic::riscv_sha256sig0:
0 commit comments