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
5 ; FIXME: The -march=thumb test doesn't change if -disable-peephole is specified.
7 %struct.Foo = type { i8* }
12 define %struct.Foo* @foo(%struct.Foo* %this, i32 %acc) nounwind readonly align 2 {
14 %scevgep = getelementptr %struct.Foo* %this, i32 1
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
26 ; ARM: ands r12, r12, #3
29 ; THUMB: movs r[[R0:[0-9]+]], #3
30 ; THUMB-NEXT: ands r[[R0]], r
31 ; THUMB-NEXT: cmp r[[R0]], #0
34 ; T2: ands r12, r12, #3
38 %tst = icmp eq i32 %and, 0
39 br i1 %tst, label %sw.bb, label %tailrecurse.switch
41 tailrecurse.switch: ; preds = %tailrecurse
42 switch i32 %and, label %sw.epilog [
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
55 sw.bb6: ; preds = %tailrecurse.switch
56 ret %struct.Foo* %lsr.iv2
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
63 sw.epilog: ; preds = %tailrecurse.switch
64 ret %struct.Foo* undef
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.
71 %struct.S = type { i8* (i8*)*, [1 x i8] }
76 define internal zeroext i8 @bar(%struct.S* %x, %struct.S* nocapture %y) nounwind readonly {
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
85 %4 = icmp eq i32 %3, 0
86 br i1 %4, label %return, label %bb
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
96 %9 = icmp eq i32 %8, 0
97 br i1 %9, label %return, label %bb2
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
106 %12 = ptrtoint %struct.S* %x to i32
107 %phitmp = trunc i32 %12 to i8
110 return: ; preds = %bb2, %bb, %entry