2 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -DFAST \
3 // RUN: -mreassociate \
4 // RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s
6 // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -DFAST \
7 // RUN: -mreassociate \
8 // RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s
10 // Test with fast math and fprotect-parens
11 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -DFAST \
12 // RUN: -mreassociate -fprotect-parens -ffp-contract=on\
13 // RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPP %s
15 // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -DFAST \
16 // RUN: -mreassociate -fprotect-parens -ffp-contract=on\
17 // RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPP %s
19 // Test without fast math: llvm intrinsic not created
20 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -fprotect-parens\
21 // RUN: -o - %s | FileCheck --implicit-check-not="llvm.arithmetic.fence" %s
23 // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -fprotect-parens\
24 // RUN: -o - %s | FileCheck --implicit-check-not="llvm.arithmetic.fence" %s
26 // Test with fast math on spir target
27 // RUN: %clang_cc1 -triple spir64 -emit-llvm -DFAST \
28 // RUN: -mreassociate -o - %s \
29 // RUN: | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s
33 int addit(float a
, float b
) {
34 // CHECK: define {{.*}}@addit(float noundef %a, float noundef %b) #0 {
35 _Complex
double cd
, cd1
;
36 cd
= __arithmetic_fence(cd1
);
37 // CHECKFAST: call{{.*}} double @llvm.arithmetic.fence.f64({{.*}}real)
38 // CHECKFAST: call{{.*}} double @llvm.arithmetic.fence.f64({{.*}}imag)
39 // Vector should be supported.
40 typedef float __v2f32
__attribute__((__vector_size__(8)));
42 vec1
= __arithmetic_fence(vec2
);
43 // CHECKFAST: call{{.*}} <2 x float> @llvm.arithmetic.fence.v2f32
45 // CHECKPP: call{{.*}} <2 x float> @llvm.arithmetic.fence.v2f32
47 v
= __arithmetic_fence(a
+ b
);
48 // CHECKFAST: call{{.*}} float @llvm.arithmetic.fence.f32(float %add{{.*}})
51 // CHECKPP: call{{.*}} float @llvm.arithmetic.fence.f32(float %add{{.*}})
53 // CHECKPP: fmul reassoc
54 // CHECKPP-NEXT: call{{.*}} float @llvm.arithmetic.fence.f32(float %mul)
58 // CHECKPP: call{{.*}} float @llvm.fmuladd.f32
61 v
= b
+ __arithmetic_fence(a
*a
); // Fence blocks recognition of FMA
68 // CHECK-NEXT store i32
69 // CHECK-NEXT load float
70 // CHECK-NEXT store float
71 // CHECK-NEXT load float
72 // CHECK-NEXT store float
74 // CHECK-NEXT ret i32 0
76 int addit1(int a
, int b
) {
77 // CHECK: define {{.*}}@addit1(i32 noundef %a, i32 noundef %b{{.*}}
79 // CHECK-NOT: call{{.*}} float @llvm.arithmetic.fence.int(float noundef %add)
83 #pragma float_control(precise, on)
84 int subit(float a
, float b
, float *fp
) {
85 // CHECKFAST: define {{.*}}@subit(float noundef %a, float noundef %b{{.*}}
86 *fp
= __arithmetic_fence(a
- b
);
88 // CHECK-NOT: call{{.*}} float @llvm.arithmetic.fence.f32(float noundef %add)