| 1 |
// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown -emit-llvm -o - -Wall -Werror | FileCheck %s |
| 2 |
// RUN: %clang_cc1 -x c -ffreestanding %s -triple=i386-unknown-unknown -emit-llvm -o - -Wall -Werror | FileCheck %s |
| 3 |
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-unknown-unknown -emit-llvm -o - -Wall -Werror | FileCheck %s |
| 4 |
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=i386-unknown-unknown -emit-llvm -o - -Wall -Werror | FileCheck %s |
| 5 |
|
| 6 |
#include <x86intrin.h> |
| 7 |
|
| 8 |
unsigned int test_castf32_u32 (float __A){ |
| 9 |
// CHECK-LABEL: test_castf32_u32 |
| 10 |
// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 4 |
| 11 |
return _castf32_u32(__A); |
| 12 |
} |
| 13 |
|
| 14 |
unsigned long long test_castf64_u64 (double __A){ |
| 15 |
// CHECK-LABEL: test_castf64_u64 |
| 16 |
// CHECK: %{{.*}} = load i64, ptr %{{.*}}, align 8 |
| 17 |
return _castf64_u64(__A); |
| 18 |
} |
| 19 |
|
| 20 |
float test_castu32_f32 (unsigned int __A){ |
| 21 |
// CHECK-LABEL: test_castu32_f32 |
| 22 |
// CHECK: %{{.*}} = load float, ptr %{{.*}}, align 4 |
| 23 |
return _castu32_f32(__A); |
| 24 |
} |
| 25 |
|
| 26 |
double test_castu64_f64 (unsigned long long __A){ |
| 27 |
// CHECK-LABEL: test_castu64_f64 |
| 28 |
// CHECK: %{{.*}} = load double, ptr %{{.*}}, align 8 |
| 29 |
return _castu64_f64(__A); |
| 30 |
} |
| 31 |
|
| 32 |
// Test constexpr handling. |
| 33 |
#if defined(__cplusplus) && (__cplusplus >= 201103L) |
| 34 |
char cast_f32_u32_0[_castf32_u32(-0.0f) == 0x80000000 ? 1 : -1]; |
| 35 |
char cast_u32_f32_0[_castu32_f32(0x3F800000) == +1.0f ? 1 : -1]; |
| 36 |
|
| 37 |
char castf64_u64_0[_castf64_u64(-0.0) == 0x8000000000000000 ? 1 : -1]; |
| 38 |
char castu64_f64_0[_castu64_f64(0xBFF0000000000000ULL) == -1.0 ? 1 : -1]; |
| 39 |
#endif |