@@ -11186,17 +11186,19 @@ SDValue DAGCombiner::visitCTPOP(SDNode *N) {
11186
11186
return SDValue();
11187
11187
}
11188
11188
11189
- // FIXME: This should be checking for no signed zeros on individual operands, as
11190
- // well as no nans.
11191
11189
static bool isLegalToCombineMinNumMaxNum(SelectionDAG &DAG, SDValue LHS,
11192
- SDValue RHS,
11190
+ SDValue RHS, const SDNodeFlags Flags,
11193
11191
const TargetLowering &TLI) {
11194
- const TargetOptions &Options = DAG.getTarget().Options;
11195
11192
EVT VT = LHS.getValueType();
11193
+ if (!VT.isFloatingPoint())
11194
+ return false;
11195
+
11196
+ const TargetOptions &Options = DAG.getTarget().Options;
11196
11197
11197
- return Options.NoSignedZerosFPMath && VT.isFloatingPoint( ) &&
11198
+ return (Flags.hasNoSignedZeros() || Options.NoSignedZerosFPMath ) &&
11198
11199
TLI.isProfitableToCombineMinNumMaxNum(VT) &&
11199
- DAG.isKnownNeverNaN(LHS) && DAG.isKnownNeverNaN(RHS);
11200
+ (Flags.hasNoNaNs() ||
11201
+ (DAG.isKnownNeverNaN(RHS) && DAG.isKnownNeverNaN(LHS)));
11200
11202
}
11201
11203
11202
11204
static SDValue combineMinNumMaxNumImpl(const SDLoc &DL, EVT VT, SDValue LHS,
@@ -11674,7 +11676,7 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) {
11674
11676
// select (fcmp gt x, y), x, y -> fmaxnum x, y
11675
11677
//
11676
11678
// This is OK if we don't care what happens if either operand is a NaN.
11677
- if (N0.hasOneUse() && isLegalToCombineMinNumMaxNum(DAG, N1, N2, TLI))
11679
+ if (N0.hasOneUse() && isLegalToCombineMinNumMaxNum(DAG, N1, N2, Flags, TLI))
11678
11680
if (SDValue FMinMax =
11679
11681
combineMinNumMaxNum(DL, VT, Cond0, Cond1, N1, N2, CC))
11680
11682
return FMinMax;
@@ -12267,7 +12269,8 @@ SDValue DAGCombiner::visitVSELECT(SDNode *N) {
12267
12269
// This is OK if we don't care about what happens if either operand is a
12268
12270
// NaN.
12269
12271
//
12270
- if (N0.hasOneUse() && isLegalToCombineMinNumMaxNum(DAG, LHS, RHS, TLI)) {
12272
+ if (N0.hasOneUse() &&
12273
+ isLegalToCombineMinNumMaxNum(DAG, LHS, RHS, N->getFlags(), TLI)) {
12271
12274
if (SDValue FMinMax = combineMinNumMaxNum(DL, VT, LHS, RHS, N1, N2, CC))
12272
12275
return FMinMax;
12273
12276
}
0 commit comments