| 1 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir -fmath-errno %s -o %t.cir |
| 2 |
// RUN: FileCheck --input-file=%t.cir %s -check-prefixes=ALL,CIR-ERRNO |
| 3 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir %s -o %t-no-errno.cir |
| 4 |
// RUN: FileCheck --input-file=%t-no-errno.cir %s -check-prefixes=ALL,CIR-NO-ERRNO |
| 5 |
|
| 6 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir -fmath-errno -O1 %s -o %t-errno-o1.cir |
| 7 |
// RUN: FileCheck --input-file=%t-errno-o1.cir %s -check-prefixes=ALL,CIR-ERRNO-O1 |
| 8 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-cir -ffast-math -O1 %s -o %t-no-errno-o1.cir |
| 9 |
// RUN: FileCheck --input-file=%t-no-errno-o1.cir %s -check-prefixes=ALL,CIR-NO-ERRNO-O1 |
| 10 |
|
| 11 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm -fmath-errno %s -o %t.ll |
| 12 |
// RUN: FileCheck --input-file=%t.ll %s -check-prefixes=ALL,LLVM-ERRNO |
| 13 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm -ffast-math %s -o %t-no-errno.ll |
| 14 |
// RUN: FileCheck --input-file=%t-no-errno.ll %s -check-prefixes=ALL,LLVM-NO-ERRNO |
| 15 |
|
| 16 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm -fmath-errno -O1 %s -o %t-errno-o1.ll |
| 17 |
// RUN: FileCheck --input-file=%t-errno-o1.ll %s -check-prefixes=ALL,LLVM-ERRNO-O1 |
| 18 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm -ffast-math -O1 %s -o %t-no-errno-o1.ll |
| 19 |
// RUN: FileCheck --input-file=%t-no-errno-o1.ll %s -check-prefixes=ALL,LLVM-NO-ERRNO-O1 |
| 20 |
|
| 21 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm -fmath-errno %s -o %t.ll |
| 22 |
// RUN: FileCheck --input-file=%t.ll %s -check-prefixes=ALL,OGCG-ERRNO |
| 23 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm -ffast-math %s -o %t-no-errno.ll |
| 24 |
// RUN: FileCheck --input-file=%t-no-errno.ll %s -check-prefixes=ALL,OGCG-NO-ERRNO |
| 25 |
|
| 26 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm -fmath-errno -O1 %s -o %t-errno-o1.ll |
| 27 |
// RUN: FileCheck --input-file=%t-errno-o1.ll %s -check-prefixes=ALL,OGCG-ERRNO-O1 |
| 28 |
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm -ffast-math -O1 %s -o %t-no-errno-o1.ll |
| 29 |
// RUN: FileCheck --input-file=%t-no-errno-o1.ll %s -check-prefixes=ALL,OGCG-NO-ERRNO-O1 |
| 30 |
|
| 31 |
float test_normal(float f) { |
| 32 |
return __builtin_cosf(f); |
| 33 |
// ALL: test_normal |
| 34 |
// CIR-ERRNO: cir.call @cosf |
| 35 |
// CIR-NO-ERRNO: cir.cos |
| 36 |
// LLVM-ERRNO: call float @cosf |
| 37 |
// LLVM-NO-ERRNO: call float @llvm.cos.f32 |
| 38 |
// OGCG-ERRNO: call {{.*}} float @cosf |
| 39 |
// OGCG-NO-ERRNO: call {{.*}} float @llvm.cos.f32 |
| 40 |
} |
| 41 |
|
| 42 |
float test_precise(float f) { |
| 43 |
#pragma float_control(precise, on) |
| 44 |
// Should never produce an intrinsic |
| 45 |
return __builtin_cosf(f); |
| 46 |
// ALL: test_precise |
| 47 |
// CIR-ERRNO: cir.call @cosf |
| 48 |
// CIR-NO-ERRNO: cir.call @cosf |
| 49 |
// LLVM-ERRNO: call float @cosf |
| 50 |
// LLVM-NO-ERRNO: call float @cosf |
| 51 |
// OGCG-ERRNO: call {{.*}} float @cosf |
| 52 |
// OGCG-NO-ERRNO: call {{.*}} float @cosf |
| 53 |
} |
| 54 |
|
| 55 |
float test_fast(float f) { |
| 56 |
#pragma float_control(precise, off) |
| 57 |
// Should produce an intrinsic at -O1 |
| 58 |
return __builtin_cosf(f); |
| 59 |
// ALL: test_fast |
| 60 |
// CIR-ERRNO-O1: cir.cos |
| 61 |
// CIR-NO-ERRNO-O1: cir.cos |
| 62 |
// LLVM-ERRNO-O1: call float @llvm.cos.f32 |
| 63 |
// LLVM-NO-ERRNO-O1: call float @llvm.cos.f32 |
| 64 |
// OGCG-ERRNO-O1: call {{.*}} float @llvm.cos.f32 |
| 65 |
// OGCG-NO-ERRNO-O1: call {{.*}} float @llvm.cos.f32 |
| 66 |
} |
| 67 |
|
| 68 |
__attribute__((optnone)) |
| 69 |
float test_optnone(float f) { |
| 70 |
// Should never produce an intrinsic |
| 71 |
return __builtin_cosf(f); |
| 72 |
// ALL: test_optnone |
| 73 |
// CIR-ERRNO: cir.call @cosf |
| 74 |
// CIR-NO-ERRNO: cir.call @cosf |
| 75 |
// LLVM-ERRNO: call float @cosf |
| 76 |
// LLVM-NO-ERRNO: call float @cosf |
| 77 |
// OGCG-ERRNO: call {{.*}} float @cosf |
| 78 |
// OGCG-NO-ERRNO: call {{.*}} float @cosf |
| 79 |
} |