Skip to content

Commit e956090

Browse files
authored
[X86] Add -fexperimental-new-constant-interpreter test coverage to the x86 scalar rotate constexpr test files (#156337)
Update tests to use builtin_test_helpers.h and the TEST_CONSTEXPR helper macro Partial fix for #155814
1 parent 507ff08 commit e956090

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

clang/test/CodeGen/X86/rot-intrinsics.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,46 @@
55
// RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
66
// RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
77

8-
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding -triple i686--linux -no-enable-noundef-analysis -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
9-
// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding -triple x86_64--linux -no-enable-noundef-analysis -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
10-
// RUN: %clang_cc1 -x c++ -std=c++11 -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
11-
// RUN: %clang_cc1 -x c++ -std=c++11 -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
12-
// RUN: %clang_cc1 -x c++ -std=c++11 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
13-
// RUN: %clang_cc1 -x c++ -std=c++11 -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
8+
// RUN: %clang_cc1 -x c++ -ffreestanding -triple i686--linux -no-enable-noundef-analysis -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
9+
// RUN: %clang_cc1 -x c++ -ffreestanding -triple x86_64--linux -no-enable-noundef-analysis -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
10+
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
11+
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
12+
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
13+
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
14+
15+
// RUN: %clang_cc1 -x c++ -ffreestanding -triple i686--linux -no-enable-noundef-analysis -emit-llvm %s -o - -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
16+
// RUN: %clang_cc1 -x c++ -ffreestanding -triple x86_64--linux -no-enable-noundef-analysis -emit-llvm %s -o - -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
17+
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
18+
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
19+
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
20+
// RUN: %clang_cc1 -x c++ -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -no-enable-noundef-analysis -emit-llvm -o - -Wall -Werror -fexperimental-new-constant-interpreter | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
1421

1522
#include <x86intrin.h>
23+
#include "builtin_test_helpers.h"
1624

1725
unsigned char test__rolb(unsigned char value, int shift) {
1826
// CHECK-LABEL: test__rolb
1927
// CHECK: [[R:%.*]] = call i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
2028
// CHECK: ret i8 [[R]]
2129
return __rolb(value, shift);
2230
}
31+
TEST_CONSTEXPR(__rolb(0x01, 5) == 0x20);
2332

2433
unsigned short test__rolw(unsigned short value, int shift) {
2534
// CHECK-LABEL: test__rolw
2635
// CHECK: [[R:%.*]] = call i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
2736
// CHECK: ret i16 [[R]]
2837
return __rolw(value, shift);
2938
}
39+
TEST_CONSTEXPR(__rolw(0x3210, 11) == 0x8190);
3040

3141
unsigned int test__rold(unsigned int value, int shift) {
3242
// CHECK-LABEL: test__rold
3343
// CHECK: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
3444
// CHECK: ret i32 [[R]]
3545
return __rold(value, shift);
3646
}
47+
TEST_CONSTEXPR(__rold(0x76543210, 22) == 0x841D950C);
3748

3849
#if defined(__x86_64__)
3950
unsigned long test__rolq(unsigned long value, int shift) {
@@ -42,6 +53,7 @@ unsigned long test__rolq(unsigned long value, int shift) {
4253
// CHECK-LONG: ret i64 [[R]]
4354
return __rolq(value, shift);
4455
}
56+
TEST_CONSTEXPR(__rolq(0xFEDCBA9876543210ULL, 55) == 0x087F6E5D4C3B2A19ULL);
4557
#endif
4658

4759
unsigned char test__rorb(unsigned char value, int shift) {
@@ -50,20 +62,23 @@ unsigned char test__rorb(unsigned char value, int shift) {
5062
// CHECK: ret i8 [[R]]
5163
return __rorb(value, shift);
5264
}
65+
TEST_CONSTEXPR(__rorb(0x01, 5) == 0x08);
5366

5467
unsigned short test__rorw(unsigned short value, int shift) {
5568
// CHECK-LABEL: test__rorw
5669
// CHECK: [[R:%.*]] = call i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
5770
// CHECK: ret i16 [[R]]
5871
return __rorw(value, shift);
5972
}
73+
TEST_CONSTEXPR(__rorw(0x3210, 11) == 0x4206);
6074

6175
unsigned int test__rord(unsigned int value, int shift) {
6276
// CHECK-LABEL: test__rord
6377
// CHECK: [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
6478
// CHECK: ret i32 [[R]]
6579
return __rord(value, shift);
6680
}
81+
TEST_CONSTEXPR(__rord(0x76543210, 22) == 0x50C841D9);
6782

6883
#if defined(__x86_64__)
6984
unsigned long test__rorq(unsigned long value, int shift) {
@@ -72,6 +87,7 @@ unsigned long test__rorq(unsigned long value, int shift) {
7287
// CHECK-LONG: ret i64 [[R]]
7388
return __rorq(value, shift);
7489
}
90+
TEST_CONSTEXPR(__rorq(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL);
7591
#endif
7692

7793
unsigned short test_rotwl(unsigned short value, int shift) {
@@ -80,13 +96,15 @@ unsigned short test_rotwl(unsigned short value, int shift) {
8096
// CHECK: ret i16 [[R]]
8197
return _rotwl(value, shift);
8298
}
99+
TEST_CONSTEXPR(_rotwl(0x3210, 4) == 0x2103);
83100

84101
unsigned int test_rotl(unsigned int value, int shift) {
85102
// CHECK-LABEL: test_rotl
86103
// CHECK: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
87104
// CHECK: ret i32 [[R]]
88105
return _rotl(value, shift);
89106
}
107+
TEST_CONSTEXPR(_rotl(0x76543210, 8) == 0x54321076);
90108

91109
unsigned long test_lrotl(unsigned long value, int shift) {
92110
// CHECK-32BIT-LONG-LABEL: test_lrotl
@@ -98,6 +116,11 @@ unsigned long test_lrotl(unsigned long value, int shift) {
98116
// CHECK-64BIT-LONG: ret i64 [[R]]
99117
return _lrotl(value, shift);
100118
}
119+
#if defined(__LP64__) && !defined(_MSC_VER)
120+
TEST_CONSTEXPR(_lrotl(0xFEDCBA9876543210ULL, 55) == 0x087F6E5D4C3B2A19ULL);
121+
#else
122+
TEST_CONSTEXPR(_lrotl(0x76543210, 22) == 0x841D950C);
123+
#endif
101124

102125

103126
unsigned short test_rotwr(unsigned short value, int shift) {
@@ -106,13 +129,15 @@ unsigned short test_rotwr(unsigned short value, int shift) {
106129
// CHECK: ret i16 [[R]]
107130
return _rotwr(value, shift);
108131
}
132+
TEST_CONSTEXPR(_rotwr(0x3210, 4) == 0x0321);
109133

110134
unsigned int test_rotr(unsigned int value, int shift) {
111135
// CHECK-LABEL: test_rotr
112136
// CHECK: [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
113137
// CHECK: ret i32 [[R]]
114138
return _rotr(value, shift);
115139
}
140+
TEST_CONSTEXPR(_rotr(0x76543210, 8) == 0x10765432);
116141

117142
unsigned long test_lrotr(unsigned long value, int shift) {
118143
// CHECK-32BIT-LONG-LABEL: test_lrotr
@@ -124,34 +149,9 @@ unsigned long test_lrotr(unsigned long value, int shift) {
124149
// CHECK-64BIT-LONG: ret i64 [[R]]
125150
return _lrotr(value, shift);
126151
}
127-
128-
// Test constexpr handling.
129-
#if defined(__cplusplus) && (__cplusplus >= 201103L)
130-
131-
char rolb_0[__rolb(0x01, 5) == 0x20 ? 1 : -1];
132-
char rolw_0[__rolw(0x3210, 11) == 0x8190 ? 1 : -1];
133-
char rold_0[__rold(0x76543210, 22) == 0x841D950C ? 1 : -1];
134-
135-
char rorb_0[__rorb(0x01, 5) == 0x08 ? 1 : -1];
136-
char rorw_0[__rorw(0x3210, 11) == 0x4206 ? 1 : -1];
137-
char rord_0[__rord(0x76543210, 22) == 0x50C841D9 ? 1 : -1];
138-
139-
#if defined(__x86_64__)
140-
char rolq_0[__rolq(0xFEDCBA9876543210ULL, 55) == 0x087F6E5D4C3B2A19ULL ? 1 : -1];
141-
char rorq_0[__rorq(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL ? 1 : -1];
142-
#endif
143-
144-
char rotwl_0[_rotwl(0x3210, 4) == 0x2103 ? 1 : -1];
145-
char rotwr_0[_rotwr(0x3210, 4) == 0x0321 ? 1 : -1];
146-
char rotl_0[_rotl(0x76543210, 8) == 0x54321076 ? 1 : -1];
147-
char rotr_0[_rotr(0x76543210, 8) == 0x10765432 ? 1 : -1];
148-
149152
#if defined(__LP64__) && !defined(_MSC_VER)
150-
char lrotl_0[_lrotl(0xFEDCBA9876543210ULL, 55) == 0x087F6E5D4C3B2A19ULL ? 1 : -1];
151-
char lrotr_0[_lrotr(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL ? 1 : -1];
153+
TEST_CONSTEXPR(_lrotr(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL);
152154
#else
153-
char lrotl_0[_lrotl(0x76543210, 22) == 0x841D950C ? 1 : -1];
154-
char lrotr_0[_lrotr(0x76543210, 22) == 0x50C841D9 ? 1 : -1];
155+
TEST_CONSTEXPR(_lrotr(0x76543210, 22) == 0x50C841D9);
155156
#endif
156157

157-
#endif

0 commit comments

Comments
 (0)