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 
test_castf32_u32(float __A)8 unsigned int test_castf32_u32 (float __A){
9   // CHECK-LABEL: test_castf32_u32
10   // CHECK: bitcast float* %{{.*}} to i32*
11   // CHECK: %{{.*}} = load i32, i32* %{{.*}}, align 4
12   return _castf32_u32(__A);
13 }
14 
test_castf64_u64(double __A)15 unsigned long long test_castf64_u64 (double __A){
16   // CHECK-LABEL: test_castf64_u64
17   // CHECK: bitcast double* %{{.*}} to i64*
18   // CHECK: %{{.*}} = load i64, i64* %{{.*}}, align 8
19   return _castf64_u64(__A);
20 }
21 
test_castu32_f32(unsigned int __A)22 float test_castu32_f32 (unsigned int __A){
23   // CHECK-LABEL: test_castu32_f32
24   // CHECK: bitcast i32* %{{.*}} to float*
25   // CHECK: %{{.*}} = load float, float* %{{.*}}, align 4
26   return _castu32_f32(__A);
27 }
28 
test_castu64_f64(unsigned long long __A)29 double test_castu64_f64 (unsigned long long __A){
30   // CHECK-LABEL: test_castu64_f64
31   // CHECK: bitcast i64* %{{.*}} to double*
32   // CHECK: %{{.*}} = load double, double* %{{.*}}, align 8
33   return _castu64_f64(__A);
34 }
35 
36 // Test constexpr handling.
37 #if defined(__cplusplus) && (__cplusplus >= 201103L)
38 char cast_f32_u32_0[_castf32_u32(-0.0f) == 0x80000000 ? 1 : -1];
39 char cast_u32_f32_0[_castu32_f32(0x3F800000) == +1.0f ? 1 : -1];
40 
41 char castf64_u64_0[_castf64_u64(-0.0) == 0x8000000000000000 ? 1 : -1];
42 char castu64_f64_0[_castu64_f64(0xBFF0000000000000ULL) == -1.0 ? 1 : -1];
43 #endif
44