Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / math-errno.c
blobb5354e47e26b77388af0619d134ebd06b498231f
1 // -O2
2 // RUN: %clang_cc1 -Wno-implicit-function-declaration \
3 // RUN: -triple x86_64-unknown-unknown -fmath-errno -ffp-contract=on \
4 // RUN: -fno-rounding-math -O2 -emit-llvm -o - %s \
5 // RUN: | FileCheck %s
7 // -ffast-math
8 // RUN: %clang_cc1 -Wno-implicit-function-declaration \
9 // RUN: -triple x86_64-unknown-unknown -menable-no-infs -menable-no-nans \
10 // RUN: -fapprox-func -funsafe-math-optimizations -fno-signed-zeros -mreassociate \
11 // RUN: -freciprocal-math -ffp-contract=fast -fno-rounding-math -ffast-math \
12 // RUN: -ffinite-math-only -ffast-math -emit-llvm -o - %s \
13 // RUN: | FileCheck %s -check-prefix=FAST
15 // -O0
16 // RUN: %clang_cc1 -Wno-implicit-function-declaration \
17 // RUN: -triple x86_64-unknown-unknown -fmath-errno -ffp-contract=on \
18 // RUN: -fno-rounding-math -O0 \
19 // RUN: -emit-llvm -o - %s | FileCheck %s -check-prefix=NOOPT
21 #pragma float_control(precise,on)
22 float f1(float x) {
23 return sqrtf(x);
26 // CHECK-LABEL: define {{.*}} float @f1
27 // CHECK: tail call float @sqrtf(float noundef {{.*}}) #[[ATTR4_O2:[0-9]+]]
29 // FAST-LABEL: define {{.*}} nofpclass(nan inf) float @f1
30 // FAST: call fast nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR3_FAST:[0-9]+]]
32 // NOOPT-LABEL: define {{.*}} float @f1
33 // NOOPT: call float @sqrtf(float noundef {{.*}}) #[[ATTR4_NOOPT:[0-9]+]]
35 #pragma float_control(precise,off)
36 float f2(float x) {
37 return sqrtf(x);
40 // CHECK-LABEL: define {{.*}} float @f2
41 // CHECK: tail call fast float @llvm.sqrt.f32(float {{.*}})
43 // FAST-LABEL: define {{.*}} nofpclass(nan inf) float @f2
44 // FAST: call fast float @llvm.sqrt.f32(float {{.*}})
46 // NOOPT-LABEL: define {{.*}} float @f2
47 // NOOPT: call float @sqrtf(float {{.*}}) #[[ATTR4_NOOPT:[0-9]+]]
49 __attribute__((optnone))
50 float f3(float x) {
51 x = sqrtf(x);
52 return x;
55 // CHECK-LABEL: define {{.*}} float @f3
56 // CHECK: call float @sqrtf(float noundef {{.*}})
58 // FAST-LABEL: define {{.*}} nofpclass(nan inf) float @f3
59 // FAST: call fast nofpclass(nan inf) float @sqrtf(float noundef nofpclass(nan inf) {{.*}}) #[[ATTR4_FAST:[0-9]+]]
61 // NOOPT-LABEL: define {{.*}} float @f3
62 // NOOPT: call float @sqrtf(float noundef %0) #[[ATTR4_NOOPT:[0-9]+]]
64 // CHECK: [[ATTR4_O2]] = { nounwind }
65 // FAST: [[ATTR3_FAST]] = { nounwind willreturn memory(none) }
66 // NOOPT: [[ATTR4_NOOPT]] = { nounwind }