blob: 1f12392d861baac8770df2907aeefdc25d474275 [file] [log] [blame]
Pekka Jaaskelainen37014502014-12-10 16:41:14 +00001// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NORMAL
2// RUN: %clang_cc1 %s -emit-llvm -cl-fast-relaxed-math -o - | FileCheck %s -check-prefix=FAST
3// RUN: %clang_cc1 %s -emit-llvm -cl-finite-math-only -o - | FileCheck %s -check-prefix=FINITE
4// RUN: %clang_cc1 %s -emit-llvm -cl-unsafe-math-optimizations -o - | FileCheck %s -check-prefix=UNSAFE
Egor Churaev45c26ee2017-03-27 10:38:01 +00005// RUN: %clang_cc1 %s -emit-llvm -cl-mad-enable -o - | FileCheck %s -check-prefix=MAD
6// RUN: %clang_cc1 %s -emit-llvm -cl-no-signed-zeros -o - | FileCheck %s -check-prefix=NOSIGNED
Pekka Jaaskelainen37014502014-12-10 16:41:14 +00007
Melanie Blowerf4aaed32020-06-26 09:23:45 -07008// Check the fp options are correct with PCH.
9// RUN: %clang_cc1 %s -DGEN_PCH=1 -finclude-default-header -triple spir-unknown-unknown -emit-pch -o %t.pch
10// RUN: %clang_cc1 %s -include-pch %t.pch -fno-validate-pch -emit-llvm -o - | FileCheck %s -check-prefix=NORMAL
11// RUN: %clang_cc1 %s -include-pch %t.pch -fno-validate-pch -emit-llvm -cl-fast-relaxed-math -o - | FileCheck %s -check-prefix=FAST
12// RUN: %clang_cc1 %s -include-pch %t.pch -fno-validate-pch -emit-llvm -cl-finite-math-only -o - | FileCheck %s -check-prefix=FINITE
13// RUN: %clang_cc1 %s -include-pch %t.pch -fno-validate-pch -emit-llvm -cl-unsafe-math-optimizations -o - | FileCheck %s -check-prefix=UNSAFE
14// RUN: %clang_cc1 %s -include-pch %t.pch -fno-validate-pch -emit-llvm -cl-mad-enable -o - | FileCheck %s -check-prefix=MAD
15// RUN: %clang_cc1 %s -include-pch %t.pch -fno-validate-pch -emit-llvm -cl-no-signed-zeros -o - | FileCheck %s -check-prefix=NOSIGNED
16
17#if !GEN_PCH
18
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000019float spscalardiv(float a, float b) {
20 // CHECK: @spscalardiv(
21
Melanie Blower827be692020-05-15 07:30:49 -070022 // NORMAL: fdiv float
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000023 // FAST: fdiv fast float
Melanie Blower827be692020-05-15 07:30:49 -070024 // FINITE: fdiv nnan ninf float
John McCall8a8d7032020-06-01 21:02:02 -040025 // UNSAFE: fdiv reassoc nsz arcp afn float
Melanie Blower827be692020-05-15 07:30:49 -070026 // MAD: fdiv float
27 // NOSIGNED: fdiv nsz float
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000028 return a / b;
29}
30// CHECK: attributes
31
Egor Churaev45c26ee2017-03-27 10:38:01 +000032// NORMAL: "less-precise-fpmad"="false"
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000033// NORMAL: "no-infs-fp-math"="false"
34// NORMAL: "no-nans-fp-math"="false"
Egor Churaev45c26ee2017-03-27 10:38:01 +000035// NORMAL: "no-signed-zeros-fp-math"="false"
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000036// NORMAL: "unsafe-fp-math"="false"
37
Egor Churaev45c26ee2017-03-27 10:38:01 +000038// FAST: "less-precise-fpmad"="true"
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000039// FAST: "no-infs-fp-math"="true"
40// FAST: "no-nans-fp-math"="true"
Egor Churaev45c26ee2017-03-27 10:38:01 +000041// FAST: "no-signed-zeros-fp-math"="true"
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000042// FAST: "unsafe-fp-math"="true"
43
Egor Churaev45c26ee2017-03-27 10:38:01 +000044// FINITE: "less-precise-fpmad"="false"
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000045// FINITE: "no-infs-fp-math"="true"
46// FINITE: "no-nans-fp-math"="true"
Egor Churaev45c26ee2017-03-27 10:38:01 +000047// FINITE: "no-signed-zeros-fp-math"="false"
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000048// FINITE: "unsafe-fp-math"="false"
49
Egor Churaev45c26ee2017-03-27 10:38:01 +000050// UNSAFE: "less-precise-fpmad"="true"
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000051// UNSAFE: "no-infs-fp-math"="false"
John McCall8a8d7032020-06-01 21:02:02 -040052// UNSAFE: "no-nans-fp-math"="false"
Egor Churaev45c26ee2017-03-27 10:38:01 +000053// UNSAFE: "no-signed-zeros-fp-math"="true"
Pekka Jaaskelainen37014502014-12-10 16:41:14 +000054// UNSAFE: "unsafe-fp-math"="true"
55
Egor Churaev45c26ee2017-03-27 10:38:01 +000056// MAD: "less-precise-fpmad"="true"
57// MAD: "no-infs-fp-math"="false"
58// MAD: "no-nans-fp-math"="false"
59// MAD: "no-signed-zeros-fp-math"="false"
60// MAD: "unsafe-fp-math"="false"
61
62// NOSIGNED: "less-precise-fpmad"="false"
63// NOSIGNED: "no-infs-fp-math"="false"
64// NOSIGNED: "no-nans-fp-math"="false"
65// NOSIGNED: "no-signed-zeros-fp-math"="true"
66// NOSIGNED: "unsafe-fp-math"="false"
Melanie Blowerf4aaed32020-06-26 09:23:45 -070067
68#else
69// Undefine this to avoid putting it in the PCH.
70#undef GEN_PCH
71#endif