summaryrefslogtreecommitdiffstats
path: root/test/CodeGen/x86-bswap.c
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-03-24 00:56:52 +0000
committerCraig Topper <craig.topper@intel.com>2019-03-24 00:56:52 +0000
commit8a55120a7d72bed6c93749e0a6dbd0a2fcd873dd (patch)
treead93f7270a7441416dce8a450e53217e39331220 /test/CodeGen/x86-bswap.c
parentb4bcb2930e135762b2820fe85ba4a8cb65e431be (diff)
[X86] Add BSR/BSF/BSWAP intrinsics to ia32intrin.h to match gcc.
Summary: These are all implemented by icc as well. I made bit_scan_forward/reverse forward to the __bsfd/__bsrq since we also have __bsfq/__bsrq. Note, when lzcnt is enabled the bsr intrinsics generates lzcnt+xor instead of bsr. Reviewers: RKSimon, spatel Subscribers: cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59682 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@356848 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/x86-bswap.c')
-rw-r--r--test/CodeGen/x86-bswap.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/CodeGen/x86-bswap.c b/test/CodeGen/x86-bswap.c
new file mode 100644
index 0000000000..adf8b7846a
--- /dev/null
+++ b/test/CodeGen/x86-bswap.c
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -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 i32 @llvm.bswap.i32
+ return __bswapd(X);
+}
+
+int test_bswap(int X) {
+// CHECK-LABEL: @test_bswap
+// CHECK: call i32 @llvm.bswap.i32
+ return _bswap(X);
+}
+
+long test__bswapq(long long X) {
+// CHECK-LABEL: @test__bswapq
+// CHECK: call i64 @llvm.bswap.i64
+ return __bswapq(X);
+}
+
+long test_bswap64(long long X) {
+// CHECK-LABEL: @test_bswap64
+// CHECK: call i64 @llvm.bswap.i64
+ return _bswap64(X);
+}
+
+