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