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
30 ; THUMB-NEXT: mov r6, r4
31 ; THUMB-NEXT: ands r6, r5
32 ; THUMB-NEXT: tst r4, r5
35 ; T2: ands r12, r12, #3
39 %tst = icmp eq i32 %and, 0
40 br i1 %tst, label %sw.bb, label %tailrecurse.switch
42 tailrecurse.switch: ; preds = %tailrecurse
43 switch i32 %and, label %sw.epilog [
49 sw.bb: ; preds = %tailrecurse.switch, %tailrecurse
50 %shl = shl i32 %acc.tr, 1
51 %or = or i32 %and, %shl
52 %lsr.iv.next = add i32 %lsr.iv, 1
53 %scevgep3 = getelementptr %struct.Foo* %lsr.iv2, i32 1
56 sw.bb6: ; preds = %tailrecurse.switch
57 ret %struct.Foo* %lsr.iv2
59 sw.bb8: ; preds = %tailrecurse.switch
60 %tmp1 = add i32 %acc.tr, %lsr.iv
61 %add.ptr11 = getelementptr inbounds %struct.Foo* %this, i32 %tmp1
62 ret %struct.Foo* %add.ptr11
64 sw.epilog: ; preds = %tailrecurse.switch
65 ret %struct.Foo* undef
68 ; Another test that exercises the AND/TST peephole optimization and also
69 ; generates a predicated ANDS instruction. Check that the predicate is printed
70 ; after the "S" modifier on the instruction.
72 %struct.S = type { i8* (i8*)*, [1 x i8] }
77 define internal zeroext i8 @bar(%struct.S* %x, %struct.S* nocapture %y) nounwind readonly {
79 %0 = getelementptr inbounds %struct.S* %x, i32 0, i32 1, i32 0
80 %1 = load i8* %0, align 1
81 %2 = zext i8 %1 to i32
86 %4 = icmp eq i32 %3, 0
87 br i1 %4, label %return, label %bb
90 %5 = getelementptr inbounds %struct.S* %y, i32 0, i32 1, i32 0
91 %6 = load i8* %5, align 1
92 %7 = zext i8 %6 to i32
97 %9 = icmp eq i32 %8, 0
98 br i1 %9, label %return, label %bb2
101 %10 = icmp eq i32 %3, 16
102 %11 = icmp eq i32 %8, 16
103 %or.cond = or i1 %10, %11
104 br i1 %or.cond, label %bb4, label %return
107 %12 = ptrtoint %struct.S* %x to i32
108 %phitmp = trunc i32 %12 to i8
111 return: ; preds = %bb2, %bb, %entry