diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 6f3d86b900edf..f85584b3335e4 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7223,6 +7223,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } } + if (IsHIPDevice) + Args.addOptOutFlag(CmdArgs, + options::OPT_fhip_fp32_correctly_rounded_divide_sqrt, + options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt); + // OpenMP offloading device jobs take the argument -fopenmp-host-ir-file-path // to specify the result of the compile phase on the host, so the meaningful // device declarations can be identified. Also, -fopenmp-is-device is passed diff --git a/clang/test/Driver/hip-options.hip b/clang/test/Driver/hip-options.hip index 7a6965caf5e00..edbe4ff3acbed 100644 --- a/clang/test/Driver/hip-options.hip +++ b/clang/test/Driver/hip-options.hip @@ -154,3 +154,18 @@ // RUN: %clang -### -nogpuinc -nogpulib -mamdgpu-ieee -mno-amdgpu-ieee -ffast-math \ // RUN: --cuda-gpu-arch=gfx906 %s 2>&1 | FileCheck -check-prefixes=IEEE-OFF-NEG %s // IEEE-OFF-NEG-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-mamdgpu-ieee" + +// Check -fno-hip-fp32-correctly-rounded-divide-sqrt is passed to -cc1 but +// (default) -fhip-fp32-correctly-rounded-divide-sqrt is not. + +// RUN: %clang -### -nogpuinc -nogpulib -fno-hip-fp32-correctly-rounded-divide-sqrt \ +// RUN: --cuda-gpu-arch=gfx906 %s 2>&1 | FileCheck -check-prefixes=NOCRDS %s +// NOCRDS: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} "-fno-hip-fp32-correctly-rounded-divide-sqrt" + +// RUN: %clang -### -nogpuinc -nogpulib \ +// RUN: --cuda-gpu-arch=gfx906 %s 2>&1 | FileCheck -check-prefixes=CRDS %s +// CRDS-NOT: "-f{{(no-)?}}hip-fp32-correctly-rounded-divide-sqrt" + +// RUN: %clang -### -nogpuinc -nogpulib -fhip-fp32-correctly-rounded-divide-sqrt \ +// RUN: --cuda-gpu-arch=gfx906 %s 2>&1 | FileCheck -check-prefixes=CRDS %s +// CRDS-NOT: "-f{{(no-)?}}hip-fp32-correctly-rounded-divide-sqrt"