1 ; RUN: llc < %s -march=arm | FileCheck %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 %struct.Foo = type { i8* }
7 define %struct.Foo* @_ZN3Foo7collectEj(%struct.Foo* %this, i32 %acc) nounwind readonly align 2 {
9 %scevgep = getelementptr %struct.Foo* %this, i32 1
12 tailrecurse: ; preds = %sw.bb, %entry
13 %lsr.iv2 = phi %struct.Foo* [ %scevgep3, %sw.bb ], [ %scevgep, %entry ]
14 %lsr.iv = phi i32 [ %lsr.iv.next, %sw.bb ], [ 1, %entry ]
15 %acc.tr = phi i32 [ %or, %sw.bb ], [ %acc, %entry ]
16 %lsr.iv24 = bitcast %struct.Foo* %lsr.iv2 to i8**
17 %scevgep5 = getelementptr i8** %lsr.iv24, i32 -1
18 %tmp2 = load i8** %scevgep5
19 %0 = ptrtoint i8* %tmp2 to i32
21 ; CHECK: ands r12, r12, #3
25 ; THUMB-NEXT: mov r6, r4
26 ; THUMB-NEXT: ands r6, r5
27 ; THUMB-NEXT: tst r4, r5
30 ; T2: ands r12, r12, #3
34 %tst = icmp eq i32 %and, 0
35 br i1 %tst, label %sw.bb, label %tailrecurse.switch
37 tailrecurse.switch: ; preds = %tailrecurse
38 switch i32 %and, label %sw.epilog [
44 sw.bb: ; preds = %tailrecurse.switch, %tailrecurse
45 %shl = shl i32 %acc.tr, 1
46 %or = or i32 %and, %shl
47 %lsr.iv.next = add i32 %lsr.iv, 1
48 %scevgep3 = getelementptr %struct.Foo* %lsr.iv2, i32 1
51 sw.bb6: ; preds = %tailrecurse.switch
52 ret %struct.Foo* %lsr.iv2
54 sw.bb8: ; preds = %tailrecurse.switch
55 %tmp1 = add i32 %acc.tr, %lsr.iv
56 %add.ptr11 = getelementptr inbounds %struct.Foo* %this, i32 %tmp1
57 ret %struct.Foo* %add.ptr11
59 sw.epilog: ; preds = %tailrecurse.switch
60 ret %struct.Foo* undef