@@ -16820,7 +16820,7 @@ ConstantFoldBITCASTofBUILD_VECTOR(SDNode *BV, EVT DstEltVT) {
16820
16820
static bool isContractableFMUL(const TargetOptions &Options, SDValue N) {
16821
16821
assert(N.getOpcode() == ISD::FMUL);
16822
16822
16823
- return Options.AllowFPOpFusion == FPOpFusion::Fast || Options.UnsafeFPMath ||
16823
+ return Options.AllowFPOpFusion == FPOpFusion::Fast ||
16824
16824
N->getFlags().hasAllowContract();
16825
16825
}
16826
16826
@@ -17093,8 +17093,8 @@ SDValue DAGCombiner::visitFSUBForFMACombine(SDNode *N) {
17093
17093
return SDValue();
17094
17094
17095
17095
const SDNodeFlags Flags = N->getFlags();
17096
- bool AllowFusionGlobally = (Options.AllowFPOpFusion == FPOpFusion::Fast ||
17097
- Options.UnsafeFPMath || HasFMAD);
17096
+ bool AllowFusionGlobally =
17097
+ ( Options.AllowFPOpFusion == FPOpFusion::Fast || HasFMAD);
17098
17098
17099
17099
// If the subtraction is not contractable, do not combine.
17100
17100
if (!AllowFusionGlobally && !N->getFlags().hasAllowContract())
@@ -17249,22 +17249,17 @@ SDValue DAGCombiner::visitFSUBForFMACombine(SDNode *N) {
17249
17249
}
17250
17250
}
17251
17251
17252
- auto isReassociable = [&Options](SDNode *N) {
17253
- return Options.UnsafeFPMath || N->getFlags().hasAllowReassociation();
17254
- };
17255
-
17256
- auto isContractableAndReassociableFMUL = [&isContractableFMUL,
17257
- &isReassociable](SDValue N) {
17258
- return isContractableFMUL(N) && isReassociable(N.getNode());
17252
+ auto isContractableAndReassociableFMUL = [&isContractableFMUL](SDValue N) {
17253
+ return isContractableFMUL(N) && N->getFlags().hasAllowReassociation();
17259
17254
};
17260
17255
17261
17256
auto isFusedOp = [&](SDValue N) {
17262
17257
return matcher.match(N, ISD::FMA) || matcher.match(N, ISD::FMAD);
17263
17258
};
17264
17259
17265
17260
// More folding opportunities when target permits.
17266
- if (Aggressive && isReassociable(N )) {
17267
- bool CanFuse = Options.UnsafeFPMath || N->getFlags().hasAllowContract();
17261
+ if (Aggressive && N->getFlags().hasAllowReassociation( )) {
17262
+ bool CanFuse = N->getFlags().hasAllowContract();
17268
17263
// fold (fsub (fma x, y, (fmul u, v)), z)
17269
17264
// -> (fma x, y (fma u, v, (fneg z)))
17270
17265
if (CanFuse && isFusedOp(N0) &&
@@ -17421,8 +17416,7 @@ SDValue DAGCombiner::visitFMULForFMADistributiveCombine(SDNode *N) {
17421
17416
17422
17417
// Floating-point multiply-add with intermediate rounding. This can result
17423
17418
// in a less precise result due to the changed rounding order.
17424
- bool HasFMAD = Options.UnsafeFPMath &&
17425
- (LegalOperations && TLI.isFMADLegal(DAG, N));
17419
+ bool HasFMAD = LegalOperations && TLI.isFMADLegal(DAG, N);
17426
17420
17427
17421
// No valid opcode, do not combine.
17428
17422
if (!HasFMAD && !HasFMA)
@@ -18321,8 +18315,7 @@ SDValue DAGCombiner::visitFDIV(SDNode *N) {
18321
18315
// Only do the transform if the reciprocal is a legal fp immediate that
18322
18316
// isn't too nasty (eg NaN, denormal, ...).
18323
18317
if (((st == APFloat::opOK && !Recip.isDenormal()) ||
18324
- (st == APFloat::opInexact &&
18325
- (Options.UnsafeFPMath || Flags.hasAllowReciprocal()))) &&
18318
+ (st == APFloat::opInexact && Flags.hasAllowReciprocal())) &&
18326
18319
(!LegalOperations ||
18327
18320
// FIXME: custom lowering of ConstantFP might fail (see e.g. ARM
18328
18321
// backend)... we should handle this gracefully after Legalize.
@@ -18333,7 +18326,7 @@ SDValue DAGCombiner::visitFDIV(SDNode *N) {
18333
18326
DAG.getConstantFP(Recip, DL, VT));
18334
18327
}
18335
18328
18336
- if (Options.UnsafeFPMath || Flags.hasAllowReciprocal()) {
18329
+ if (Flags.hasAllowReciprocal()) {
18337
18330
// If this FDIV is part of a reciprocal square root, it may be folded
18338
18331
// into a target-specific square root estimate instruction.
18339
18332
if (N1.getOpcode() == ISD::FSQRT) {
@@ -18408,7 +18401,7 @@ SDValue DAGCombiner::visitFDIV(SDNode *N) {
18408
18401
18409
18402
// Fold X/Sqrt(X) -> Sqrt(X)
18410
18403
if ((Options.NoSignedZerosFPMath || Flags.hasNoSignedZeros()) &&
18411
- (Options.UnsafeFPMath || Flags.hasAllowReassociation() ))
18404
+ Flags.hasAllowReassociation())
18412
18405
if (N1.getOpcode() == ISD::FSQRT && N0 == N1.getOperand(0))
18413
18406
return N1;
18414
18407
0 commit comments