1 ; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 | FileCheck %s
2 ; RUN: llc < %s -mtriple=thumbv8 | FileCheck -check-prefix=CHECK-V8 %s
3 ; RUN: llc < %s -mtriple=thumbv7 -arm-restrict-it | FileCheck -check-prefix=CHECK-V8 %s
5 define i32 @t1(i32 %a, i32 %b, i8** %retaddr) {
7 ; CHECK: Block address taken
8 ; CHECK-NOT: Address of block that was removed by CodeGen
9 store i8* blockaddress(@t1, %cond_true), i8** %retaddr
10 %tmp2 = icmp eq i32 %a, 0
11 br i1 %tmp2, label %cond_false, label %cond_true
18 %tmp7 = add i32 %b, -1
22 define i32 @t2(i32 %a, i32 %b, i32 %c, i32 %d, i8** %retaddr) {
24 ; CHECK: Block address taken
28 store i8* blockaddress(@t2, %cond_true), i8** %retaddr
29 %tmp2 = icmp sgt i32 %c, 10
30 %tmp5 = icmp slt i32 %d, 4
31 %tmp8 = and i1 %tmp5, %tmp2
32 %tmp13 = add i32 %b, %a
33 br i1 %tmp8, label %cond_true, label %UnifiedReturnBlock
36 %tmp15 = add i32 %tmp13, %c
37 %tmp1821 = sub i32 %tmp15, %d
44 define hidden fastcc void @t3(i8** %retaddr, i1 %tst, i8* %p8) {
46 ; CHECK: Block address taken
47 ; CHECK-NOT: Address of block that was removed by CodeGen
49 store i8* blockaddress(@t3, %KBBlockZero_return_1), i8** %retaddr
50 br i1 %tst, label %bb77, label %bb7.i
52 bb7.i: ; preds = %bb35
55 KBBlockZero_return_1: ; preds = %KBBlockZero.exit
58 KBBlockZero_return_0: ; preds = %KBBlockZero.exit
61 bb77: ; preds = %bb26, %bb12, %bb
64 bb2.i: ; preds = %bb6.i350, %bb7.i
65 br i1 %tst, label %bb6.i350, label %KBBlockZero.exit
67 bb6.i350: ; preds = %bb2.i
70 KBBlockZero.exit: ; preds = %bb2.i
71 indirectbr i8* %p8, [label %KBBlockZero_return_1, label %KBBlockZero_return_0]
74 @foo = global i32 ()* null
75 define i32 @t4(i32 %x, i32 ()* %p_foo) {
79 %cmp = icmp slt i32 %x, 60
80 br i1 %cmp, label %if.then, label %if.else
82 if.then: ; preds = %entry
83 %tmp.2 = call i32 %p_foo()
84 %sub = add nsw i32 %x, -1
87 if.else: ; preds = %entry
88 %sub1 = add nsw i32 %x, -120
91 return: ; preds = %if.end5, %if.then4, %if.then
92 %retval.0 = phi i32 [ %sub, %if.then ], [ %sub1, %if.else ]
96 ; If-converter was checking for the wrong predicate subsumes pattern when doing
98 ; E.g., Let A be a basic block that flows conditionally into B and B be a
100 ; B can be predicated with A.BrToBPredicate into A iff B.Predicate is less
101 ; "permissive" than A.BrToBPredicate, i.e., iff A.BrToBPredicate subsumes
104 ; Hard-coded registers comes from the ABI.
105 ; CHECK-LABEL: wrapDistance:
108 ; CHECK-NEXT: suble r0, r2, #1
109 ; CHECK-NEXT: bxle lr
110 ; CHECK-NEXT: LBB{{.*}}:
111 ; CHECK-NEXT: subs [[REG:r[0-9]+]], #120
112 ; CHECK-NEXT: cmp [[REG]], r1
114 ; CHECK-NEXT: bge [[LABEL:.+]]
117 ; CHECK: cmp r0, #119
119 ; CHECK-NEXT: addle r0, r1, #1
120 ; CHECK-NEXT: bxle lr
123 ; CHECK-NEXT: subs r0, r1, r0
126 ; CHECK-V8-LABEL: wrapDistance:
127 ; CHECK-V8: cmp r1, #59
129 ; CHECK-V8-NEXT: %if.then
130 ; CHECK-V8-NEXT: subs r0, r2, #1
131 ; CHECK-V8-NEXT: bx lr
132 ; CHECK-V8-NEXT: %if.else
133 ; CHECK-V8-NEXT: subs [[REG:r[0-9]+]], #120
134 ; CHECK-V8-NEXT: cmp [[REG]], r1
136 ; CHECK-V8-NEXT: %if.else
137 ; CHECK-V8-NEXT: cmp r0, #119
139 ; CHECK-V8-NEXT: %if.then4
140 ; CHECK-V8-NEXT: adds r0, r1, #1
141 ; CHECK-V8-NEXT: bx lr
142 ; CHECK-V8-NEXT: %if.end5
143 ; CHECK-V8-NEXT: subs r0, r1, r0
144 ; CHECK-V8-NEXT: bx lr
146 define i32 @wrapDistance(i32 %tx, i32 %sx, i32 %w) {
148 %cmp = icmp slt i32 %sx, 60
149 br i1 %cmp, label %if.then, label %if.else
151 if.then: ; preds = %entry
152 %sub = add nsw i32 %w, -1
155 if.else: ; preds = %entry
156 %sub1 = add nsw i32 %w, -120
157 %cmp2 = icmp slt i32 %sub1, %sx
158 %cmp3 = icmp slt i32 %tx, 120
159 %or.cond = and i1 %cmp2, %cmp3
160 br i1 %or.cond, label %if.then4, label %if.end5
162 if.then4: ; preds = %if.else
163 %add = add nsw i32 %sx, 1
166 if.end5: ; preds = %if.else
167 %sub6 = sub nsw i32 %sx, %tx
170 return: ; preds = %if.end5, %if.then4, %if.then
171 %retval.0 = phi i32 [ %sub, %if.then ], [ %add, %if.then4 ], [ %sub6, %if.end5 ]