[clang] [Inliner] Improve propagation of return attributes. (PR #67756)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 28 17:33:47 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-x86

<details>
<summary>Changes</summary>

- [Inliner] Regen checks for old test; NFC
- [Clang][X86] Split some tests for c/cpp; NFC
- [Inliner] Use "best" ret attribute when propagating attributes during inlining
- [Inliner] Also propagate `noundef` and `align` ret attributes during inlining


---

Patch is 329.13 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/67756.diff


32 Files Affected:

- (modified) clang/test/CodeGen/X86/bitscan-builtins.c (-3) 
- (added) clang/test/CodeGen/X86/bitscan-builtins.cpp (+71) 
- (modified) clang/test/CodeGen/X86/popcnt-builtins.c (-2) 
- (added) clang/test/CodeGen/X86/popcnt-builtins.cpp (+67) 
- (modified) clang/test/CodeGen/X86/rot-intrinsics.c (-7) 
- (added) clang/test/CodeGen/X86/rot-intrinsics.cpp (+165) 
- (modified) clang/test/CodeGen/X86/x86-bswap.c (-1) 
- (added) clang/test/CodeGen/X86/x86-bswap.cpp (+44) 
- (modified) clang/test/CodeGen/aarch64-ls64.c (+2-2) 
- (modified) clang/test/CodeGen/fp-contract-fast-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGen/fp-contract-on-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGen/fp-contract-pragma.cpp (+1-1) 
- (modified) clang/test/CodeGenCUDA/cuda-builtin-vars.cu (+12-12) 
- (modified) clang/test/Headers/__clang_hip_cmath.hip (+10-10) 
- (modified) clang/test/Headers/__clang_hip_math.hip (+524-524) 
- (modified) clang/test/Headers/__clang_hip_math_ocml_rounded_ops.hip (+44-44) 
- (modified) clang/test/Headers/amdgcn_openmp_device_math.c (+12-12) 
- (modified) clang/test/Headers/amdgcn_openmp_device_math_constexpr.cpp (+12-12) 
- (modified) clang/test/Headers/hip-header.hip (+5-5) 
- (modified) clang/test/Headers/nvptx_device_cmath_functions.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_functions.c (+12-7) 
- (modified) clang/test/Headers/nvptx_device_math_functions.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_functions_cxx17.cpp (+5-5) 
- (modified) clang/test/Headers/nvptx_device_math_modf.cpp (+4-4) 
- (modified) clang/test/Headers/nvptx_device_math_sin.cpp (+4-4) 
- (modified) clang/test/Headers/nvptx_device_math_sin_cos.cpp (+6-6) 
- (modified) clang/test/Headers/openmp_device_math_isnan.cpp (+4-4) 
- (modified) llvm/lib/Transforms/Utils/InlineFunction.cpp (+11) 
- (modified) llvm/test/Transforms/Inline/byval.ll (+122-73) 
- (modified) llvm/test/Transforms/Inline/ret_attr_align_and_noundef.ll (+9-9) 
- (modified) llvm/test/Transforms/Inline/ret_attr_update.ll (+1-1) 


``````````diff
diff --git a/clang/test/CodeGen/X86/bitscan-builtins.c b/clang/test/CodeGen/X86/bitscan-builtins.c
index a5a7808a82a234d..d75f7c1ab2f1ed4 100644
--- a/clang/test/CodeGen/X86/bitscan-builtins.c
+++ b/clang/test/CodeGen/X86/bitscan-builtins.c
@@ -1,9 +1,6 @@
 // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
-
 // PR33722
 // RUN: %clang_cc1 -x c -ffreestanding %s -triple x86_64-unknown-unknown -fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple x86_64-unknown-unknown -fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - | FileCheck %s
 
 #include <x86intrin.h>
 
diff --git a/clang/test/CodeGen/X86/bitscan-builtins.cpp b/clang/test/CodeGen/X86/bitscan-builtins.cpp
new file mode 100644
index 000000000000000..ab8a0fa2f24773b
--- /dev/null
+++ b/clang/test/CodeGen/X86/bitscan-builtins.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-unknown-unknown -emit-llvm -o - | FileCheck %s
+
+// PR33722
+// RUN: %clang_cc1 -x c++ -ffreestanding %s -triple x86_64-unknown-unknown -fms-extensions -fms-compatibility-version=19.00 -emit-llvm -o - | FileCheck %s
+
+#include <x86intrin.h>
+
+int test_bit_scan_forward(int a) {
+// CHECK-LABEL: test_bit_scan_forward
+// CHECK: %[[call:.*]] = call noundef i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
+// CHECK: ret i32 %[[call]]
+  return _bit_scan_forward(a);
+}
+
+int test_bit_scan_reverse(int a) {
+// CHECK-LABEL: test_bit_scan_reverse
+// CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
+// CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]
+// CHECK: ret i32 %[[sub]]
+  return _bit_scan_reverse(a);
+}
+
+int test__bsfd(int X) {
+// CHECK-LABEL: test__bsfd
+// CHECK: %[[call:.*]] = call noundef i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
+  return __bsfd(X);
+}
+
+int test__bsfq(long long X) {
+// CHECK-LABEL: test__bsfq
+// CHECK: %[[call:.*]] = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
+  return __bsfq(X);
+}
+
+int test__bsrd(int X) {
+// CHECK-LABEL: test__bsrd
+// CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
+// CHECK:  %[[sub:.*]] = sub nsw i32 31, %[[call]]
+  return __bsrd(X);
+}
+
+int test__bsrq(long long X) {
+// CHECK-LABEL: test__bsrq
+// CHECK:  %[[call:.*]] = call i64 @llvm.ctlz.i64(i64 %{{.*}}, i1 true)
+// CHECK:  %[[cast:.*]] = trunc i64 %[[call]] to i32
+// CHECK:  %[[sub:.*]] = sub nsw i32 63, %[[cast]]
+  return __bsrq(X);
+}
+
+// Test constexpr handling.
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+
+char bsf_0[_bit_scan_forward(0x00000001) ==  0 ? 1 : -1];
+char bsf_1[_bit_scan_forward(0x10000000) == 28 ? 1 : -1];
+
+char bsr_0[_bit_scan_reverse(0x00000001) ==  0 ? 1 : -1];
+char bsr_1[_bit_scan_reverse(0x01000000) == 24 ? 1 : -1];
+
+char bsfd_0[__bsfd(0x00000008) ==  3 ? 1 : -1];
+char bsfd_1[__bsfd(0x00010008) ==  3 ? 1 : -1];
+
+char bsrd_0[__bsrd(0x00000010) ==  4 ? 1 : -1];
+char bsrd_1[__bsrd(0x00100100) == 20 ? 1 : -1];
+
+char bsfq_0[__bsfq(0x0000000800000000ULL) == 35 ? 1 : -1];
+char bsfq_1[__bsfq(0x0004000000000000ULL) == 50 ? 1 : -1];
+
+char bsrq_0[__bsrq(0x0000100800000000ULL) == 44 ? 1 : -1];
+char bsrq_1[__bsrq(0x0004000100000000ULL) == 50 ? 1 : -1];
+
+#endif
diff --git a/clang/test/CodeGen/X86/popcnt-builtins.c b/clang/test/CodeGen/X86/popcnt-builtins.c
index e59ffaa031a6a10..b9bc666a1e28ad2 100644
--- a/clang/test/CodeGen/X86/popcnt-builtins.c
+++ b/clang/test/CodeGen/X86/popcnt-builtins.c
@@ -1,7 +1,5 @@
 // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
 // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
 
 #include <x86intrin.h>
 
diff --git a/clang/test/CodeGen/X86/popcnt-builtins.cpp b/clang/test/CodeGen/X86/popcnt-builtins.cpp
new file mode 100644
index 000000000000000..42996c547e0af9b
--- /dev/null
+++ b/clang/test/CodeGen/X86/popcnt-builtins.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +popcnt -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-POPCNT
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+
+#include <x86intrin.h>
+
+#ifdef __POPCNT__
+int test_mm_popcnt_u32(unsigned int __X) {
+  //CHECK-POPCNT: call noundef i32 @llvm.ctpop.i32
+  return _mm_popcnt_u32(__X);
+}
+#endif
+
+int test_popcnt32(unsigned int __X) {
+  //CHECK: call noundef i32 @llvm.ctpop.i32
+  return _popcnt32(__X);
+}
+
+int test__popcntd(unsigned int __X) {
+  //CHECK: call noundef i32 @llvm.ctpop.i32
+  return __popcntd(__X);
+}
+
+#ifdef __x86_64__
+#ifdef __POPCNT__
+long long test_mm_popcnt_u64(unsigned long long __X) {
+  //CHECK-POPCNT: call i64 @llvm.ctpop.i64
+  return _mm_popcnt_u64(__X);
+}
+#endif
+
+long long test_popcnt64(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return _popcnt64(__X);
+}
+
+long long test__popcntq(unsigned long long __X) {
+  //CHECK: call i64 @llvm.ctpop.i64
+  return __popcntq(__X);
+}
+#endif
+
+// Test constexpr handling.
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+#if defined(__POPCNT__)
+char ctpop32_0[_mm_popcnt_u32(0x00000000) == 0 ? 1 : -1];
+char ctpop32_1[_mm_popcnt_u32(0x000000F0) == 4 ? 1 : -1];
+#endif
+
+char popcnt32_0[_popcnt32(0x00000000) == 0 ? 1 : -1];
+char popcnt32_1[_popcnt32(0x100000F0) == 5 ? 1 : -1];
+
+char popcntd_0[__popcntd(0x00000000) == 0 ? 1 : -1];
+char popcntd_1[__popcntd(0x00F000F0) == 8 ? 1 : -1];
+
+#ifdef __x86_64__
+#if defined(__POPCNT__)
+char ctpop64_0[_mm_popcnt_u64(0x0000000000000000ULL) == 0 ? 1 : -1];
+char ctpop64_1[_mm_popcnt_u64(0xF000000000000001ULL) == 5 ? 1 : -1];
+#endif
+
+char popcnt64_0[_popcnt64(0x0000000000000000ULL) == 0 ? 1 : -1];
+char popcnt64_1[_popcnt64(0xF00000F000000001ULL) == 9 ? 1 : -1];
+
+char popcntq_0[__popcntq(0x0000000000000000ULL) == 0 ? 1 : -1];
+char popcntq_1[__popcntq(0xF000010000300001ULL) == 8 ? 1 : -1];
+#endif
+#endif
diff --git a/clang/test/CodeGen/X86/rot-intrinsics.c b/clang/test/CodeGen/X86/rot-intrinsics.c
index f8c78119a1c4a77..70bda329ce860c9 100644
--- a/clang/test/CodeGen/X86/rot-intrinsics.c
+++ b/clang/test/CodeGen/X86/rot-intrinsics.c
@@ -5,13 +5,6 @@
 // RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -x c -fms-extensions -fms-compatibility -fms-compatibility-version=17.00 -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding -triple i686--linux -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding -triple x86_64--linux -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
-// RUN: %clang_cc1 -x c++ -std=c++11 -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
-// RUN: %clang_cc1 -x c++ -std=c++11 -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
-// 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 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
-// 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 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
-
 #include <x86intrin.h>
 
 unsigned char test__rolb(unsigned char value, int shift) {
diff --git a/clang/test/CodeGen/X86/rot-intrinsics.cpp b/clang/test/CodeGen/X86/rot-intrinsics.cpp
new file mode 100644
index 000000000000000..90afa91f335e83d
--- /dev/null
+++ b/clang/test/CodeGen/X86/rot-intrinsics.cpp
@@ -0,0 +1,165 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding -triple i686--linux -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG-NO-COMPAT17
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding -triple x86_64--linux -emit-llvm %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
+// RUN: %clang_cc1 -x c++ -std=c++11 -fms-extensions -fms-compatibility -ffreestanding %s -triple=i686-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG-NO-COMPAT17
+// RUN: %clang_cc1 -x c++ -std=c++11 -fms-extensions -fms-compatibility -ffreestanding %s -triple=x86_64-windows-msvc -target-feature +sse2 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG-NO-COMPAT17
+// 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 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG-COMPAT17
+// 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 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG-COMPAT17
+
+#include <x86intrin.h>
+
+unsigned char test__rolb(unsigned char value, int shift) {
+// CHECK-LABEL: test__rolb
+// CHECK:   [[R:%.*]] = call noundef i8 @llvm.fshl.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
+// CHECK:   ret i8 [[R]]
+  return __rolb(value, shift);
+}
+
+unsigned short test__rolw(unsigned short value, int shift) {
+// CHECK-LABEL: test__rolw
+// CHECK:   [[R:%.*]] = call noundef i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
+// CHECK:   ret i16 [[R]]
+  return __rolw(value, shift);
+}
+
+unsigned int test__rold(unsigned int value, int shift) {
+// CHECK-LABEL: test__rold
+// CHECK:   [[R:%.*]] = call noundef i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK:   ret i32 [[R]]
+  return __rold(value, shift);
+}
+
+#if defined(__x86_64__)
+unsigned long test__rolq(unsigned long value, int shift) {
+// CHECK-LONG-LABEL: test__rolq
+// CHECK-LONG:   [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
+// CHECK-LONG:   ret i64 [[R]]
+  return __rolq(value, shift);
+}
+#endif
+
+unsigned char test__rorb(unsigned char value, int shift) {
+// CHECK-LABEL: test__rorb
+// CHECK:   [[R:%.*]] = call noundef i8 @llvm.fshr.i8(i8 [[X:%.*]], i8 [[X]], i8 [[Y:%.*]])
+// CHECK:   ret i8 [[R]]
+  return __rorb(value, shift);
+}
+
+unsigned short test__rorw(unsigned short value, int shift) {
+// CHECK-LABEL: test__rorw
+// CHECK:   [[R:%.*]] = call noundef i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
+// CHECK:   ret i16 [[R]]
+  return __rorw(value, shift);
+}
+
+unsigned int test__rord(unsigned int value, int shift) {
+// CHECK-LABEL: test__rord
+// CHECK:   [[R:%.*]] = call noundef i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK:   ret i32 [[R]]
+  return __rord(value, shift);
+}
+
+#if defined(__x86_64__)
+unsigned long test__rorq(unsigned long value, int shift) {
+// CHECK-LONG-LABEL: test__rorq
+// CHECK-LONG:   [[R:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
+// CHECK-LONG:   ret i64 [[R]]
+  return __rorq(value, shift);
+}
+#endif
+
+unsigned short test_rotwl(unsigned short value, int shift) {
+// CHECK-LABEL: test_rotwl
+// CHECK:   [[R:%.*]] = call noundef i16 @llvm.fshl.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
+// CHECK:   ret i16 [[R]]
+  return _rotwl(value, shift);
+}
+
+unsigned int test_rotl(unsigned int value, int shift) {
+// CHECK-32BIT-LONG-COMPAT17-LABEL: test_rotl
+// CHECK-32BIT-LONG-COMPAT17:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK-32BIT-LONG-COMPAT17:   ret i32 [[R]]
+//
+// CHECK-32BIT-LONG-NO-COMPAT17-LABEL: test_rotl
+// CHECK-32BIT-LONG-NO-COMPAT17:   [[R:%.*]] = call noundef i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK-32BIT-LONG-NO-COMPAT17:   ret i32 [[R]]
+  return _rotl(value, shift);
+}
+
+unsigned long test_lrotl(unsigned long value, int shift) {
+// CHECK-32BIT-LONG-COMPAT17-LABEL: test_lrotl
+// CHECK-32BIT-LONG-COMPAT17:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK-32BIT-LONG-COMPAT17:   ret i32 [[R]]
+//
+// CHECK-32BIT-LONG-NO-COMPAT17-LABEL: test_lrotl
+// CHECK-32BIT-LONG-NO-COMPAT17:   [[R:%.*]] = call noundef i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK-32BIT-LONG-NO-COMPAT17:   ret i32 [[R]]
+//
+// CHECK-64BIT-LONG-LABEL: test_lrotl
+// CHECK-64BIT-LONG:   [[R:%.*]] = call noundef i64 @llvm.fshl.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
+// CHECK-64BIT-LONG:   ret i64 [[R]]
+  return _lrotl(value, shift);
+}
+
+
+unsigned short test_rotwr(unsigned short value, int shift) {
+// CHECK-LABEL: test_rotwr
+// CHECK:   [[R:%.*]] = call noundef i16 @llvm.fshr.i16(i16 [[X:%.*]], i16 [[X]], i16 [[Y:%.*]])
+// CHECK:   ret i16 [[R]]
+  return _rotwr(value, shift);
+}
+
+unsigned int test_rotr(unsigned int value, int shift) {
+// CHECK-32BIT-LONG-COMPAT17-LABEL: test_rotr
+// CHECK-32BIT-LONG-COMPAT17:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK-32BIT-LONG-COMPAT17:   ret i32 [[R]]
+// CHECK-32BIT-LONG-NO-COMPAT17-LABEL: test_rotr
+// CHECK-32BIT-LONG-NO-COMPAT17:   [[R:%.*]] = call noundef i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK-32BIT-LONG-NO-COMPAT17:   ret i32 [[R]]
+  return _rotr(value, shift);
+}
+
+unsigned long test_lrotr(unsigned long value, int shift) {
+// CHECK-32BIT-LONG-COMPAT17-LABEL: test_lrotr
+// CHECK-32BIT-LONG-COMPAT17:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK-32BIT-LONG-COMPAT17:   ret i32 [[R]]
+//
+// CHECK-32BIT-LONG-NO-COMPAT17-LABEL: test_lrotr
+// CHECK-32BIT-LONG-NO-COMPAT17:   [[R:%.*]] = call noundef i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
+// CHECK-32BIT-LONG-NO-COMPAT17:   ret i32 [[R]]
+//
+// CHECK-64BIT-LONG-LABEL: test_lrotr
+// CHECK-64BIT-LONG:   [[R:%.*]] = call noundef i64 @llvm.fshr.i64(i64 [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
+// CHECK-64BIT-LONG:   ret i64 [[R]]
+  return _lrotr(value, shift);
+}
+
+// Test constexpr handling.
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+
+char rolb_0[__rolb(0x01, 5) == 0x20 ? 1 : -1];
+char rolw_0[__rolw(0x3210, 11) == 0x8190 ? 1 : -1];
+char rold_0[__rold(0x76543210, 22) == 0x841D950C ? 1 : -1];
+
+char rorb_0[__rorb(0x01, 5) == 0x08 ? 1 : -1];
+char rorw_0[__rorw(0x3210, 11) == 0x4206 ? 1 : -1];
+char rord_0[__rord(0x76543210, 22) == 0x50C841D9 ? 1 : -1];
+
+#if defined(__x86_64__)
+char rolq_0[__rolq(0xFEDCBA9876543210ULL, 55) == 0x087F6E5D4C3B2A19ULL ? 1 : -1];
+char rorq_0[__rorq(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL ? 1 : -1];
+#endif
+
+char rotwl_0[_rotwl(0x3210, 4) == 0x2103 ? 1 : -1];
+char rotwr_0[_rotwr(0x3210, 4) == 0x0321 ? 1 : -1];
+char rotl_0[_rotl(0x76543210, 8) == 0x54321076 ? 1 : -1];
+char rotr_0[_rotr(0x76543210, 8) == 0x10765432 ? 1 : -1];
+
+#if defined(__LP64__) && !defined(_MSC_VER)
+char lrotl_0[_lrotl(0xFEDCBA9876543210ULL, 55) == 0x087F6E5D4C3B2A19ULL ? 1 : -1];
+char lrotr_0[_lrotr(0xFEDCBA9876543210ULL, 55) == 0xB97530ECA86421FDULL ? 1 : -1];
+#else
+char lrotl_0[_lrotl(0x76543210, 22) == 0x841D950C ? 1 : -1];
+char lrotr_0[_lrotr(0x76543210, 22) == 0x50C841D9 ? 1 : -1];
+#endif
+
+#endif
diff --git a/clang/test/CodeGen/X86/x86-bswap.c b/clang/test/CodeGen/X86/x86-bswap.c
index fb4852c524087ed..7bc045f275d9513 100644
--- a/clang/test/CodeGen/X86/x86-bswap.c
+++ b/clang/test/CodeGen/X86/x86-bswap.c
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -x c -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
 
 #include <x86intrin.h>
 
diff --git a/clang/test/CodeGen/X86/x86-bswap.cpp b/clang/test/CodeGen/X86/x86-bswap.cpp
new file mode 100644
index 000000000000000..1ba573f3d2ba8f9
--- /dev/null
+++ b/clang/test/CodeGen/X86/x86-bswap.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -ffreestanding %s -triple=x86_64-apple-darwin -emit-llvm -o - | FileCheck %s
+
+#include <x86intrin.h>
+
+int test__bswapd(int X) {
+// CHECK-LABEL: test__bswapd
+// CHECK: call noundef i32 @llvm.bswap.i32
+  return __bswapd(X);
+}
+
+int test_bswap(int X) {
+// CHECK-LABEL: test_bswap
+// CHECK: call noundef i32 @llvm.bswap.i32
+  return _bswap(X);
+}
+
+long test__bswapq(long long X) {
+// CHECK-LABEL: test__bswapq
+// CHECK: call noundef i64 @llvm.bswap.i64
+  return __bswapq(X);
+}
+
+long test_bswap64(long long X) {
+// CHECK-LABEL: test_bswap64
+// CHECK: call noundef i64 @llvm.bswap.i64
+  return _bswap64(X);
+}
+
+// Test constexpr handling.
+#if defined(__cplusplus) && (__cplusplus >= 201103L)
+
+char bswapd_0[__bswapd(0x00000000) == 0x00000000 ? 1 : -1];
+char bswapd_1[__bswapd(0x01020304) == 0x04030201 ? 1 : -1];
+
+char bswap_0[_bswap(0x00000000) == 0x00000000 ? 1 : -1];
+char bswap_1[_bswap(0x10203040) == 0x40302010 ? 1 : -1];
+
+char bswapq_0[__bswapq(0x0000000000000000ULL) == 0x0000000000000000 ? 1 : -1];
+char bswapq_1[__bswapq(0x0102030405060708ULL) == 0x0807060504030201 ? 1 : -1];
+
+char bswap64_0[_bswap64(0x0000000000000000ULL) == 0x0000000000000000 ? 1 : -1];
+char bswap64_1[_bswap64(0x1020304050607080ULL) == 0x8070605040302010 ? 1 : -1];
+
+#endif
diff --git a/clang/test/CodeGen/aarch64-ls64.c b/clang/test/CodeGen/aarch64-ls64.c
index 39def71d71c7b0c..8a61a9643dd3dee 100644
--- a/clang/test/CodeGen/aarch64-ls64.c
+++ b/clang/test/CodeGen/aarch64-ls64.c
@@ -206,7 +206,7 @@ EXTERN_C void test_st64b(void)
 // CHECK-CXX-NEXT:    [[TMP14:%.*]] = load i64, ptr [[TMP13]], align 8
 // CHECK-CXX-NEXT:    [[TMP15:%.*]] = getelementptr i64, ptr [[AGG_TMP]], i32 7
 // CHECK-CXX-NEXT:    [[TMP16:%.*]] = load i64, ptr [[TMP15]], align 8
-// CHECK-CXX-NEXT:    [[TMP17:%.*]] = call i64 @llvm.aarch64.st64bv(ptr [[TMP1]], i64 [[TMP2]], i64 [[TMP4]], i64 [[TMP6]], i64 [[TMP8]], i64 [[TMP10]], i64 [[TMP12]], i64 [[TMP14]], i64 [[TMP16]])
+// CHECK-CXX-NEXT:    [[TMP17:%.*]] = call noundef i64 @llvm.aarch64.st64bv(ptr [[TMP1]], i64 [[TMP2]], i64 [[TMP4]], i64 [[TMP6]], i64 [[TMP8]], i64 [[TMP10]], i64 [[TMP12]], i64 [[TMP14]], i64 [[TMP16]])
 // CHECK-CXX-NEXT:    store i64 [[TMP17]], ptr @status, align 8
 // CHECK-CXX-NEXT:    ret void
 //
@@ -269,7 +269,7 @@ EXTERN_C void test_st64bv(void)
 // CHECK-CXX-NEXT:    [[TMP14:%.*]] = load i64, ptr [[TMP13]], align 8
 // CHECK-CXX-NEXT:    [[TMP15:%.*]] = getelementptr i64, ptr [[AGG_TMP]], i32 7
 // CHECK-CXX-NEXT:    [[TMP16:%.*]] = load i64, ptr [[TMP15]], align 8
-// CHECK-CXX-NEXT:    [[TMP17:%.*]] = call i64 @llvm.aarch64.st64bv0(ptr [[TMP1]], i64 [[TMP2]], i64 [[TMP4]], i64 [[TMP6]], i64 [[TMP8]], i64 [[TMP10]], i64 [[TMP12]], i64 [[TMP14]], i64 [[TMP16]])
+// CHECK-CXX-NEXT:    [[TMP17:%.*]] = call noundef i64 @llvm.aarch64.st64bv0(ptr [[TMP1]], i64 [[TMP2]], i64 [[TMP4]], i64 [[TMP6]], i64 [[TMP8]], i64 [[TMP10]], i64 [[TMP12]], i64 [[TMP14]], i64 [[TMP16]])
 // CHECK-CXX-NEXT:    store i64 [[TMP17]], ptr @status, align 8
 // CHECK-CXX-NEXT:    ret void
 //
diff --git a/clang/test/CodeGen/fp-contract-fast-pragma.cpp b/clang/test/CodeGen/fp-contract-fast-pragma.cpp
index a88ddac4037bb63..0bb01d6e17a1d6d 100644
--- a/clang/t...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/67756


More information about the cfe-commits mailing list