Skip to content

Commit 11ff25e

Browse files
committed
RISC-V: Support vectorizing FMINIMUMNUM and FMAXIMUMNUM
RISC-V V extension support vfmax and vfmin, which follow IEEE754-2019. We can use them directly.
1 parent 5e834b9 commit 11ff25e

File tree

3 files changed

+854
-208
lines changed

3 files changed

+854
-208
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,8 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
969969
static const unsigned ZvfhminZvfbfminPromoteOps[] = {
970970
ISD::FMINNUM,
971971
ISD::FMAXNUM,
972+
ISD::FMINIMUMNUM,
973+
ISD::FMAXIMUMNUM,
972974
ISD::FADD,
973975
ISD::FSUB,
974976
ISD::FMUL,
@@ -1037,7 +1039,9 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
10371039
// Expand various condition codes (explained above).
10381040
setCondCodeAction(VFPCCToExpand, VT, Expand);
10391041

1040-
setOperationAction({ISD::FMINNUM, ISD::FMAXNUM}, VT, Legal);
1042+
setOperationAction(
1043+
{ISD::FMINNUM, ISD::FMAXNUM, ISD::FMAXIMUMNUM, ISD::FMINIMUMNUM}, VT,
1044+
Legal);
10411045
setOperationAction({ISD::FMAXIMUM, ISD::FMINIMUM}, VT, Custom);
10421046

10431047
setOperationAction({ISD::FTRUNC, ISD::FCEIL, ISD::FFLOOR, ISD::FROUND,
@@ -1455,7 +1459,8 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
14551459
setOperationAction({ISD::FADD, ISD::FSUB, ISD::FMUL, ISD::FDIV,
14561460
ISD::FNEG, ISD::FABS, ISD::FCOPYSIGN, ISD::FSQRT,
14571461
ISD::FMA, ISD::FMINNUM, ISD::FMAXNUM,
1458-
ISD::IS_FPCLASS, ISD::FMAXIMUM, ISD::FMINIMUM},
1462+
ISD::FMINIMUMNUM, ISD::FMAXIMUMNUM, ISD::IS_FPCLASS,
1463+
ISD::FMAXIMUM, ISD::FMINIMUM},
14591464
VT, Custom);
14601465

14611466
setOperationAction({ISD::FTRUNC, ISD::FCEIL, ISD::FFLOOR, ISD::FROUND,
@@ -6913,9 +6918,11 @@ static unsigned getRISCVVLOp(SDValue Op) {
69136918
case ISD::VP_FP_TO_UINT:
69146919
return RISCVISD::VFCVT_RTZ_XU_F_VL;
69156920
case ISD::FMINNUM:
6921+
case ISD::FMINIMUMNUM:
69166922
case ISD::VP_FMINNUM:
69176923
return RISCVISD::VFMIN_VL;
69186924
case ISD::FMAXNUM:
6925+
case ISD::FMAXIMUMNUM:
69196926
case ISD::VP_FMAXNUM:
69206927
return RISCVISD::VFMAX_VL;
69216928
case ISD::LRINT:
@@ -7951,6 +7958,8 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
79517958
case ISD::FMA:
79527959
case ISD::FMINNUM:
79537960
case ISD::FMAXNUM:
7961+
case ISD::FMINIMUMNUM:
7962+
case ISD::FMAXIMUMNUM:
79547963
if (isPromotedOpNeedingSplit(Op, Subtarget))
79557964
return SplitVectorOp(Op, DAG);
79567965
[[fallthrough]];

0 commit comments

Comments
 (0)