Skip to content

Commit ea1f05e

Browse files
committed
[SelectionDAG] Fix lowering of IEEE 754 2019 minimum/maximum
We used integer comparisons instead of floating point comparisons resulting in very odd behavior.
1 parent 2a6136e commit ea1f05e

File tree

2 files changed

+1103
-3
lines changed

2 files changed

+1103
-3
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8517,7 +8517,7 @@ SDValue TargetLowering::expandFMINIMUM_FMAXIMUM(SDNode *N,
85178517

85188518
// NaN (if exists) will be propagated later, so orderness doesn't matter.
85198519
SDValue Compare =
8520-
DAG.getSetCC(DL, CCVT, LHS, RHS, IsMax ? ISD::SETGT : ISD::SETLT);
8520+
DAG.getSetCC(DL, CCVT, LHS, RHS, IsMax ? ISD::SETOGT : ISD::SETOLT);
85218521
MinMax = DAG.getSelect(DL, VT, Compare, LHS, RHS, Flags);
85228522
}
85238523

@@ -8534,7 +8534,7 @@ SDValue TargetLowering::expandFMINIMUM_FMAXIMUM(SDNode *N,
85348534
if (!MinMaxMustRespectOrderedZero && !N->getFlags().hasNoSignedZeros() &&
85358535
!DAG.isKnownNeverZeroFloat(RHS) && !DAG.isKnownNeverZeroFloat(LHS)) {
85368536
SDValue IsZero = DAG.getSetCC(DL, CCVT, MinMax,
8537-
DAG.getConstantFP(0.0, DL, VT), ISD::SETEQ);
8537+
DAG.getConstantFP(0.0, DL, VT), ISD::SETOEQ);
85388538
SDValue TestZero =
85398539
DAG.getTargetConstant(IsMax ? fcPosZero : fcNegZero, DL, MVT::i32);
85408540
SDValue LCmp = DAG.getSelect(
@@ -8823,7 +8823,7 @@ SDValue TargetLowering::expandIS_FPCLASS(EVT ResultVT, SDValue Op,
88238823
// Split the value into sign bit and absolute value.
88248824
SDValue AbsV = DAG.getNode(ISD::AND, DL, IntVT, OpAsInt, ValueMaskV);
88258825
SDValue SignV = DAG.getSetCC(DL, ResultVT, OpAsInt,
8826-
DAG.getConstant(0.0, DL, IntVT), ISD::SETLT);
8826+
DAG.getConstant(0, DL, IntVT), ISD::SETLT);
88278827

88288828
// Tests that involve more than one class should be processed first.
88298829
SDValue PartialRes;

0 commit comments

Comments
 (0)