File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -511,6 +511,19 @@ static void addImpliedArgs(const llvm::Triple &Triple,
511
511
BeArgs.push_back (" -g" );
512
512
if (Args.getLastArg (options::OPT_O0))
513
513
BeArgs.push_back (" -cl-opt-disable" );
514
+ // Check if floating pointing optimizations are allowed.
515
+ bool isFastMath = isOptimizationLevelFast (Args);
516
+ Arg *A = Args.getLastArg (options::OPT_ffast_math, options::OPT_fno_fast_math,
517
+ options::OPT_funsafe_math_optimizations,
518
+ options::OPT_fno_unsafe_math_optimizations);
519
+ isFastMath =
520
+ isFastMath || (A && (A->getOption ().getID () == options::OPT_ffast_math ||
521
+ A->getOption ().getID () ==
522
+ options::OPT_funsafe_math_optimizations));
523
+ A = Args.getLastArg (options::OPT_ffp_model_EQ);
524
+ isFastMath = isFastMath || (A && StringRef (A->getValue ()).equals (" fast" ));
525
+ if (isFastMath)
526
+ BeArgs.push_back (" -cl-fast-relaxed-math" );
514
527
if (BeArgs.empty ())
515
528
return ;
516
529
if (Triple.getSubArch () == llvm::Triple::NoSubArch ||
Original file line number Diff line number Diff line change 904
904
// CHECK-STD-OVR: clang{{.*}} "-emit-obj" {{.*}} "-std=c++14"
905
905
// CHECK-STD-OVR-NOT: clang{{.*}} "-std=c++17"
906
906
907
+ // Bypass -cl-fast-relaxed-math to SPIR-V compiler.
908
+ // RUN: %clang -### -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -ffast-math %s 2>&1 | FileCheck -check-prefix=CHECK-FAST-MATH-OPT %s
909
+ // RUN: %clang -### -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -funsafe-math-optimizations %s 2>&1 | FileCheck -check-prefix=CHECK-FAST-MATH-OPT %s
910
+ // RUN: %clang -### -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -Ofast %s 2>&1 | FileCheck -check-prefix=CHECK-FAST-MATH-OPT %s
911
+ // RUN: %clang -### -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -ffp-model=fast %s 2>&1 | FileCheck -check-prefix=CHECK-FAST-MATH-OPT %s
912
+ // RUN: %clang_cl -### -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice /fp:fast %s 2>&1 | FileCheck -check-prefix=CHECK-FAST-MATH-OPT %s
913
+ // CHECK-FAST-MATH-OPT: clang-offload-wrapper{{.*}} "-compile-opts=-cl-fast-relaxed-math"
914
+
907
915
// TODO: SYCL specific fail - analyze and enable
908
916
// XFAIL: windows-msvc
You can’t perform that action at this time.
0 commit comments