@@ -3020,7 +3020,9 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
30203020 LangOptions::ComplexRangeKind Range = LangOptions::ComplexRangeKind::CX_None;
30213021 std::string ComplexRangeStr = " " ;
30223022 std::string GccRangeComplexOption = " " ;
3023- bool IsDeviceOffloading = JA.isDeviceOffloading (Action::OFK_SYCL);
3023+ bool IsFp32PrecDivSqrtAllowed = JA.isDeviceOffloading (Action::OFK_SYCL) &&
3024+ !JA.isDeviceOffloading (Action::OFK_Cuda) &&
3025+ !JA.isOffloading (Action::OFK_HIP);
30243026
30253027 // Lambda to set fast-math options. This is also used by -ffp-model=fast
30263028 auto applyFastMath = [&]() {
@@ -3050,7 +3052,7 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
30503052 : ComplexArithmeticStr (LangOptions::ComplexRangeKind::CX_Basic));
30513053 Range = LangOptions::ComplexRangeKind::CX_Basic;
30523054 SeenUnsafeMathModeOption = true ;
3053- if (IsDeviceOffloading ) {
3055+ if (IsFp32PrecDivSqrtAllowed ) {
30543056 // when fp-model=fast is used the default precision for division and
30553057 // sqrt is not precise.
30563058 NoOffloadFP32PrecDiv = true ;
@@ -3085,7 +3087,7 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
30853087 }
30863088
30873089 auto addSPIRVArgs = [&](StringRef SPIRVArg) {
3088- if (IsDeviceOffloading ) {
3090+ if (IsFp32PrecDivSqrtAllowed ) {
30893091 if (!FPAccuracy.empty ())
30903092 EmitAccuracyDiag (D, JA, FPAccuracy, SPIRVArg);
30913093 if (SPIRVArg == " -fno-offload-fp32-prec-div" )
@@ -3631,7 +3633,7 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
36313633 CmdArgs.push_back (" -fno-cx-limited-range" );
36323634 if (Args.hasArg (options::OPT_fno_cx_fortran_rules))
36333635 CmdArgs.push_back (" -fno-cx-fortran-rules" );
3634- if (IsDeviceOffloading ) {
3636+ if (IsFp32PrecDivSqrtAllowed ) {
36353637 if (NoOffloadFP32PrecDiv)
36363638 CmdArgs.push_back (" -fno-offload-fp32-prec-div" );
36373639 if (NoOffloadFP32PrecSqrt)
0 commit comments