|
1 | 1 | // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s |
2 | 2 | // RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s |
3 | 3 |
|
| 4 | +// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - -fexperimental-new-constant-interpreter | FileCheck %s |
| 5 | +// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - -fexperimental-new-constant-interpreter | FileCheck %s |
| 6 | + |
| 7 | + |
4 | 8 | #include <x86intrin.h> |
| 9 | +#include "builtin_test_helpers.h" |
5 | 10 |
|
6 | 11 | int test__bswapd(int X) { |
7 | 12 | // CHECK-LABEL: test__bswapd |
8 | 13 | // CHECK: call i32 @llvm.bswap.i32 |
9 | 14 | return __bswapd(X); |
10 | 15 | } |
| 16 | +TEST_CONSTEXPR(__bswapd(0x00000000) == 0x00000000); |
| 17 | +TEST_CONSTEXPR(__bswapd(0x01020304) == 0x04030201); |
11 | 18 |
|
12 | 19 | int test_bswap(int X) { |
13 | 20 | // CHECK-LABEL: test_bswap |
14 | 21 | // CHECK: call i32 @llvm.bswap.i32 |
15 | 22 | return _bswap(X); |
16 | 23 | } |
| 24 | +TEST_CONSTEXPR(_bswap(0x00000000) == 0x00000000); |
| 25 | +TEST_CONSTEXPR(_bswap(0x10203040) == 0x40302010); |
17 | 26 |
|
18 | 27 | long test__bswapq(long long X) { |
19 | 28 | // CHECK-LABEL: test__bswapq |
20 | 29 | // CHECK: call i64 @llvm.bswap.i64 |
21 | 30 | return __bswapq(X); |
22 | 31 | } |
| 32 | +TEST_CONSTEXPR(__bswapq(0x0000000000000000ULL) == 0x0000000000000000); |
| 33 | +TEST_CONSTEXPR(__bswapq(0x0102030405060708ULL) == 0x0807060504030201); |
23 | 34 |
|
24 | 35 | long test_bswap64(long long X) { |
25 | 36 | // CHECK-LABEL: test_bswap64 |
26 | 37 | // CHECK: call i64 @llvm.bswap.i64 |
27 | 38 | return _bswap64(X); |
28 | 39 | } |
29 | | - |
30 | | -// Test constexpr handling. |
31 | | -#if defined(__cplusplus) && (__cplusplus >= 201103L) |
32 | | - |
33 | | -char bswapd_0[__bswapd(0x00000000) == 0x00000000 ? 1 : -1]; |
34 | | -char bswapd_1[__bswapd(0x01020304) == 0x04030201 ? 1 : -1]; |
35 | | - |
36 | | -char bswap_0[_bswap(0x00000000) == 0x00000000 ? 1 : -1]; |
37 | | -char bswap_1[_bswap(0x10203040) == 0x40302010 ? 1 : -1]; |
38 | | - |
39 | | -char bswapq_0[__bswapq(0x0000000000000000ULL) == 0x0000000000000000 ? 1 : -1]; |
40 | | -char bswapq_1[__bswapq(0x0102030405060708ULL) == 0x0807060504030201 ? 1 : -1]; |
41 | | - |
42 | | -char bswap64_0[_bswap64(0x0000000000000000ULL) == 0x0000000000000000 ? 1 : -1]; |
43 | | -char bswap64_1[_bswap64(0x1020304050607080ULL) == 0x8070605040302010 ? 1 : -1]; |
44 | | - |
45 | | -#endif |
| 40 | +TEST_CONSTEXPR(_bswap64(0x0000000000000000ULL) == 0x0000000000000000); |
| 41 | +TEST_CONSTEXPR(_bswap64(0x1020304050607080ULL) == 0x8070605040302010); |
0 commit comments