Skip to content

Commit 75fd5b0

Browse files
authored
[X86] Add -fexperimental-new-constant-interpreter test coverage to the BITSCAN constexpr test files (llvm#156070)
Update tests to use builtin_test_helpers.h and the TEST_CONSTEXPR helper macro Partial fix for llvm#155814
1 parent b975a7b commit 75fd5b0

File tree

1 file changed

+17
-23
lines changed

1 file changed

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

4+
// RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown -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-unknown-unknown -no-enable-noundef-analysis -emit-llvm -o - -fexperimental-new-constant-interpreter | FileCheck %s
6+
47
// PR33722
58
// RUN: %clang_cc1 -x c -ffreestanding %s -triple x86_64-unknown-unknown -fms-extensions -fms-compatibility-version=19.00 -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s
69
// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple x86_64-unknown-unknown -fms-extensions -fms-compatibility-version=19.00 -no-enable-noundef-analysis -emit-llvm -o - | FileCheck %s
710

11+
812
#include <x86intrin.h>
13+
#include "builtin_test_helpers.h"
914

1015
int test_bit_scan_forward(int a) {
1116
// CHECK-LABEL: test_bit_scan_forward
1217
// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
1318
// CHECK: ret i32 %[[call]]
1419
return _bit_scan_forward(a);
1520
}
21+
TEST_CONSTEXPR(_bit_scan_forward(0x00000001) == 0);
22+
TEST_CONSTEXPR(_bit_scan_forward(0x10000000) == 28);
1623

1724
int test_bit_scan_reverse(int a) {
1825
// CHECK-LABEL: test_bit_scan_reverse
@@ -21,25 +28,33 @@ int test_bit_scan_reverse(int a) {
2128
// CHECK: ret i32 %[[sub]]
2229
return _bit_scan_reverse(a);
2330
}
31+
TEST_CONSTEXPR(_bit_scan_reverse(0x00000001) == 0);
32+
TEST_CONSTEXPR(_bit_scan_reverse(0x01000000) == 24);
2433

2534
int test__bsfd(int X) {
2635
// CHECK-LABEL: test__bsfd
2736
// CHECK: %[[call:.*]] = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
2837
return __bsfd(X);
2938
}
39+
TEST_CONSTEXPR(__bsfd(0x00000008) == 3);
40+
TEST_CONSTEXPR(__bsfd(0x00010008) == 3);
3041

3142
int test__bsfq(long long X) {
3243
// CHECK-LABEL: test__bsfq
3344
// CHECK: %[[call:.*]] = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
3445
return __bsfq(X);
3546
}
47+
TEST_CONSTEXPR(__bsfq(0x0000000800000000ULL) == 35);
48+
TEST_CONSTEXPR(__bsfq(0x0004000000000000ULL) == 50);
3649

3750
int test__bsrd(int X) {
3851
// CHECK-LABEL: test__bsrd
3952
// CHECK: %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
4053
// CHECK: %[[sub:.*]] = sub nsw i32 31, %[[call]]
4154
return __bsrd(X);
4255
}
56+
TEST_CONSTEXPR(__bsrd(0x00000010) == 4);
57+
TEST_CONSTEXPR(__bsrd(0x00100100) == 20);
4358

4459
int test__bsrq(long long X) {
4560
// CHECK-LABEL: test__bsrq
@@ -48,26 +63,5 @@ int test__bsrq(long long X) {
4863
// CHECK: %[[sub:.*]] = sub nsw i32 63, %[[cast]]
4964
return __bsrq(X);
5065
}
51-
52-
// Test constexpr handling.
53-
#if defined(__cplusplus) && (__cplusplus >= 201103L)
54-
55-
char bsf_0[_bit_scan_forward(0x00000001) == 0 ? 1 : -1];
56-
char bsf_1[_bit_scan_forward(0x10000000) == 28 ? 1 : -1];
57-
58-
char bsr_0[_bit_scan_reverse(0x00000001) == 0 ? 1 : -1];
59-
char bsr_1[_bit_scan_reverse(0x01000000) == 24 ? 1 : -1];
60-
61-
char bsfd_0[__bsfd(0x00000008) == 3 ? 1 : -1];
62-
char bsfd_1[__bsfd(0x00010008) == 3 ? 1 : -1];
63-
64-
char bsrd_0[__bsrd(0x00000010) == 4 ? 1 : -1];
65-
char bsrd_1[__bsrd(0x00100100) == 20 ? 1 : -1];
66-
67-
char bsfq_0[__bsfq(0x0000000800000000ULL) == 35 ? 1 : -1];
68-
char bsfq_1[__bsfq(0x0004000000000000ULL) == 50 ? 1 : -1];
69-
70-
char bsrq_0[__bsrq(0x0000100800000000ULL) == 44 ? 1 : -1];
71-
char bsrq_1[__bsrq(0x0004000100000000ULL) == 50 ? 1 : -1];
72-
73-
#endif
66+
TEST_CONSTEXPR(__bsrq(0x0000100800000000ULL) == 44);
67+
TEST_CONSTEXPR(__bsrq(0x0004000100000000ULL) == 50);

0 commit comments

Comments
 (0)