brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · 5339b20 Raw
92 lines · c
1// Test with fast math2// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -DFAST \3// RUN: -mreassociate \4// RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s5//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 %s9//10// Test with fast math and fprotect-parens11// 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 %s14//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 %s18//19// Test without fast math: llvm intrinsic not created20// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -fprotect-parens\21// RUN: -o - %s | FileCheck --implicit-check-not="llvm.arithmetic.fence" %s22//23// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -fprotect-parens\24// RUN: -o - %s | FileCheck --implicit-check-not="llvm.arithmetic.fence" %s25//26// Test with fast math on spir target27// RUN: %clang_cc1 -triple spir64  -emit-llvm -DFAST \28// RUN: -mreassociate -o - %s \29// RUN: | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s30//31 32int v;33int 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)));41  __v2f32 vec1, vec2;42  vec1 = __arithmetic_fence(vec2);43  // CHECKFAST: call{{.*}} <2 x float> @llvm.arithmetic.fence.v2f3244  vec2 = (vec2 + vec1);45  // CHECKPP: call{{.*}} <2 x float> @llvm.arithmetic.fence.v2f3246 47  v = __arithmetic_fence(a + b);48  // CHECKFAST: call{{.*}} float @llvm.arithmetic.fence.f32(float %add{{.*}})49 50  v = (a + b);51  // CHECKPP: call{{.*}} float @llvm.arithmetic.fence.f32(float %add{{.*}})52  v = a + (b*b);53  // CHECKPP: fmul reassoc54  // CHECKPP-NEXT: call{{.*}} float @llvm.arithmetic.fence.f32(float %mul)55  // CHECKNP: fmul56  // CHECKNP: fadd57  v = b + a*a;58  // CHECKPP: call{{.*}} float @llvm.fmuladd.f3259  // CHECKNP: fmul60  // CHECKNP: fadd61  v = b + __arithmetic_fence(a*a); // Fence blocks recognition of FMA62  // CHECKPP: fmul63  // CHECKNP: fmul64 65  b = (a);66  (a) = b;67  // CHECK-NEXT fptosi68  // CHECK-NEXT store i3269  // CHECK-NEXT load float70  // CHECK-NEXT store float71  // CHECK-NEXT load float72  // CHECK-NEXT store float73  return 0;74  // CHECK-NEXT ret i32 075}76int addit1(int a, int b) {77  // CHECK: define {{.*}}@addit1(i32 noundef %a, i32 noundef %b{{.*}}78  v = (a + b);79  // CHECK-NOT: call{{.*}} float @llvm.arithmetic.fence.int(float noundef %add)80  return 0;81}82#ifdef FAST83#pragma float_control(precise, on)84int subit(float a, float b, float *fp) {85  // CHECKFAST: define {{.*}}@subit(float noundef %a, float noundef %b{{.*}}86  *fp = __arithmetic_fence(a - b);87  *fp = (a + b);88  // CHECK-NOT: call{{.*}} float @llvm.arithmetic.fence.f32(float noundef %add)89  return 0;90}91#endif92