Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc < %s -mtriple arm-eabi -mattr=+v6t2 | FileCheck %s
      2 ; RUN: llc < %s -mtriple arm-eabi -mattr=+v6t2 -mattr=+neon | FileCheck %s
      3 
      4 ; This test checks the @llvm.cttz.* intrinsics for integers.
      5 
      6 declare i8 @llvm.cttz.i8(i8, i1)
      7 declare i16 @llvm.cttz.i16(i16, i1)
      8 declare i32 @llvm.cttz.i32(i32, i1)
      9 declare i64 @llvm.cttz.i64(i64, i1)
     10 
     11 ;------------------------------------------------------------------------------
     12 
     13 define i8 @test_i8(i8 %a) {
     14 ; CHECK-LABEL: test_i8:
     15 ; CHECK: orr [[REG:r[0-9]+]], [[REG]], #256
     16 ; CHECK: rbit
     17 ; CHECK: clz
     18   %tmp = call i8 @llvm.cttz.i8(i8 %a, i1 false)
     19   ret i8 %tmp
     20 }
     21 
     22 define i16 @test_i16(i16 %a) {
     23 ; CHECK-LABEL: test_i16:
     24 ; CHECK: orr [[REG:r[0-9]+]], [[REG]], #65536
     25 ; CHECK: rbit
     26 ; CHECK: clz
     27   %tmp = call i16 @llvm.cttz.i16(i16 %a, i1 false)
     28   ret i16 %tmp
     29 }
     30 
     31 define i32 @test_i32(i32 %a) {
     32 ; CHECK-LABEL: test_i32:
     33 ; CHECK: rbit
     34 ; CHECK: clz
     35   %tmp = call i32 @llvm.cttz.i32(i32 %a, i1 false)
     36   ret i32 %tmp
     37 }
     38 
     39 define i64 @test_i64(i64 %a) {
     40 ; CHECK-LABEL: test_i64:
     41 ; CHECK: rbit
     42 ; CHECK: rbit
     43 ; CHECK: cmp
     44 ; CHECK: clz
     45 ; CHECK: add
     46 ; CHECK: clzne
     47   %tmp = call i64 @llvm.cttz.i64(i64 %a, i1 false)
     48   ret i64 %tmp
     49 }
     50 
     51 ;------------------------------------------------------------------------------
     52 
     53 define i8 @test_i8_zero_undef(i8 %a) {
     54 ; CHECK-LABEL: test_i8_zero_undef:
     55 ; CHECK-NOT: orr
     56 ; CHECK: rbit
     57 ; CHECK: clz
     58   %tmp = call i8 @llvm.cttz.i8(i8 %a, i1 true)
     59   ret i8 %tmp
     60 }
     61 
     62 define i16 @test_i16_zero_undef(i16 %a) {
     63 ; CHECK-LABEL: test_i16_zero_undef:
     64 ; CHECK-NOT: orr
     65 ; CHECK: rbit
     66 ; CHECK: clz
     67   %tmp = call i16 @llvm.cttz.i16(i16 %a, i1 true)
     68   ret i16 %tmp
     69 }
     70 
     71 
     72 define i32 @test_i32_zero_undef(i32 %a) {
     73 ; CHECK-LABEL: test_i32_zero_undef:
     74 ; CHECK: rbit
     75 ; CHECK: clz
     76   %tmp = call i32 @llvm.cttz.i32(i32 %a, i1 true)
     77   ret i32 %tmp
     78 }
     79 
     80 define i64 @test_i64_zero_undef(i64 %a) {
     81 ; CHECK-LABEL: test_i64_zero_undef:
     82 ; CHECK: rbit
     83 ; CHECK: rbit
     84 ; CHECK: cmp
     85 ; CHECK: clz
     86 ; CHECK: add
     87 ; CHECK: clzne
     88   %tmp = call i64 @llvm.cttz.i64(i64 %a, i1 true)
     89   ret i64 %tmp
     90 }
     91