Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +bmi -emit-llvm -o - | FileCheck %s |
Craig Topper | 5c75208 | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 2 | |
| 3 | // Don't include mm_malloc.h, it's system specific. |
| 4 | #define __MM_MALLOC_H |
| 5 | |
| 6 | #include <x86intrin.h> |
| 7 | |
Craig Topper | 435d268 | 2012-07-02 06:52:51 +0000 | [diff] [blame] | 8 | unsigned short test__tzcnt_u16(unsigned short __X) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 9 | // CHECK: @llvm.cttz.i16 |
Craig Topper | 435d268 | 2012-07-02 06:52:51 +0000 | [diff] [blame] | 10 | return __tzcnt_u16(__X); |
Craig Topper | 5c75208 | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 11 | } |
| 12 | |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 13 | unsigned int test__andn_u32(unsigned int __X, unsigned int __Y) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 14 | // CHECK: [[DEST:%.*]] = xor i32 %{{.*}}, -1 |
| 15 | // CHECK-NEXT: %{{.*}} = and i32 %{{.*}}, [[DEST]] |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 16 | return __andn_u32(__X, __Y); |
| 17 | } |
| 18 | |
| 19 | unsigned int test__bextr_u32(unsigned int __X, unsigned int __Y) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 20 | // CHECK: @llvm.x86.bmi.bextr.32 |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 21 | return __bextr_u32(__X, __Y); |
| 22 | } |
| 23 | |
| 24 | unsigned int test__blsi_u32(unsigned int __X) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 25 | // CHECK: [[DEST:%.*]] = sub i32 0, [[SRC:%.*]] |
| 26 | // CHECK-NEXT: %{{.*}} = and i32 [[SRC]], [[DEST]] |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 27 | return __blsi_u32(__X); |
| 28 | } |
| 29 | |
| 30 | unsigned int test__blsmsk_u32(unsigned int __X) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 31 | // CHECK: [[DEST:%.*]] = add i32 [[SRC:%.*]], -1 |
| 32 | // CHECK-NEXT: %{{.*}} = xor i32 [[DEST]], [[SRC]] |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 33 | return __blsmsk_u32(__X); |
| 34 | } |
| 35 | |
| 36 | unsigned int test__blsr_u32(unsigned int __X) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 37 | // CHECK: [[DEST:%.*]] = add i32 [[SRC:%.*]], -1 |
| 38 | // CHECK-NEXT: %{{.*}} = and i32 [[DEST]], [[SRC]] |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 39 | return __blsr_u32(__X); |
| 40 | } |
| 41 | |
Craig Topper | 435d268 | 2012-07-02 06:52:51 +0000 | [diff] [blame] | 42 | unsigned int test_tzcnt_u32(unsigned int __X) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 43 | // CHECK: @llvm.cttz.i32 |
Craig Topper | 435d268 | 2012-07-02 06:52:51 +0000 | [diff] [blame] | 44 | return __tzcnt_u32(__X); |
Craig Topper | 5c75208 | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 45 | } |
| 46 | |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 47 | unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 48 | // CHECK: [[DEST:%.*]] = xor i64 %{{.*}}, -1 |
| 49 | // CHECK-NEXT: %{{.*}} = and i64 %{{.*}}, [[DEST]] |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 50 | return __andn_u64(__X, __Y); |
| 51 | } |
| 52 | |
| 53 | unsigned long long test__bextr_u64(unsigned long __X, unsigned long __Y) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 54 | // CHECK: @llvm.x86.bmi.bextr.64 |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 55 | return __bextr_u64(__X, __Y); |
| 56 | } |
| 57 | |
| 58 | unsigned long long test__blsi_u64(unsigned long long __X) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 59 | // CHECK: [[DEST:%.*]] = sub i64 0, [[SRC:%.*]] |
| 60 | // CHECK-NEXT: %{{.*}} = and i64 [[SRC]], [[DEST]] |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 61 | return __blsi_u64(__X); |
| 62 | } |
| 63 | |
| 64 | unsigned long long test__blsmsk_u64(unsigned long long __X) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 65 | // CHECK: [[DEST:%.*]] = add i64 [[SRC:%.*]], -1 |
| 66 | // CHECK-NEXT: %{{.*}} = xor i64 [[DEST]], [[SRC]] |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 67 | return __blsmsk_u64(__X); |
| 68 | } |
| 69 | |
| 70 | unsigned long long test__blsr_u64(unsigned long long __X) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 71 | // CHECK: [[DEST:%.*]] = add i64 [[SRC:%.*]], -1 |
| 72 | // CHECK-NEXT: %{{.*}} = and i64 [[DEST]], [[SRC]] |
Craig Topper | 0b269c1 | 2011-12-25 07:27:12 +0000 | [diff] [blame] | 73 | return __blsr_u64(__X); |
| 74 | } |
| 75 | |
Craig Topper | 435d268 | 2012-07-02 06:52:51 +0000 | [diff] [blame] | 76 | unsigned long long test__tzcnt_u64(unsigned long long __X) { |
Craig Topper | 19b4a71 | 2011-12-25 15:20:31 +0000 | [diff] [blame] | 77 | // CHECK: @llvm.cttz.i64 |
Craig Topper | 435d268 | 2012-07-02 06:52:51 +0000 | [diff] [blame] | 78 | return __tzcnt_u64(__X); |
Craig Topper | 5c75208 | 2011-12-25 06:25:37 +0000 | [diff] [blame] | 79 | } |