Disable because peephole is disabled.
[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 ; XFAIL: *
5
6 %struct.Foo = type { i8* }
7
8 define %struct.Foo* @_ZN3Foo7collectEj(%struct.Foo* %this, i32 %acc) nounwind readonly align 2 {
9 entry:
10   %scevgep = getelementptr %struct.Foo* %this, i32 1
11   br label %tailrecurse
12
13 tailrecurse:                                      ; preds = %sw.bb, %entry
14   %lsr.iv2 = phi %struct.Foo* [ %scevgep3, %sw.bb ], [ %scevgep, %entry ]
15   %lsr.iv = phi i32 [ %lsr.iv.next, %sw.bb ], [ 1, %entry ]
16   %acc.tr = phi i32 [ %or, %sw.bb ], [ %acc, %entry ]
17   %lsr.iv24 = bitcast %struct.Foo* %lsr.iv2 to i8**
18   %scevgep5 = getelementptr i8** %lsr.iv24, i32 -1
19   %tmp2 = load i8** %scevgep5
20   %0 = ptrtoint i8* %tmp2 to i32
21
22 ; CHECK:      ands r12, r12, #3
23 ; CHECK-NEXT: beq
24
25 ; THUMB:      movs r5, #3
26 ; THUMB-NEXT: mov r6, r4
27 ; THUMB-NEXT: ands r6, r5
28 ; THUMB-NEXT: tst r4, r5
29 ; THUMB-NEXT: beq
30
31 ; T2:      ands r12, r12, #3
32 ; T2-NEXT: beq
33
34   %and = and i32 %0, 3
35   %tst = icmp eq i32 %and, 0
36   br i1 %tst, label %sw.bb, label %tailrecurse.switch
37
38 tailrecurse.switch:                               ; preds = %tailrecurse
39   switch i32 %and, label %sw.epilog [
40     i32 1, label %sw.bb
41     i32 3, label %sw.bb6
42     i32 2, label %sw.bb8
43   ]
44
45 sw.bb:                                            ; preds = %tailrecurse.switch, %tailrecurse
46   %shl = shl i32 %acc.tr, 1
47   %or = or i32 %and, %shl
48   %lsr.iv.next = add i32 %lsr.iv, 1
49   %scevgep3 = getelementptr %struct.Foo* %lsr.iv2, i32 1
50   br label %tailrecurse
51
52 sw.bb6:                                           ; preds = %tailrecurse.switch
53   ret %struct.Foo* %lsr.iv2
54
55 sw.bb8:                                           ; preds = %tailrecurse.switch
56   %tmp1 = add i32 %acc.tr, %lsr.iv
57   %add.ptr11 = getelementptr inbounds %struct.Foo* %this, i32 %tmp1
58   ret %struct.Foo* %add.ptr11
59
60 sw.epilog:                                        ; preds = %tailrecurse.switch
61   ret %struct.Foo* undef
62 }
63
64 ; Another test that exercises the AND/TST peephole optimization and also
65 ; generates a predicated ANDS instruction. Check that the predicate is printed
66 ; after the "S" modifier on the instruction.
67
68 %struct.S = type { i8* (i8*)*, [1 x i8] }
69
70 ; CHECK: bar
71 ; THUMB: bar
72 ; T2: bar
73 define internal zeroext i8 @bar(%struct.S* %x, %struct.S* nocapture %y) nounwind readonly {
74 entry:
75   %0 = getelementptr inbounds %struct.S* %x, i32 0, i32 1, i32 0
76   %1 = load i8* %0, align 1
77   %2 = zext i8 %1 to i32
78 ; CHECK: ands
79 ; THUMB: ands
80 ; T2: ands
81   %3 = and i32 %2, 112
82   %4 = icmp eq i32 %3, 0
83   br i1 %4, label %return, label %bb
84
85 bb:                                               ; preds = %entry
86   %5 = getelementptr inbounds %struct.S* %y, i32 0, i32 1, i32 0
87   %6 = load i8* %5, align 1
88   %7 = zext i8 %6 to i32
89 ; CHECK: andsne
90 ; THUMB: ands
91 ; T2: andsne
92   %8 = and i32 %7, 112
93   %9 = icmp eq i32 %8, 0
94   br i1 %9, label %return, label %bb2
95
96 bb2:                                              ; preds = %bb
97   %10 = icmp eq i32 %3, 16
98   %11 = icmp eq i32 %8, 16
99   %or.cond = or i1 %10, %11
100   br i1 %or.cond, label %bb4, label %return
101
102 bb4:                                              ; preds = %bb2
103   %12 = ptrtoint %struct.S* %x to i32
104   %phitmp = trunc i32 %12 to i8
105   ret i8 %phitmp
106
107 return:                                           ; preds = %bb2, %bb, %entry
108   ret i8 1
109 }