[clang] inliner attrs (PR #66036)

via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 11 17:30:28 PDT 2023


llvmbot wrote:

@llvm/pr-subscribers-clang

<details>
<summary>Changes</summary>

- Add some additional tests for progagating attributes before inlining; NFC
- Regen checks for old test; NFC
- Split some tests for c/cpp; NFC
- Use "best" ret attribute when propagating attributes during inlining
- Also propagate `noundef` and `align` ret attributes during inlining
- Propagate callee function memory access attributes before inlining
- Propagate callee argument memory access attributes before inlining
- Propagate some additional callee argument attributes before inlining
- Propagate some callee function attributes to callsites before inlining

--

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

45 Files Affected:

- (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c (+9-9) 
- (modified) clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c (+4-4) 
- (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 (+3-3) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp (+5-5) 
- (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) clang/test/OpenMP/bug57757.cpp (+1-1) 
- (modified) llvm/include/llvm/Support/ModRef.h (+7) 
- (modified) llvm/lib/Transforms/Utils/InlineFunction.cpp (+187) 
- (added) llvm/test/Transforms/Inline/access-attributes-prop.ll (+498) 
- (modified) llvm/test/Transforms/Inline/assumptions-from-callsite-attrs.ll (+1-1) 
- (modified) llvm/test/Transforms/Inline/byval.ll (+122-73) 
- (modified) llvm/test/Transforms/Inline/memprof_inline.ll (+2-2) 
- (modified) llvm/test/Transforms/Inline/noalias-calls-always.ll (+6-6) 
- (modified) llvm/test/Transforms/Inline/noalias-calls.ll (+10-10) 
- (added) llvm/test/Transforms/Inline/ret_attr_align_and_noundef.ll (+171) 
- (modified) llvm/test/Transforms/Inline/ret_attr_update.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/norepeated-icp-3.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/norepeated-icp-4.ll (+1-1) 
- (modified) llvm/test/Transforms/SampleProfile/uniqname.ll (+3-3) 


<pre>
diff --git a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
index 44f8cbe2cc01739..642b08ac68ef122 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
@@ -636,31 +636,31 @@ void test_core(void) {
   // CHECK-ASM: vlbb
 
   vsc = vec_load_len(cptrsc, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vuc = vec_load_len(cptruc, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vss = vec_load_len(cptrss, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vus = vec_load_len(cptrus, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vsi = vec_load_len(cptrsi, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vui = vec_load_len(cptrui, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vsl = vec_load_len(cptrsl, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vul = vec_load_len(cptrul, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vd = vec_load_len(cptrd, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
 
   vec_store_len(vsc, ptrsc, idx);
diff --git a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
index 416ca0ddd1b4fe2..3f02565dfb488ce 100644
--- a/clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
+++ b/clang/test/CodeGen/SystemZ/builtins-systemz-zvector2.c
@@ -207,10 +207,10 @@ void test_core(void) {
   // CHECK-ASM: vlbb
 
   vf = vec_load_len(cptrf, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
   vd = vec_load_len(cptrd, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vll(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vll
 
   vec_store_len(vf, ptrf, idx);
@@ -221,10 +221,10 @@ void test_core(void) {
   // CHECK-ASM: vstl
 
   vuc = vec_load_len_r(cptruc, 0);
-  // CHECK: call <16 x i8> @llvm.s390.vlrl(i32 0, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vlrl(i32 0, ptr readonly %{{.*}})
   // CHECK-ASM: vlrl %{{.*}}, 0(%{{.*}}), 0
   vuc = vec_load_len_r(cptruc, idx);
-  // CHECK: call <16 x i8> @llvm.s390.vlrl(i32 %{{.*}}, ptr %{{.*}})
+  // CHECK: call <16 x i8> @llvm.s390.vlrl(i32 %{{.*}}, ptr readonly %{{.*}})
   // CHECK-ASM: vlrlr
 
   vec_store_len_r(vuc, ptruc, 0);
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_ro...
<truncated>
</pre>

</details>

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


More information about the cfe-commits mailing list