Skip to content

Commit 149fb57

Browse files
authored
[X86] Add -fexperimental-new-constant-interpreter test coverage to the BSWAP constexpr test files (llvm#156061)
Update tests to use builtin_test_helpers.h and the TEST_CONSTEXPR helper macro Partial fix for llvm#155814
1 parent a22d4de commit 149fb57

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

clang/test/CodeGen/X86/x86-bswap.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,41 @@
11
// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s
22
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s
33

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+
48
#include <x86intrin.h>
9+
#include "builtin_test_helpers.h"
510

611
int test__bswapd(int X) {
712
// CHECK-LABEL: test__bswapd
813
// CHECK: call i32 @llvm.bswap.i32
914
return __bswapd(X);
1015
}
16+
TEST_CONSTEXPR(__bswapd(0x00000000) == 0x00000000);
17+
TEST_CONSTEXPR(__bswapd(0x01020304) == 0x04030201);
1118

1219
int test_bswap(int X) {
1320
// CHECK-LABEL: test_bswap
1421
// CHECK: call i32 @llvm.bswap.i32
1522
return _bswap(X);
1623
}
24+
TEST_CONSTEXPR(_bswap(0x00000000) == 0x00000000);
25+
TEST_CONSTEXPR(_bswap(0x10203040) == 0x40302010);
1726

1827
long test__bswapq(long long X) {
1928
// CHECK-LABEL: test__bswapq
2029
// CHECK: call i64 @llvm.bswap.i64
2130
return __bswapq(X);
2231
}
32+
TEST_CONSTEXPR(__bswapq(0x0000000000000000ULL) == 0x0000000000000000);
33+
TEST_CONSTEXPR(__bswapq(0x0102030405060708ULL) == 0x0807060504030201);
2334

2435
long test_bswap64(long long X) {
2536
// CHECK-LABEL: test_bswap64
2637
// CHECK: call i64 @llvm.bswap.i64
2738
return _bswap64(X);
2839
}
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

Comments
 (0)