1- // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s
2- // RUN: %clang_cc1 -ffreestanding %s -triple=i386-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s --check-prefix=B32
1+ // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s
2+ // RUN: %clang_cc1 -x c -ffreestanding %s -triple=i386-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s --check-prefix=B32
3+ // RUN: %clang_cc1 -x c++ -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s
4+ // RUN: %clang_cc1 -x c++ -ffreestanding %s -triple=i386-apple-darwin -target-feature +bmi2 -emit-llvm -o - | FileCheck %s --check-prefix=B32
35
46
57#include <immintrin.h>
@@ -22,7 +24,6 @@ unsigned int test_pext_u32(unsigned int __X, unsigned int __Y) {
2224#ifdef __i386__
2325unsigned int test_mulx_u32 (unsigned int __X , unsigned int __Y ,
2426 unsigned int * __P ) {
25- // B32: @test_mulx_u32
2627 // B32: mul i64
2728 return _mulx_u32 (__X , __Y , __P );
2829}
@@ -46,8 +47,24 @@ unsigned long long test_pext_u64(unsigned long long __X, unsigned long long __Y)
4647
4748unsigned long long test_mulx_u64 (unsigned long long __X , unsigned long long __Y ,
4849 unsigned long long * __P ) {
49- // CHECK: @test_mulx_u64
5050 // CHECK: mul i128
5151 return _mulx_u64 (__X , __Y , __P );
5252}
5353#endif
54+
55+ // Test constexpr handling.
56+ #if defined(__cplusplus ) && (__cplusplus >= 201103L )
57+ char bzhi32_0 [_bzhi_u32 (0x89ABCDEF , 0 ) == 0x00000000 ? 1 : -1 ];
58+ char bzhi32_1 [_bzhi_u32 (0x89ABCDEF , 16 ) == 0x0000CDEF ? 1 : -1 ];
59+ char bzhi32_2 [_bzhi_u32 (0x89ABCDEF , 31 ) == 0x09ABCDEF ? 1 : -1 ];
60+ char bzhi32_3 [_bzhi_u32 (0x89ABCDEF , 32 ) == 0x89ABCDEF ? 1 : -1 ];
61+ char bzhi32_4 [_bzhi_u32 (0x89ABCDEF , 99 ) == 0x89ABCDEF ? 1 : -1 ];
62+ char bzhi32_5 [_bzhi_u32 (0x89ABCDEF , 260 ) == 0x0000000F ? 1 : -1 ];
63+
64+ #ifdef __x86_64__
65+ char bzhi64_0 [_bzhi_u64 (0x0123456789ABCDEFULL , 0 ) == 0x0000000000000000ULL ? 1 : -1 ];
66+ char bzhi64_1 [_bzhi_u64 (0x0123456789ABCDEFULL , 32 ) == 0x0000000089ABCDEFULL ? 1 : -1 ];
67+ char bzhi64_2 [_bzhi_u64 (0x0123456789ABCDEFULL , 99 ) == 0x0123456789ABCDEFULL ? 1 : -1 ];
68+ char bzhi64_3 [_bzhi_u64 (0x0123456789ABCDEFULL , 520 ) == 0x00000000000000EFULL ? 1 : -1 ];
69+ #endif
70+ #endif
0 commit comments