do not compare actual branch labels; this may fix llvm-gcc-x86_64-darwin10-cross...
[oota-llvm.git] / test / CodeGen / ARM / arm-and-tst-peephole.ll
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
4
5 %struct.Foo = type { i8* }
6
7 define %struct.Foo* @_ZN3Foo7collectEj(%struct.Foo* %this, i32 %acc) nounwind readonly align 2 {
8 entry:
9   %scevgep = getelementptr %struct.Foo* %this, i32 1
10   br label %tailrecurse
11
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
20
21 ; CHECK:      ands r12, r12, #3
22 ; CHECK-NEXT: beq
23
24 ; THUMB:      movs r5, #3
25 ; THUMB-NEXT: mov r6, r4
26 ; THUMB-NEXT: ands r6, r5
27 ; THUMB-NEXT: tst r4, r5
28 ; THUMB-NEXT: beq
29
30 ; T2:      ands r12, r12, #3
31 ; T2-NEXT: beq
32
33   %and = and i32 %0, 3
34   %tst = icmp eq i32 %and, 0
35   br i1 %tst, label %sw.bb, label %tailrecurse.switch
36
37 tailrecurse.switch:                               ; preds = %tailrecurse
38   switch i32 %and, label %sw.epilog [
39     i32 1, label %sw.bb
40     i32 3, label %sw.bb6
41     i32 2, label %sw.bb8
42   ]
43
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
49   br label %tailrecurse
50
51 sw.bb6:                                           ; preds = %tailrecurse.switch
52   ret %struct.Foo* %lsr.iv2
53
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
58
59 sw.epilog:                                        ; preds = %tailrecurse.switch
60   ret %struct.Foo* undef
61 }