Home | History | Annotate | Download | only in AArch64
      1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s
      2 
      3 @var32 = global i32 0
      4 @var64 = global i64 0
      5 
      6 define void @rev_i32() {
      7 ; CHECK-LABEL: rev_i32:
      8     %val0_tmp = load i32* @var32
      9     %val1_tmp = call i32 @llvm.bswap.i32(i32 %val0_tmp)
     10 ; CHECK: rev	{{w[0-9]+}}, {{w[0-9]+}}
     11     store volatile i32 %val1_tmp, i32* @var32
     12     ret void
     13 }
     14 
     15 define void @rev_i64() {
     16 ; CHECK-LABEL: rev_i64:
     17     %val0_tmp = load i64* @var64
     18     %val1_tmp = call i64 @llvm.bswap.i64(i64 %val0_tmp)
     19 ; CHECK: rev	{{x[0-9]+}}, {{x[0-9]+}}
     20     store volatile i64 %val1_tmp, i64* @var64
     21     ret void
     22 }
     23 
     24 define void @rev32_i64() {
     25 ; CHECK-LABEL: rev32_i64:
     26     %val0_tmp = load i64* @var64
     27     %val1_tmp = shl i64 %val0_tmp, 32
     28     %val5_tmp = sub i64 64, 32
     29     %val2_tmp = lshr i64 %val0_tmp, %val5_tmp
     30     %val3_tmp = or i64 %val1_tmp, %val2_tmp
     31     %val4_tmp = call i64 @llvm.bswap.i64(i64 %val3_tmp)
     32 ; CHECK: rev32	{{x[0-9]+}}, {{x[0-9]+}}
     33     store volatile i64 %val4_tmp, i64* @var64
     34     ret void
     35 }
     36 
     37 define void @rev16_i32() {
     38 ; CHECK-LABEL: rev16_i32:
     39     %val0_tmp = load i32* @var32
     40     %val1_tmp = shl i32 %val0_tmp, 16
     41     %val2_tmp = lshr i32 %val0_tmp, 16
     42     %val3_tmp = or i32 %val1_tmp, %val2_tmp
     43     %val4_tmp = call i32 @llvm.bswap.i32(i32 %val3_tmp)
     44 ; CHECK: rev16	{{w[0-9]+}}, {{w[0-9]+}}
     45     store volatile i32 %val4_tmp, i32* @var32
     46     ret void
     47 }
     48 
     49 define void @clz_zerodef_i32() {
     50 ; CHECK-LABEL: clz_zerodef_i32:
     51     %val0_tmp = load i32* @var32
     52     %val4_tmp = call i32 @llvm.ctlz.i32(i32 %val0_tmp, i1 0)
     53 ; CHECK: clz	{{w[0-9]+}}, {{w[0-9]+}}
     54     store volatile i32 %val4_tmp, i32* @var32
     55     ret void
     56 }
     57 
     58 define void @clz_zerodef_i64() {
     59 ; CHECK-LABEL: clz_zerodef_i64:
     60     %val0_tmp = load i64* @var64
     61     %val4_tmp = call i64 @llvm.ctlz.i64(i64 %val0_tmp, i1 0)
     62 ; CHECK: clz	{{x[0-9]+}}, {{x[0-9]+}}
     63     store volatile i64 %val4_tmp, i64* @var64
     64     ret void
     65 }
     66 
     67 define void @clz_zeroundef_i32() {
     68 ; CHECK-LABEL: clz_zeroundef_i32:
     69     %val0_tmp = load i32* @var32
     70     %val4_tmp = call i32 @llvm.ctlz.i32(i32 %val0_tmp, i1 1)
     71 ; CHECK: clz	{{w[0-9]+}}, {{w[0-9]+}}
     72     store volatile i32 %val4_tmp, i32* @var32
     73     ret void
     74 }
     75 
     76 define void @clz_zeroundef_i64() {
     77 ; CHECK-LABEL: clz_zeroundef_i64:
     78     %val0_tmp = load i64* @var64
     79     %val4_tmp = call i64 @llvm.ctlz.i64(i64 %val0_tmp, i1 1)
     80 ; CHECK: clz	{{x[0-9]+}}, {{x[0-9]+}}
     81     store volatile i64 %val4_tmp, i64* @var64
     82     ret void
     83 }
     84 
     85 define void @cttz_zerodef_i32() {
     86 ; CHECK-LABEL: cttz_zerodef_i32:
     87     %val0_tmp = load i32* @var32
     88     %val4_tmp = call i32 @llvm.cttz.i32(i32 %val0_tmp, i1 0)
     89 ; CHECK: rbit   [[REVERSED:w[0-9]+]], {{w[0-9]+}}
     90 ; CHECK: clz	{{w[0-9]+}}, [[REVERSED]]
     91     store volatile i32 %val4_tmp, i32* @var32
     92     ret void
     93 }
     94 
     95 define void @cttz_zerodef_i64() {
     96 ; CHECK-LABEL: cttz_zerodef_i64:
     97     %val0_tmp = load i64* @var64
     98     %val4_tmp = call i64 @llvm.cttz.i64(i64 %val0_tmp, i1 0)
     99 ; CHECK: rbit   [[REVERSED:x[0-9]+]], {{x[0-9]+}}
    100 ; CHECK: clz	{{x[0-9]+}}, [[REVERSED]]
    101     store volatile i64 %val4_tmp, i64* @var64
    102     ret void
    103 }
    104 
    105 define void @cttz_zeroundef_i32() {
    106 ; CHECK-LABEL: cttz_zeroundef_i32:
    107     %val0_tmp = load i32* @var32
    108     %val4_tmp = call i32 @llvm.cttz.i32(i32 %val0_tmp, i1 1)
    109 ; CHECK: rbit   [[REVERSED:w[0-9]+]], {{w[0-9]+}}
    110 ; CHECK: clz	{{w[0-9]+}}, [[REVERSED]]
    111     store volatile i32 %val4_tmp, i32* @var32
    112     ret void
    113 }
    114 
    115 define void @cttz_zeroundef_i64() {
    116 ; CHECK-LABEL: cttz_zeroundef_i64:
    117     %val0_tmp = load i64* @var64
    118     %val4_tmp = call i64 @llvm.cttz.i64(i64 %val0_tmp, i1 1)
    119 ; CHECK: rbit   [[REVERSED:x[0-9]+]], {{x[0-9]+}}
    120 ; CHECK: clz	{{x[0-9]+}}, [[REVERSED]]
    121     store volatile i64 %val4_tmp, i64* @var64
    122     ret void
    123 }
    124 
    125 ; These two are just compilation tests really: the operation's set to Expand in
    126 ; ISelLowering.
    127 define void @ctpop_i32() {
    128 ; CHECK-LABEL: ctpop_i32:
    129     %val0_tmp = load i32* @var32
    130     %val4_tmp = call i32 @llvm.ctpop.i32(i32 %val0_tmp)
    131     store volatile i32 %val4_tmp, i32* @var32
    132     ret void
    133 }
    134 
    135 define void @ctpop_i64() {
    136 ; CHECK-LABEL: ctpop_i64:
    137     %val0_tmp = load i64* @var64
    138     %val4_tmp = call i64 @llvm.ctpop.i64(i64 %val0_tmp)
    139     store volatile i64 %val4_tmp, i64* @var64
    140     ret void
    141 }
    142 
    143 
    144 declare i32 @llvm.bswap.i32(i32)
    145 declare i64 @llvm.bswap.i64(i64)
    146 declare i32  @llvm.ctlz.i32 (i32, i1)
    147 declare i64  @llvm.ctlz.i64 (i64, i1)
    148 declare i32  @llvm.cttz.i32 (i32, i1)
    149 declare i64  @llvm.cttz.i64 (i64, i1)
    150 declare i32  @llvm.ctpop.i32 (i32)
    151 declare i64  @llvm.ctpop.i64 (i64)
    152 
    153