@@ -7199,7 +7199,7 @@ SDValue SITargetLowering::lowerFP_ROUND(SDValue Op, SelectionDAG &DAG) const {
71997199 SDValue Trunc = DAG.getNode(ISD::TRUNCATE, DL, MVT::i16, FpToFp16);
72007200 return DAG.getNode(ISD::BITCAST, DL, MVT::f16, Trunc);
72017201 }
7202- if (getTargetMachine ().Options.UnsafeFPMath ) {
7202+ if (Op->getFlags ().hasApproximateFuncs() ) {
72037203 SDValue Flags = Op.getOperand(1);
72047204 SDValue Src32 = DAG.getNode(ISD::FP_ROUND, DL, MVT::f32, Src, Flags);
72057205 return DAG.getNode(ISD::FP_ROUND, DL, MVT::f16, Src32, Flags);
@@ -11294,8 +11294,7 @@ SDValue SITargetLowering::lowerFastUnsafeFDIV(SDValue Op,
1129411294 EVT VT = Op.getValueType();
1129511295 const SDNodeFlags Flags = Op->getFlags();
1129611296
11297- bool AllowInaccurateRcp =
11298- Flags.hasApproximateFuncs() || DAG.getTarget().Options.UnsafeFPMath;
11297+ bool AllowInaccurateRcp = Flags.hasApproximateFuncs();
1129911298
1130011299 if (const ConstantFPSDNode *CLHS = dyn_cast<ConstantFPSDNode>(LHS)) {
1130111300 // Without !fpmath accuracy information, we can't do more because we don't
@@ -11314,7 +11313,7 @@ SDValue SITargetLowering::lowerFastUnsafeFDIV(SDValue Op,
1131411313
1131511314 // 1.0 / sqrt(x) -> rsq(x)
1131611315
11317- // XXX - Is UnsafeFPMath sufficient to do this for f64? The maximum ULP
11316+ // XXX - Is afn sufficient to do this for f64? The maximum ULP
1131811317 // error seems really high at 2^29 ULP.
1131911318 // 1.0 / x -> rcp(x)
1132011319 return DAG.getNode(AMDGPUISD::RCP, SL, VT, RHS);
@@ -11348,8 +11347,7 @@ SDValue SITargetLowering::lowerFastUnsafeFDIV64(SDValue Op,
1134811347 EVT VT = Op.getValueType();
1134911348 const SDNodeFlags Flags = Op->getFlags();
1135011349
11351- bool AllowInaccurateDiv =
11352- Flags.hasApproximateFuncs() || DAG.getTarget().Options.UnsafeFPMath;
11350+ bool AllowInaccurateDiv = Flags.hasApproximateFuncs();
1135311351 if (!AllowInaccurateDiv)
1135411352 return SDValue();
1135511353
@@ -14601,7 +14599,7 @@ unsigned SITargetLowering::getFusedOpcode(const SelectionDAG &DAG,
1460114599 return ISD::FMAD;
1460214600
1460314601 const TargetOptions &Options = DAG.getTarget().Options;
14604- if ((Options.AllowFPOpFusion == FPOpFusion::Fast || Options.UnsafeFPMath ||
14602+ if ((Options.AllowFPOpFusion == FPOpFusion::Fast ||
1460514603 (N0->getFlags().hasAllowContract() &&
1460614604 N1->getFlags().hasAllowContract())) &&
1460714605 isFMAFasterThanFMulAndFAdd(DAG.getMachineFunction(), VT)) {
@@ -15724,9 +15722,9 @@ SDValue SITargetLowering::performFMACombine(SDNode *N,
1572415722
1572515723 // fdot2_f32_f16 always flushes fp32 denormal operand and output to zero,
1572615724 // regardless of the denorm mode setting. Therefore,
15727- // unsafe-fp-math/ fp-contract is sufficient to allow generating fdot2.
15725+ // fp-contract is sufficient to allow generating fdot2.
1572815726 const TargetOptions &Options = DAG.getTarget().Options;
15729- if (Options.AllowFPOpFusion == FPOpFusion::Fast || Options.UnsafeFPMath ||
15727+ if (Options.AllowFPOpFusion == FPOpFusion::Fast ||
1573015728 (N->getFlags().hasAllowContract() &&
1573115729 FMA->getFlags().hasAllowContract())) {
1573215730 Op1 = Op1.getOperand(0);
0 commit comments