Skip to content

Commit a6e297d

Browse files
authored
Merge pull request #2471 from apple/eng/fixup-ms-2020
Revert "Re-fix _lrotl/_lrotr to always take Long, no matter the platf…
2 parents 8643831 + b5e4206 commit a6e297d

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

clang/include/clang/Basic/Builtins.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,12 +885,12 @@ LANGBUILTIN(_ReturnAddress, "v*", "n", ALL_MS_LANGUAGES)
885885
LANGBUILTIN(_rotl8, "UcUcUc", "n", ALL_MS_LANGUAGES)
886886
LANGBUILTIN(_rotl16, "UsUsUc", "n", ALL_MS_LANGUAGES)
887887
LANGBUILTIN(_rotl, "UiUii", "n", ALL_MS_LANGUAGES)
888-
LANGBUILTIN(_lrotl, "ULiULii", "n", ALL_MS_LANGUAGES)
888+
LANGBUILTIN(_lrotl, "UNiUNii", "n", ALL_MS_LANGUAGES)
889889
LANGBUILTIN(_rotl64, "UWiUWii", "n", ALL_MS_LANGUAGES)
890890
LANGBUILTIN(_rotr8, "UcUcUc", "n", ALL_MS_LANGUAGES)
891891
LANGBUILTIN(_rotr16, "UsUsUc", "n", ALL_MS_LANGUAGES)
892892
LANGBUILTIN(_rotr, "UiUii", "n", ALL_MS_LANGUAGES)
893-
LANGBUILTIN(_lrotr, "ULiULii", "n", ALL_MS_LANGUAGES)
893+
LANGBUILTIN(_lrotr, "UNiUNii", "n", ALL_MS_LANGUAGES)
894894
LANGBUILTIN(_rotr64, "UWiUWii", "n", ALL_MS_LANGUAGES)
895895
LANGBUILTIN(__va_start, "vc**.", "nt", ALL_MS_LANGUAGES)
896896
LANGBUILTIN(__fastfail, "vUi", "nr", ALL_MS_LANGUAGES)

clang/test/CodeGen/ms-intrinsics-rotations.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@
1212
// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
1313
// RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 \
1414
// RUN: -triple x86_64--linux -emit-llvm %s -o - \
15-
// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
15+
// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
1616
// RUN: %clang_cc1 -ffreestanding -fms-extensions \
1717
// RUN: -triple x86_64--darwin -emit-llvm %s -o - \
18-
// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
18+
// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
19+
20+
// LP64 targets use 'long' as 'int' for MS intrinsics (-fms-extensions)
21+
#ifdef __LP64__
22+
#define LONG int
23+
#else
24+
#define LONG long
25+
#endif
1926

2027
// rotate left
2128

@@ -40,15 +47,12 @@ unsigned int test_rotl(unsigned int value, int shift) {
4047
// CHECK: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
4148
// CHECK: ret i32 [[R]]
4249

43-
unsigned long test_lrotl(unsigned long value, int shift) {
50+
unsigned LONG test_lrotl(unsigned LONG value, int shift) {
4451
return _lrotl(value, shift);
4552
}
4653
// CHECK-32BIT-LONG: i32 @test_lrotl
4754
// CHECK-32BIT-LONG: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
4855
// CHECK-32BIT-LONG: ret i32 [[R]]
49-
// CHECK-64BIT-LONG: i64 @test_lrotl
50-
// CHECK-64BIT-LONG: [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
51-
// CHECK-64BIT-LONG: ret i64 [[R]]
5256

5357
unsigned __int64 test_rotl64(unsigned __int64 value, int shift) {
5458
return _rotl64(value, shift);
@@ -80,15 +84,12 @@ unsigned int test_rotr(unsigned int value, int shift) {
8084
// CHECK: [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
8185
// CHECK: ret i32 [[R]]
8286

83-
unsigned long test_lrotr(unsigned long value, int shift) {
87+
unsigned LONG test_lrotr(unsigned LONG value, int shift) {
8488
return _lrotr(value, shift);
8589
}
8690
// CHECK-32BIT-LONG: i32 @test_lrotr
8791
// CHECK-32BIT-LONG: [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
8892
// CHECK-32BIT-LONG: ret i32 [[R]]
89-
// CHECK-64BIT-LONG: i64 @test_lrotr
90-
// CHECK-64BIT-LONG: [[R:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
91-
// CHECK-64BIT-LONG: ret i64 [[R]]
9293

9394
unsigned __int64 test_rotr64(unsigned __int64 value, int shift) {
9495
return _rotr64(value, shift);

0 commit comments

Comments
 (0)