More tests to XFAIL. The arm-and-txt-peephole.ll test passes even when the
[oota-llvm.git] / test / CodeGen / ARM / arm-and-tst-peephole.ll
1 ; RUN: llc < %s -march=arm
2 ; FIXME: llc < %s -march=thumb | FileCheck -check-prefix=THUMB %s
3 ; FIXME: 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 }
62
63 ; Another test that exercises the AND/TST peephole optimization and also
64 ; generates a predicated ANDS instruction. Check that the predicate is printed
65 ; after the "S" modifier on the instruction.
66
67 %struct.S = type { i8* (i8*)*, [1 x i8] }
68
69 ; CHECK: bar
70 ; THUMB: bar
71 ; T2: bar
72 define internal zeroext i8 @bar(%struct.S* %x, %struct.S* nocapture %y) nounwind readonly {
73 entry:
74   %0 = getelementptr inbounds %struct.S* %x, i32 0, i32 1, i32 0
75   %1 = load i8* %0, align 1
76   %2 = zext i8 %1 to i32
77 ; CHECK: ands
78 ; THUMB: ands
79 ; T2: ands
80   %3 = and i32 %2, 112
81   %4 = icmp eq i32 %3, 0
82   br i1 %4, label %return, label %bb
83
84 bb:                                               ; preds = %entry
85   %5 = getelementptr inbounds %struct.S* %y, i32 0, i32 1, i32 0
86   %6 = load i8* %5, align 1
87   %7 = zext i8 %6 to i32
88 ; CHECK: andsne
89 ; THUMB: ands
90 ; T2: andsne
91   %8 = and i32 %7, 112
92   %9 = icmp eq i32 %8, 0
93   br i1 %9, label %return, label %bb2
94
95 bb2:                                              ; preds = %bb
96   %10 = icmp eq i32 %3, 16
97   %11 = icmp eq i32 %8, 16
98   %or.cond = or i1 %10, %11
99   br i1 %or.cond, label %bb4, label %return
100
101 bb4:                                              ; preds = %bb2
102   %12 = ptrtoint %struct.S* %x to i32
103   %phitmp = trunc i32 %12 to i8
104   ret i8 %phitmp
105
106 return:                                           ; preds = %bb2, %bb, %entry
107   ret i8 1
108 }