Skip to content

Commit 5883ad3

Browse files
authored
DAG: Handle vector legalization of minimumnum/maximumnum (llvm#109779)
Follow the same patterns as the other min/max variants.
1 parent d556e38 commit 5883ad3

File tree

5 files changed

+2539
-1
lines changed

5 files changed

+2539
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4537,6 +4537,8 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
45374537
case ISD::VP_FMINIMUM:
45384538
case ISD::FMAXIMUM:
45394539
case ISD::VP_FMAXIMUM:
4540+
case ISD::FMINIMUMNUM:
4541+
case ISD::FMAXIMUMNUM:
45404542
case ISD::SMIN: case ISD::VP_SMIN:
45414543
case ISD::SMAX: case ISD::VP_SMAX:
45424544
case ISD::UMIN: case ISD::VP_UMIN:

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8606,6 +8606,9 @@ SDValue TargetLowering::expandFMINIMUMNUM_FMAXIMUMNUM(SDNode *Node,
86068606
return DAG.getNode(IEEE2008Op, DL, VT, LHS, RHS, Flags);
86078607
}
86088608

8609+
if (VT.isVector() && !isOperationLegalOrCustom(ISD::VSELECT, VT))
8610+
return DAG.UnrollVectorOp(Node);
8611+
86098612
// If only one operand is NaN, override it with another operand.
86108613
if (!Flags.hasNoNaNs() && !DAG.isKnownNeverNaN(LHS)) {
86118614
LHS = DAG.getSelectCC(DL, LHS, LHS, RHS, LHS, ISD::SETUO);

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,8 @@ SITargetLowering::SITargetLowering(const TargetMachine &TM,
753753
setOperationAction({ISD::FMAXNUM, ISD::FMINNUM}, MVT::f16, Custom);
754754
setOperationAction({ISD::FMAXNUM_IEEE, ISD::FMINNUM_IEEE}, MVT::f16, Legal);
755755

756-
setOperationAction({ISD::FMINNUM_IEEE, ISD::FMAXNUM_IEEE},
756+
setOperationAction({ISD::FMINNUM_IEEE, ISD::FMAXNUM_IEEE, ISD::FMINIMUMNUM,
757+
ISD::FMAXIMUMNUM},
757758
{MVT::v4f16, MVT::v8f16, MVT::v16f16, MVT::v32f16},
758759
Custom);
759760

@@ -5842,6 +5843,8 @@ SDValue SITargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
58425843
case ISD::FMAXNUM_IEEE:
58435844
case ISD::FMINIMUM:
58445845
case ISD::FMAXIMUM:
5846+
case ISD::FMINIMUMNUM:
5847+
case ISD::FMAXIMUMNUM:
58455848
case ISD::UADDSAT:
58465849
case ISD::USUBSAT:
58475850
case ISD::SADDSAT:

0 commit comments

Comments
 (0)