@@ -924,7 +924,7 @@ CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple,
924924 const ToolChain &HostTC, const ArgList &Args,
925925 const Action::OffloadKind OK)
926926 : NVPTXToolChain(D, Triple, HostTC.getTriple(), Args), HostTC(HostTC),
927- OK(OK) {}
927+ SYCLInstallation(D), OK(OK) {}
928928
929929void CudaToolChain::addClangTargetOptions (
930930 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
@@ -941,11 +941,19 @@ void CudaToolChain::addClangTargetOptions(
941941 // If we are compiling SYCL kernels for Nvidia GPUs, we do not support Cuda
942942 // device code compatability, hence we do not set Cuda mode in that instance.
943943 if (DeviceOffloadingKind == Action::OFK_SYCL) {
944- toolchains::SYCLToolChain::AddSYCLIncludeArgs (getDriver (), DriverArgs,
945- CC1Args);
944+ SYCLInstallation.AddSYCLIncludeArgs (DriverArgs, CC1Args);
946945
947946 if (DriverArgs.hasArg (options::OPT_fsycl_fp32_prec_sqrt))
948947 CC1Args.push_back (" -fcuda-prec-sqrt" );
948+
949+ bool FastRelaxedMath = DriverArgs.hasFlag (
950+ options::OPT_ffast_math, options::OPT_fno_fast_math, false );
951+ bool UnsafeMathOpt =
952+ DriverArgs.hasFlag (options::OPT_funsafe_math_optimizations,
953+ options::OPT_fno_unsafe_math_optimizations, false );
954+ if (FastRelaxedMath || UnsafeMathOpt)
955+ CC1Args.append ({" -mllvm" , " --nvptx-prec-divf32=0" , " -mllvm" ,
956+ " --nvptx-prec-sqrtf32=0" });
949957 } else {
950958 CC1Args.append (
951959 {" -fcuda-is-device" , " -mllvm" , " -enable-memcpyopt-without-libcalls" });
@@ -1196,8 +1204,7 @@ CudaToolChain::GetCXXStdlibType(const ArgList &Args) const {
11961204void CudaToolChain::AddClangSystemIncludeArgs (const ArgList &DriverArgs,
11971205 ArgStringList &CC1Args) const {
11981206 if (DriverArgs.hasArg (options::OPT_fsycl)) {
1199- toolchains::SYCLToolChain::AddSYCLIncludeArgs (getDriver (), DriverArgs,
1200- CC1Args);
1207+ SYCLInstallation.AddSYCLIncludeArgs (DriverArgs, CC1Args);
12011208 }
12021209 HostTC.AddClangSystemIncludeArgs (DriverArgs, CC1Args);
12031210
0 commit comments