From 8a55120a7d72bed6c93749e0a6dbd0a2fcd873dd Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sun, 24 Mar 2019 00:56:52 +0000 Subject: [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 --- test/CodeGen/x86-bswap.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/CodeGen/x86-bswap.c (limited to 'test/CodeGen/x86-bswap.c') 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 + +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); +} + + -- cgit v1.2.3