1 // RUN: %clang_cc1 -triple x86_64-linux-gnu -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s
2
test_default(float a,float b,float c)3 float test_default(float a, float b, float c) {
4 float tmp = a;
5 tmp += b;
6 tmp += c;
7 return tmp;
8 }
9
10 // CHECK: define{{.*}} float @_Z12test_defaultfff(float noundef %a, float noundef %b, float noundef %c) [[FAST_ATTRS:#[0-9]+]]
11 // CHECK: fadd fast float {{%.+}}, {{%.+}}
12 // CHECK: fadd fast float {{%.+}}, {{%.+}}
13
test_precise_on_pragma(float a,float b,float c)14 float test_precise_on_pragma(float a, float b, float c) {
15 float tmp = a;
16 {
17 #pragma float_control(precise, on)
18 tmp += b;
19 }
20 tmp += c;
21 return tmp;
22 }
23
24 // CHECK: define{{.*}} float @_Z22test_precise_on_pragmafff(float noundef %a, float noundef %b, float noundef %c) [[PRECISE_ATTRS:#[0-9]+]]
25 // CHECK: fadd float {{%.+}}, {{%.+}}
26 // CHECK: fadd fast float {{%.+}}, {{%.+}}
27
test_reassociate_off_pragma(float a,float b,float c)28 float test_reassociate_off_pragma(float a, float b, float c) {
29 float tmp = a;
30 {
31 #pragma clang fp reassociate(off)
32 tmp += b;
33 }
34 tmp += c;
35 return tmp;
36 }
37
38 // CHECK: define{{.*}} float @_Z27test_reassociate_off_pragmafff(float noundef %a, float noundef %b, float noundef %c) [[NOREASSOC_ATTRS:#[0-9]+]]
39 // CHECK: fadd nnan ninf nsz arcp contract afn float {{%.+}}, {{%.+}}
40 // CHECK: fadd fast float {{%.+}}, {{%.+}}
41
42 // CHECK: attributes [[FAST_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="true"{{.*}} }
43 // CHECK: attributes [[PRECISE_ATTRS]] = { {{.*}}"no-infs-fp-math"="false" {{.*}}"no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" {{.*}}"unsafe-fp-math"="false"{{.*}} }
44 // CHECK: attributes [[NOREASSOC_ATTRS]] = { {{.*}}"no-infs-fp-math"="true" {{.*}}"no-nans-fp-math"="true" "no-signed-zeros-fp-math"="true" {{.*}}"unsafe-fp-math"="false"{{.*}} }
45