@@ -1505,7 +1505,8 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
1505
1505
VT, Custom);
1506
1506
1507
1507
setOperationAction({ISD::FTRUNC, ISD::FCEIL, ISD::FFLOOR, ISD::FROUND,
1508
- ISD::FROUNDEVEN, ISD::FRINT, ISD::FNEARBYINT},
1508
+ ISD::FROUNDEVEN, ISD::FRINT, ISD::LRINT,
1509
+ ISD::LLRINT, ISD::FNEARBYINT},
1509
1510
VT, Custom);
1510
1511
1511
1512
setCondCodeAction(VFPCCToExpand, VT, Expand);
@@ -3208,7 +3209,14 @@ static RISCVFPRndMode::RoundingMode matchRoundingOp(unsigned Opc) {
3208
3209
case ISD::VP_FROUND:
3209
3210
return RISCVFPRndMode::RMM;
3210
3211
case ISD::FRINT:
3212
+ case ISD::LRINT:
3213
+ case ISD::LLRINT:
3214
+ case ISD::STRICT_FRINT:
3215
+ case ISD::STRICT_LRINT:
3216
+ case ISD::STRICT_LLRINT:
3211
3217
case ISD::VP_FRINT:
3218
+ case ISD::VP_LRINT:
3219
+ case ISD::VP_LLRINT:
3212
3220
return RISCVFPRndMode::DYN;
3213
3221
}
3214
3222
@@ -3458,28 +3466,34 @@ lowerFTRUNC_FCEIL_FFLOOR_FROUND(SDValue Op, SelectionDAG &DAG,
3458
3466
// Expand vector LRINT and LLRINT by converting to the integer domain.
3459
3467
static SDValue lowerVectorXRINT(SDValue Op, SelectionDAG &DAG,
3460
3468
const RISCVSubtarget &Subtarget) {
3461
- MVT VT = Op.getSimpleValueType();
3462
- assert(VT.isVector() && "Unexpected type");
3463
-
3464
3469
SDLoc DL(Op);
3470
+ MVT DstVT = Op.getSimpleValueType();
3465
3471
SDValue Src = Op.getOperand(0);
3466
- MVT ContainerVT = VT;
3472
+ MVT SrcVT = Src.getSimpleValueType();
3473
+ assert(SrcVT.isVector() && DstVT.isVector() &&
3474
+ !(SrcVT.isFixedLengthVector() ^ DstVT.isFixedLengthVector()) &&
3475
+ "Unexpected type");
3467
3476
3468
- if (VT.isFixedLengthVector()) {
3469
- ContainerVT = getContainerForFixedLengthVector(DAG, VT, Subtarget);
3470
- Src = convertToScalableVector(ContainerVT, Src, DAG, Subtarget);
3477
+ MVT DstContainerVT = DstVT;
3478
+ MVT SrcContainerVT = SrcVT;
3479
+
3480
+ if (DstVT.isFixedLengthVector()) {
3481
+ DstContainerVT = getContainerForFixedLengthVector(DAG, DstVT, Subtarget);
3482
+ SrcContainerVT = getContainerForFixedLengthVector(DAG, SrcVT, Subtarget);
3483
+ Src = convertToScalableVector(SrcContainerVT, Src, DAG, Subtarget);
3471
3484
}
3472
3485
3473
- auto [Mask, VL] = getDefaultVLOps(VT, ContainerVT, DL, DAG, Subtarget);
3474
- SDValue Truncated = DAG.getNode(
3475
- RISCVISD::VFCVT_RM_X_F_VL, DL, ContainerVT, Src, Mask,
3476
- DAG.getTargetConstant(RISCVFPRndMode::DYN, DL, Subtarget.getXLenVT()),
3477
- VL);
3486
+ auto [Mask, VL] = getDefaultVLOps(SrcVT, SrcContainerVT, DL, DAG, Subtarget);
3487
+ SDValue Res =
3488
+ DAG.getNode(RISCVISD::VFCVT_RM_X_F_VL, DL, DstContainerVT, Src, Mask,
3489
+ DAG.getTargetConstant(matchRoundingOp(Op.getOpcode()), DL,
3490
+ Subtarget.getXLenVT()),
3491
+ VL);
3478
3492
3479
- if (!VT .isFixedLengthVector())
3480
- return Truncated ;
3493
+ if (!DstVT .isFixedLengthVector())
3494
+ return Res ;
3481
3495
3482
- return convertFromScalableVector(VT, Truncated , DAG, Subtarget);
3496
+ return convertFromScalableVector(DstVT, Res , DAG, Subtarget);
3483
3497
}
3484
3498
3485
3499
static SDValue
0 commit comments