Home | History | Annotate | Download | only in ARM
      1 ; RUN: llc < %s -march=arm | FileCheck -check-prefix=ARM %s
      2 ; RUN: llc < %s -march=thumb | FileCheck -check-prefix=THUMB %s
      3 ; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck -check-prefix=T2 %s
      4 
      5 ; FIXME: The -march=thumb test doesn't change if -disable-peephole is specified.
      6 
      7 %struct.Foo = type { i8* }
      8 
      9 ; ARM:   foo
     10 ; THUMB: foo
     11 ; T2:    foo
     12 define %struct.Foo* @foo(%struct.Foo* %this, i32 %acc) nounwind readonly align 2 {
     13 entry:
     14   %scevgep = getelementptr %struct.Foo* %this, i32 1
     15   br label %tailrecurse
     16 
     17 tailrecurse:                                      ; preds = %sw.bb, %entry
     18   %lsr.iv2 = phi %struct.Foo* [ %scevgep3, %sw.bb ], [ %scevgep, %entry ]
     19   %lsr.iv = phi i32 [ %lsr.iv.next, %sw.bb ], [ 1, %entry ]
     20   %acc.tr = phi i32 [ %or, %sw.bb ], [ %acc, %entry ]
     21   %lsr.iv24 = bitcast %struct.Foo* %lsr.iv2 to i8**
     22   %scevgep5 = getelementptr i8** %lsr.iv24, i32 -1
     23   %tmp2 = load i8** %scevgep5
     24   %0 = ptrtoint i8* %tmp2 to i32
     25 
     26 ; ARM:      ands {{r[0-9]+}}, {{r[0-9]+}}, #3
     27 ; ARM-NEXT: beq
     28 
     29 ; THUMB:      movs r[[R0:[0-9]+]], #3
     30 ; THUMB-NEXT: ands r[[R0]], r
     31 ; THUMB-NEXT: cmp r[[R0]], #0
     32 ; THUMB-NEXT: beq
     33 
     34 ; T2:      ands {{r[0-9]+}}, {{r[0-9]+}}, #3
     35 ; T2-NEXT: beq
     36 
     37   %and = and i32 %0, 3
     38   %tst = icmp eq i32 %and, 0
     39   br i1 %tst, label %sw.bb, label %tailrecurse.switch
     40 
     41 tailrecurse.switch:                               ; preds = %tailrecurse
     42   switch i32 %and, label %sw.epilog [
     43     i32 1, label %sw.bb
     44     i32 3, label %sw.bb6
     45     i32 2, label %sw.bb8
     46   ]
     47 
     48 sw.bb:                                            ; preds = %tailrecurse.switch, %tailrecurse
     49   %shl = shl i32 %acc.tr, 1
     50   %or = or i32 %and, %shl
     51   %lsr.iv.next = add i32 %lsr.iv, 1
     52   %scevgep3 = getelementptr %struct.Foo* %lsr.iv2, i32 1
     53   br label %tailrecurse
     54 
     55 sw.bb6:                                           ; preds = %tailrecurse.switch
     56   ret %struct.Foo* %lsr.iv2
     57 
     58 sw.bb8:                                           ; preds = %tailrecurse.switch
     59   %tmp1 = add i32 %acc.tr, %lsr.iv
     60   %add.ptr11 = getelementptr inbounds %struct.Foo* %this, i32 %tmp1
     61   ret %struct.Foo* %add.ptr11
     62 
     63 sw.epilog:                                        ; preds = %tailrecurse.switch
     64   ret %struct.Foo* undef
     65 }
     66 
     67 ; Another test that exercises the AND/TST peephole optimization and also
     68 ; generates a predicated ANDS instruction. Check that the predicate is printed
     69 ; after the "S" modifier on the instruction.
     70 
     71 %struct.S = type { i8* (i8*)*, [1 x i8] }
     72 
     73 ; ARM: bar
     74 ; THUMB: bar
     75 ; T2: bar
     76 define internal zeroext i8 @bar(%struct.S* %x, %struct.S* nocapture %y) nounwind readonly {
     77 entry:
     78   %0 = getelementptr inbounds %struct.S* %x, i32 0, i32 1, i32 0
     79   %1 = load i8* %0, align 1
     80   %2 = zext i8 %1 to i32
     81 ; ARM: ands
     82 ; THUMB: ands
     83 ; T2: ands
     84   %3 = and i32 %2, 112
     85   %4 = icmp eq i32 %3, 0
     86   br i1 %4, label %return, label %bb
     87 
     88 bb:                                               ; preds = %entry
     89   %5 = getelementptr inbounds %struct.S* %y, i32 0, i32 1, i32 0
     90   %6 = load i8* %5, align 1
     91   %7 = zext i8 %6 to i32
     92 ; ARM: andsne
     93 ; THUMB: ands
     94 ; T2: andsne
     95   %8 = and i32 %7, 112
     96   %9 = icmp eq i32 %8, 0
     97   br i1 %9, label %return, label %bb2
     98 
     99 bb2:                                              ; preds = %bb
    100   %10 = icmp eq i32 %3, 16
    101   %11 = icmp eq i32 %8, 16
    102   %or.cond = or i1 %10, %11
    103   br i1 %or.cond, label %bb4, label %return
    104 
    105 bb4:                                              ; preds = %bb2
    106   %12 = ptrtoint %struct.S* %x to i32
    107   %phitmp = trunc i32 %12 to i8
    108   ret i8 %phitmp
    109 
    110 return:                                           ; preds = %bb2, %bb, %entry
    111   ret i8 1
    112 }
    113