1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: -p
2 ; RUN: opt < %s -loop-unroll -unroll-runtime=true -unroll-runtime-epilog=true -unroll-runtime-multi-exit=true -verify-loop-lcssa -verify-dom-info -verify-loop-info -S | FileCheck %s -check-prefixes=CHECK,EPILOG
3 ; RUN: opt < %s -loop-unroll -unroll-runtime -unroll-count=2 -unroll-runtime-epilog=true -unroll-runtime-multi-exit=true -verify-loop-lcssa -verify-dom-info -verify-loop-info -S | FileCheck %s -check-prefixes=CHECK,EPILOG-BLOCK
4 ; RUN: opt < %s -loop-unroll -unroll-runtime=true -unroll-runtime-epilog=false -unroll-runtime-multi-exit=true -verify-loop-lcssa -verify-dom-info -verify-loop-info -S | FileCheck %s -check-prefixes=CHECK,PROLOG
5 ; RUN: opt < %s -loop-unroll -unroll-runtime -unroll-runtime-epilog=false -unroll-count=2 -unroll-runtime-multi-exit=true -verify-loop-lcssa -verify-dom-info -verify-loop-info -S | FileCheck %s -check-prefixes=CHECK,PROLOG-BLOCK
9 ; test with three exiting and three exit blocks.
10 ; none of the exit blocks have successors
11 define void @test1(i64 %trip, i1 %cond) {
12 ; EPILOG-LABEL: @test1(
14 ; EPILOG-NEXT: %0 = add i64 %trip, -1
15 ; EPILOG-NEXT: %xtraiter = and i64 %trip, 7
16 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
17 ; EPILOG-NEXT: br i1 %1, label %exit2.loopexit.unr-lcssa, label %entry.new
19 ; EPILOG-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
20 ; EPILOG-NEXT: br label %loop_header
21 ; EPILOG: loop_header:
22 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
23 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
24 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
25 ; EPILOG: loop_exiting_bb1:
26 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
27 ; EPILOG: loop_exiting_bb2:
28 ; EPILOG-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
29 ; EPILOG: exit3.loopexit:
30 ; EPILOG-NEXT: br label %exit3
31 ; EPILOG: exit3.loopexit2:
32 ; EPILOG-NEXT: br label %exit3
34 ; EPILOG-NEXT: ret void
36 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
37 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
38 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
39 ; EPILOG: loop_exiting_bb1.1:
40 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
41 ; EPILOG: loop_exiting_bb2.1:
42 ; EPILOG-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
43 ; EPILOG: loop_latch.1:
44 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
45 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
46 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting_bb1.2
47 ; EPILOG: loop_exiting_bb1.2:
48 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.2, label %exit1.loopexit
49 ; EPILOG: loop_exiting_bb2.2:
50 ; EPILOG-NEXT: br i1 false, label %loop_latch.2, label %exit3.loopexit
51 ; EPILOG: loop_latch.2:
52 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
53 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
54 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting_bb1.3
55 ; EPILOG: loop_exiting_bb1.3:
56 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.3, label %exit1.loopexit
57 ; EPILOG: loop_exiting_bb2.3:
58 ; EPILOG-NEXT: br i1 false, label %loop_latch.3, label %exit3.loopexit
59 ; EPILOG: loop_latch.3:
60 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
61 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
62 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting_bb1.4
63 ; EPILOG: loop_exiting_bb1.4:
64 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.4, label %exit1.loopexit
65 ; EPILOG: loop_exiting_bb2.4:
66 ; EPILOG-NEXT: br i1 false, label %loop_latch.4, label %exit3.loopexit
67 ; EPILOG: loop_latch.4:
68 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
69 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
70 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting_bb1.5
71 ; EPILOG: loop_exiting_bb1.5:
72 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.5, label %exit1.loopexit
73 ; EPILOG: loop_exiting_bb2.5:
74 ; EPILOG-NEXT: br i1 false, label %loop_latch.5, label %exit3.loopexit
75 ; EPILOG: loop_latch.5:
76 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
77 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
78 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting_bb1.6
79 ; EPILOG: loop_exiting_bb1.6:
80 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.6, label %exit1.loopexit
81 ; EPILOG: loop_exiting_bb2.6:
82 ; EPILOG-NEXT: br i1 false, label %loop_latch.6, label %exit3.loopexit
83 ; EPILOG: loop_latch.6:
84 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
85 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
86 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting_bb1.7
87 ; EPILOG: loop_exiting_bb1.7:
88 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.7, label %exit1.loopexit
89 ; EPILOG: loop_exiting_bb2.7:
90 ; EPILOG-NEXT: br i1 false, label %loop_latch.7, label %exit3.loopexit
91 ; EPILOG: loop_latch.7:
92 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
93 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
94 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
95 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit
96 ; EPILOG: exit1.loopexit:
97 ; EPILOG-NEXT: br label %exit1
98 ; EPILOG: exit1.loopexit1:
99 ; EPILOG-NEXT: br label %exit1
101 ; EPILOG-NEXT: ret void
102 ; EPILOG: exit2.loopexit.unr-lcssa.loopexit:
103 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
104 ; EPILOG-NEXT: br label %exit2.loopexit.unr-lcssa
105 ; EPILOG: exit2.loopexit.unr-lcssa:
106 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
107 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
108 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
109 ; EPILOG: loop_header.epil.preheader:
110 ; EPILOG-NEXT: br label %loop_header.epil
111 ; EPILOG: loop_header.epil:
112 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
113 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
114 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting_bb1.epil
115 ; EPILOG: loop_exiting_bb1.epil:
116 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.epil, label %exit1.loopexit1
117 ; EPILOG: loop_exiting_bb2.epil:
118 ; EPILOG-NEXT: br i1 false, label %loop_latch.epil, label %exit3.loopexit2
119 ; EPILOG: loop_latch.epil:
120 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
121 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
122 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
123 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
124 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.loopexit.epilog-lcssa, !llvm.loop !0
125 ; EPILOG: exit2.loopexit.epilog-lcssa:
126 ; EPILOG-NEXT: br label %exit2.loopexit
127 ; EPILOG: exit2.loopexit:
128 ; EPILOG-NEXT: ret void
130 ; EPILOG-BLOCK-LABEL: @test1(
131 ; EPILOG-BLOCK-NEXT: entry:
132 ; EPILOG-BLOCK-NEXT: %0 = add i64 %trip, -1
133 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
134 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
135 ; EPILOG-BLOCK-NEXT: br i1 %1, label %exit2.loopexit.unr-lcssa, label %entry.new
136 ; EPILOG-BLOCK: entry.new:
137 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
138 ; EPILOG-BLOCK-NEXT: br label %loop_header
139 ; EPILOG-BLOCK: loop_header:
140 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
141 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
142 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
143 ; EPILOG-BLOCK: loop_exiting_bb1:
144 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
145 ; EPILOG-BLOCK: loop_exiting_bb2:
146 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
147 ; EPILOG-BLOCK: exit3.loopexit:
148 ; EPILOG-BLOCK-NEXT: br label %exit3
149 ; EPILOG-BLOCK: exit3:
150 ; EPILOG-BLOCK-NEXT: ret void
151 ; EPILOG-BLOCK: loop_latch:
152 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
153 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
154 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
155 ; EPILOG-BLOCK: loop_exiting_bb1.1:
156 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
157 ; EPILOG-BLOCK: loop_exiting_bb2.1:
158 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
159 ; EPILOG-BLOCK: loop_latch.1:
160 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
161 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
162 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
163 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit, !llvm.loop !0
164 ; EPILOG-BLOCK: exit1.loopexit:
165 ; EPILOG-BLOCK-NEXT: br label %exit1
166 ; EPILOG-BLOCK: exit1:
167 ; EPILOG-BLOCK-NEXT: ret void
168 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa.loopexit:
169 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit.unr-lcssa
170 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa:
171 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
172 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
173 ; EPILOG-BLOCK: loop_header.epil.preheader:
174 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
175 ; EPILOG-BLOCK: loop_header.epil:
176 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting_bb1.epil
177 ; EPILOG-BLOCK: loop_exiting_bb1.epil:
178 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.epil, label %exit1
179 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
180 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_latch.epil, label %exit3
181 ; EPILOG-BLOCK: loop_latch.epil:
182 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit
183 ; EPILOG-BLOCK: exit2.loopexit:
184 ; EPILOG-BLOCK-NEXT: ret void
186 ; PROLOG-LABEL: @test1(
187 ; PROLOG-NEXT: entry:
188 ; PROLOG-NEXT: %0 = add i64 %trip, -1
189 ; PROLOG-NEXT: %xtraiter = and i64 %trip, 7
190 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
191 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
192 ; PROLOG: loop_header.prol.preheader:
193 ; PROLOG-NEXT: br label %loop_header.prol
194 ; PROLOG: loop_header.prol:
195 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
196 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
197 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting_bb1.prol
198 ; PROLOG: loop_exiting_bb1.prol:
199 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.prol, label %exit1.loopexit1
200 ; PROLOG: loop_exiting_bb2.prol:
201 ; PROLOG-NEXT: br i1 false, label %loop_latch.prol, label %exit3.loopexit2
202 ; PROLOG: loop_latch.prol:
203 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
204 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
205 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
206 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
207 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !0
208 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
209 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
210 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
211 ; PROLOG: loop_header.prol.loopexit:
212 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
213 ; PROLOG-NEXT: %1 = icmp ult i64 %0, 7
214 ; PROLOG-NEXT: br i1 %1, label %exit2.loopexit, label %entry.new
216 ; PROLOG-NEXT: br label %loop_header
217 ; PROLOG: loop_header:
218 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
219 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
220 ; PROLOG: loop_exiting_bb1:
221 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
222 ; PROLOG: loop_exiting_bb2:
223 ; PROLOG-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
224 ; PROLOG: exit3.loopexit:
225 ; PROLOG-NEXT: br label %exit3
226 ; PROLOG: exit3.loopexit2:
227 ; PROLOG-NEXT: br label %exit3
229 ; PROLOG-NEXT: ret void
230 ; PROLOG: loop_latch:
231 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
232 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
233 ; PROLOG: loop_exiting_bb1.1:
234 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
235 ; PROLOG: loop_exiting_bb2.1:
236 ; PROLOG-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
237 ; PROLOG: loop_latch.1:
238 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
239 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting_bb1.2
240 ; PROLOG: loop_exiting_bb1.2:
241 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.2, label %exit1.loopexit
242 ; PROLOG: loop_exiting_bb2.2:
243 ; PROLOG-NEXT: br i1 false, label %loop_latch.2, label %exit3.loopexit
244 ; PROLOG: loop_latch.2:
245 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
246 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting_bb1.3
247 ; PROLOG: loop_exiting_bb1.3:
248 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.3, label %exit1.loopexit
249 ; PROLOG: loop_exiting_bb2.3:
250 ; PROLOG-NEXT: br i1 false, label %loop_latch.3, label %exit3.loopexit
251 ; PROLOG: loop_latch.3:
252 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
253 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting_bb1.4
254 ; PROLOG: loop_exiting_bb1.4:
255 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.4, label %exit1.loopexit
256 ; PROLOG: loop_exiting_bb2.4:
257 ; PROLOG-NEXT: br i1 false, label %loop_latch.4, label %exit3.loopexit
258 ; PROLOG: loop_latch.4:
259 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
260 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting_bb1.5
261 ; PROLOG: loop_exiting_bb1.5:
262 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.5, label %exit1.loopexit
263 ; PROLOG: loop_exiting_bb2.5:
264 ; PROLOG-NEXT: br i1 false, label %loop_latch.5, label %exit3.loopexit
265 ; PROLOG: loop_latch.5:
266 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
267 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting_bb1.6
268 ; PROLOG: loop_exiting_bb1.6:
269 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.6, label %exit1.loopexit
270 ; PROLOG: loop_exiting_bb2.6:
271 ; PROLOG-NEXT: br i1 false, label %loop_latch.6, label %exit3.loopexit
272 ; PROLOG: loop_latch.6:
273 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
274 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting_bb1.7
275 ; PROLOG: loop_exiting_bb1.7:
276 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.7, label %exit1.loopexit
277 ; PROLOG: loop_exiting_bb2.7:
278 ; PROLOG-NEXT: br i1 false, label %loop_latch.7, label %exit3.loopexit
279 ; PROLOG: loop_latch.7:
280 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
281 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
282 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa
283 ; PROLOG: exit1.loopexit:
284 ; PROLOG-NEXT: br label %exit1
285 ; PROLOG: exit1.loopexit1:
286 ; PROLOG-NEXT: br label %exit1
288 ; PROLOG-NEXT: ret void
289 ; PROLOG: exit2.loopexit.unr-lcssa:
290 ; PROLOG-NEXT: br label %exit2.loopexit
291 ; PROLOG: exit2.loopexit:
292 ; PROLOG-NEXT: ret void
294 ; PROLOG-BLOCK-LABEL: @test1(
295 ; PROLOG-BLOCK-NEXT: entry:
296 ; PROLOG-BLOCK-NEXT: %0 = add i64 %trip, -1
297 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
298 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
299 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
300 ; PROLOG-BLOCK: loop_header.prol.preheader:
301 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
302 ; PROLOG-BLOCK: loop_header.prol:
303 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting_bb1.prol
304 ; PROLOG-BLOCK: loop_exiting_bb1.prol:
305 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.prol, label %exit1
306 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
307 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_latch.prol, label %exit3
308 ; PROLOG-BLOCK: loop_latch.prol:
309 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
310 ; PROLOG-BLOCK: loop_header.prol.loopexit:
311 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
312 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
313 ; PROLOG-BLOCK-NEXT: br i1 %1, label %exit2.loopexit, label %entry.new
314 ; PROLOG-BLOCK: entry.new:
315 ; PROLOG-BLOCK-NEXT: br label %loop_header
316 ; PROLOG-BLOCK: loop_header:
317 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
318 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
319 ; PROLOG-BLOCK: loop_exiting_bb1:
320 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
321 ; PROLOG-BLOCK: loop_exiting_bb2:
322 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
323 ; PROLOG-BLOCK: exit3.loopexit:
324 ; PROLOG-BLOCK-NEXT: br label %exit3
325 ; PROLOG-BLOCK: exit3:
326 ; PROLOG-BLOCK-NEXT: ret void
327 ; PROLOG-BLOCK: loop_latch:
328 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
329 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
330 ; PROLOG-BLOCK: loop_exiting_bb1.1:
331 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
332 ; PROLOG-BLOCK: loop_exiting_bb2.1:
333 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
334 ; PROLOG-BLOCK: loop_latch.1:
335 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
336 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
337 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa, !llvm.loop !0
338 ; PROLOG-BLOCK: exit1.loopexit:
339 ; PROLOG-BLOCK-NEXT: br label %exit1
340 ; PROLOG-BLOCK: exit1:
341 ; PROLOG-BLOCK-NEXT: ret void
342 ; PROLOG-BLOCK: exit2.loopexit.unr-lcssa:
343 ; PROLOG-BLOCK-NEXT: br label %exit2.loopexit
344 ; PROLOG-BLOCK: exit2.loopexit:
345 ; PROLOG-BLOCK-NEXT: ret void
349 br label %loop_header
352 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
353 br i1 %cond, label %loop_latch, label %loop_exiting_bb1
356 br i1 false, label %loop_exiting_bb2, label %exit1
359 br i1 false, label %loop_latch, label %exit3
365 %iv_next = add i64 %iv, 1
366 %cmp = icmp ne i64 %iv_next, %trip
367 br i1 %cmp, label %loop_header, label %exit2.loopexit
377 ; test with three exiting and two exit blocks.
378 ; The non-latch exit block has 2 unique predecessors.
379 ; There are 2 values passed to the exit blocks that are calculated at every iteration.
380 ; %sum.02 and %add. Both of these are incoming values for phi from every exiting
382 define i32 @test2(i32* nocapture %a, i64 %n) {
383 ; EPILOG-LABEL: @test2(
384 ; EPILOG-NEXT: entry:
385 ; EPILOG-NEXT: %0 = add i64 %n, -1
386 ; EPILOG-NEXT: %xtraiter = and i64 %n, 7
387 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
388 ; EPILOG-NEXT: br i1 %1, label %for.end.unr-lcssa, label %entry.new
390 ; EPILOG-NEXT: %unroll_iter = sub i64 %n, %xtraiter
391 ; EPILOG-NEXT: br label %header
393 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %for.body.7 ]
394 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %for.body.7 ]
395 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %for.body.7 ]
396 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
397 ; EPILOG: for.exiting_block:
398 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
399 ; EPILOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
401 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
402 ; EPILOG-NEXT: %2 = load i32, i32* %arrayidx, align 4
403 ; EPILOG-NEXT: %add = add nsw i32 %2, %sum.02
404 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
405 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
406 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
407 ; EPILOG: for.exiting_block.1:
408 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
409 ; EPILOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
410 ; EPILOG: for.body.1:
411 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
412 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
413 ; EPILOG-NEXT: %add.1 = add nsw i32 %3, %add
414 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
415 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
416 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
417 ; EPILOG: for.exiting_block.2:
418 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
419 ; EPILOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %for.body.2
420 ; EPILOG: for.body.2:
421 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
422 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.2, align 4
423 ; EPILOG-NEXT: %add.2 = add nsw i32 %4, %add.1
424 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
425 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
426 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
427 ; EPILOG: for.exiting_block.3:
428 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
429 ; EPILOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %for.body.3
430 ; EPILOG: for.body.3:
431 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
432 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.3, align 4
433 ; EPILOG-NEXT: %add.3 = add nsw i32 %5, %add.2
434 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
435 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
436 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
437 ; EPILOG: for.exiting_block.4:
438 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
439 ; EPILOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %for.body.4
440 ; EPILOG: for.body.4:
441 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
442 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.4, align 4
443 ; EPILOG-NEXT: %add.4 = add nsw i32 %6, %add.3
444 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
445 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
446 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
447 ; EPILOG: for.exiting_block.5:
448 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
449 ; EPILOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %for.body.5
450 ; EPILOG: for.body.5:
451 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
452 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.5, align 4
453 ; EPILOG-NEXT: %add.5 = add nsw i32 %7, %add.4
454 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
455 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
456 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
457 ; EPILOG: for.exiting_block.6:
458 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
459 ; EPILOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %for.body.6
460 ; EPILOG: for.body.6:
461 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
462 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.6, align 4
463 ; EPILOG-NEXT: %add.6 = add nsw i32 %8, %add.5
464 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
465 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
466 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
467 ; EPILOG: for.exiting_block.7:
468 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
469 ; EPILOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %for.body.7
470 ; EPILOG: for.body.7:
471 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
472 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.7, align 4
473 ; EPILOG-NEXT: %add.7 = add nsw i32 %9, %add.6
474 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
475 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
476 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
477 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %for.end.unr-lcssa.loopexit, label %header
478 ; EPILOG: for.end.unr-lcssa.loopexit:
479 ; EPILOG-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.7, %for.body.7 ]
480 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %for.body.7 ]
481 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %for.body.7 ]
482 ; EPILOG-NEXT: br label %for.end.unr-lcssa
483 ; EPILOG: for.end.unr-lcssa:
484 ; EPILOG-NEXT: %sum.0.lcssa.ph = phi i32 [ undef, %entry ], [ %sum.0.lcssa.ph.ph, %for.end.unr-lcssa.loopexit ]
485 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %for.end.unr-lcssa.loopexit ]
486 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %for.end.unr-lcssa.loopexit ]
487 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
488 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %for.end
489 ; EPILOG: header.epil.preheader:
490 ; EPILOG-NEXT: br label %header.epil
491 ; EPILOG: header.epil:
492 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %for.body.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
493 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %for.body.epil ], [ %sum.02.unr, %header.epil.preheader ]
494 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %for.body.epil ]
495 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit2, label %for.exiting_block.epil
496 ; EPILOG: for.exiting_block.epil:
497 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
498 ; EPILOG-NEXT: br i1 %cmp.epil, label %for.exit2.loopexit2, label %for.body.epil
499 ; EPILOG: for.body.epil:
500 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
501 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.epil, align 4
502 ; EPILOG-NEXT: %add.epil = add nsw i32 %10, %sum.02.epil
503 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
504 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
505 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
506 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
507 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %for.end.epilog-lcssa, !llvm.loop !2
508 ; EPILOG: for.end.epilog-lcssa:
509 ; EPILOG-NEXT: %sum.0.lcssa.ph1 = phi i32 [ %add.epil, %for.body.epil ]
510 ; EPILOG-NEXT: br label %for.end
512 ; EPILOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %for.end.unr-lcssa ], [ %sum.0.lcssa.ph1, %for.end.epilog-lcssa ]
513 ; EPILOG-NEXT: ret i32 %sum.0.lcssa
514 ; EPILOG: for.exit2.loopexit:
515 ; EPILOG-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %for.body ], [ 42, %for.exiting_block.1 ], [ %add.1, %for.body.1 ], [ 42, %for.exiting_block.2 ], [ %add.2, %for.body.2 ], [ 42, %for.exiting_block.3 ], [ %add.3, %for.body.3 ], [ 42, %for.exiting_block.4 ], [ %add.4, %for.body.4 ], [ 42, %for.exiting_block.5 ], [ %add.5, %for.body.5 ], [ 42, %for.exiting_block.6 ], [ %add.6, %for.body.6 ], [ 42, %for.exiting_block.7 ]
516 ; EPILOG-NEXT: br label %for.exit2
517 ; EPILOG: for.exit2.loopexit2:
518 ; EPILOG-NEXT: %retval.ph3 = phi i32 [ 42, %for.exiting_block.epil ], [ %sum.02.epil, %header.epil ]
519 ; EPILOG-NEXT: br label %for.exit2
521 ; EPILOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph3, %for.exit2.loopexit2 ]
522 ; EPILOG-NEXT: ret i32 %retval
524 ; EPILOG-BLOCK-LABEL: @test2(
525 ; EPILOG-BLOCK-NEXT: entry:
526 ; EPILOG-BLOCK-NEXT: %0 = add i64 %n, -1
527 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
528 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
529 ; EPILOG-BLOCK-NEXT: br i1 %1, label %for.end.unr-lcssa, label %entry.new
530 ; EPILOG-BLOCK: entry.new:
531 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %n, %xtraiter
532 ; EPILOG-BLOCK-NEXT: br label %header
533 ; EPILOG-BLOCK: header:
534 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %for.body.1 ]
535 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %for.body.1 ]
536 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %for.body.1 ]
537 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
538 ; EPILOG-BLOCK: for.exiting_block:
539 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
540 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
541 ; EPILOG-BLOCK: for.body:
542 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
543 ; EPILOG-BLOCK-NEXT: %2 = load i32, i32* %arrayidx, align 4
544 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %2, %sum.02
545 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
546 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
547 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
548 ; EPILOG-BLOCK: for.exiting_block.1:
549 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
550 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
551 ; EPILOG-BLOCK: for.body.1:
552 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
553 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
554 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %3, %add
555 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
556 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
557 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
558 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %for.end.unr-lcssa.loopexit, label %header, !llvm.loop !2
559 ; EPILOG-BLOCK: for.end.unr-lcssa.loopexit:
560 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.1, %for.body.1 ]
561 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %for.body.1 ]
562 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %for.body.1 ]
563 ; EPILOG-BLOCK-NEXT: br label %for.end.unr-lcssa
564 ; EPILOG-BLOCK: for.end.unr-lcssa:
565 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ undef, %entry ], [ %sum.0.lcssa.ph.ph, %for.end.unr-lcssa.loopexit ]
566 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %for.end.unr-lcssa.loopexit ]
567 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %for.end.unr-lcssa.loopexit ]
568 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
569 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %for.end
570 ; EPILOG-BLOCK: header.epil.preheader:
571 ; EPILOG-BLOCK-NEXT: br label %header.epil
572 ; EPILOG-BLOCK: header.epil:
573 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.epil
574 ; EPILOG-BLOCK: for.exiting_block.epil:
575 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
576 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %for.exit2, label %for.body.epil
577 ; EPILOG-BLOCK: for.body.epil:
578 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
579 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.epil, align 4
580 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %4, %sum.02.unr
581 ; EPILOG-BLOCK-NEXT: br label %for.end
582 ; EPILOG-BLOCK: for.end:
583 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %for.end.unr-lcssa ], [ %add.epil, %for.body.epil ]
584 ; EPILOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
585 ; EPILOG-BLOCK: for.exit2.loopexit:
586 ; EPILOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %for.body ], [ 42, %for.exiting_block.1 ]
587 ; EPILOG-BLOCK-NEXT: br label %for.exit2
588 ; EPILOG-BLOCK: for.exit2:
589 ; EPILOG-BLOCK-NEXT: %retval = phi i32 [ %sum.02.unr, %header.epil ], [ 42, %for.exiting_block.epil ], [ %retval.ph, %for.exit2.loopexit ]
590 ; EPILOG-BLOCK-NEXT: ret i32 %retval
592 ; PROLOG-LABEL: @test2(
593 ; PROLOG-NEXT: entry:
594 ; PROLOG-NEXT: %0 = add i64 %n, -1
595 ; PROLOG-NEXT: %xtraiter = and i64 %n, 7
596 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
597 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
598 ; PROLOG: header.prol.preheader:
599 ; PROLOG-NEXT: br label %header.prol
600 ; PROLOG: header.prol:
601 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %for.body.prol ], [ 0, %header.prol.preheader ]
602 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %for.body.prol ], [ 0, %header.prol.preheader ]
603 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %for.body.prol ]
604 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit1, label %for.exiting_block.prol
605 ; PROLOG: for.exiting_block.prol:
606 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
607 ; PROLOG-NEXT: br i1 %cmp.prol, label %for.exit2.loopexit1, label %for.body.prol
608 ; PROLOG: for.body.prol:
609 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
610 ; PROLOG-NEXT: %1 = load i32, i32* %arrayidx.prol, align 4
611 ; PROLOG-NEXT: %add.prol = add nsw i32 %1, %sum.02.prol
612 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
613 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
614 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
615 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
616 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !2
617 ; PROLOG: header.prol.loopexit.unr-lcssa:
618 ; PROLOG-NEXT: %sum.0.lcssa.unr.ph = phi i32 [ %add.prol, %for.body.prol ]
619 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %for.body.prol ]
620 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %for.body.prol ]
621 ; PROLOG-NEXT: br label %header.prol.loopexit
622 ; PROLOG: header.prol.loopexit:
623 ; PROLOG-NEXT: %sum.0.lcssa.unr = phi i32 [ undef, %entry ], [ %sum.0.lcssa.unr.ph, %header.prol.loopexit.unr-lcssa ]
624 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
625 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
626 ; PROLOG-NEXT: %2 = icmp ult i64 %0, 7
627 ; PROLOG-NEXT: br i1 %2, label %for.end, label %entry.new
629 ; PROLOG-NEXT: br label %header
631 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %for.body.7 ]
632 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %for.body.7 ]
633 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
634 ; PROLOG: for.exiting_block:
635 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
636 ; PROLOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
638 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
639 ; PROLOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
640 ; PROLOG-NEXT: %add = add nsw i32 %3, %sum.02
641 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
642 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
643 ; PROLOG: for.exiting_block.1:
644 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
645 ; PROLOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
646 ; PROLOG: for.body.1:
647 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
648 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
649 ; PROLOG-NEXT: %add.1 = add nsw i32 %4, %add
650 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
651 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
652 ; PROLOG: for.exiting_block.2:
653 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
654 ; PROLOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %for.body.2
655 ; PROLOG: for.body.2:
656 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
657 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
658 ; PROLOG-NEXT: %add.2 = add nsw i32 %5, %add.1
659 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
660 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
661 ; PROLOG: for.exiting_block.3:
662 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
663 ; PROLOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %for.body.3
664 ; PROLOG: for.body.3:
665 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
666 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
667 ; PROLOG-NEXT: %add.3 = add nsw i32 %6, %add.2
668 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
669 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
670 ; PROLOG: for.exiting_block.4:
671 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
672 ; PROLOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %for.body.4
673 ; PROLOG: for.body.4:
674 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
675 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
676 ; PROLOG-NEXT: %add.4 = add nsw i32 %7, %add.3
677 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
678 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
679 ; PROLOG: for.exiting_block.5:
680 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
681 ; PROLOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %for.body.5
682 ; PROLOG: for.body.5:
683 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
684 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
685 ; PROLOG-NEXT: %add.5 = add nsw i32 %8, %add.4
686 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
687 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
688 ; PROLOG: for.exiting_block.6:
689 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
690 ; PROLOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %for.body.6
691 ; PROLOG: for.body.6:
692 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
693 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
694 ; PROLOG-NEXT: %add.6 = add nsw i32 %9, %add.5
695 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
696 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
697 ; PROLOG: for.exiting_block.7:
698 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
699 ; PROLOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %for.body.7
700 ; PROLOG: for.body.7:
701 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
702 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
703 ; PROLOG-NEXT: %add.7 = add nsw i32 %10, %add.6
704 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
705 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
706 ; PROLOG-NEXT: br i1 %exitcond.7, label %for.end.unr-lcssa, label %header
707 ; PROLOG: for.end.unr-lcssa:
708 ; PROLOG-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.7, %for.body.7 ]
709 ; PROLOG-NEXT: br label %for.end
711 ; PROLOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %for.end.unr-lcssa ]
712 ; PROLOG-NEXT: ret i32 %sum.0.lcssa
713 ; PROLOG: for.exit2.loopexit:
714 ; PROLOG-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %for.body ], [ 42, %for.exiting_block.1 ], [ %add.1, %for.body.1 ], [ 42, %for.exiting_block.2 ], [ %add.2, %for.body.2 ], [ 42, %for.exiting_block.3 ], [ %add.3, %for.body.3 ], [ 42, %for.exiting_block.4 ], [ %add.4, %for.body.4 ], [ 42, %for.exiting_block.5 ], [ %add.5, %for.body.5 ], [ 42, %for.exiting_block.6 ], [ %add.6, %for.body.6 ], [ 42, %for.exiting_block.7 ]
715 ; PROLOG-NEXT: br label %for.exit2
716 ; PROLOG: for.exit2.loopexit1:
717 ; PROLOG-NEXT: %retval.ph2 = phi i32 [ 42, %for.exiting_block.prol ], [ %sum.02.prol, %header.prol ]
718 ; PROLOG-NEXT: br label %for.exit2
720 ; PROLOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph2, %for.exit2.loopexit1 ]
721 ; PROLOG-NEXT: ret i32 %retval
723 ; PROLOG-BLOCK-LABEL: @test2(
724 ; PROLOG-BLOCK-NEXT: entry:
725 ; PROLOG-BLOCK-NEXT: %0 = add i64 %n, -1
726 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
727 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
728 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
729 ; PROLOG-BLOCK: header.prol.preheader:
730 ; PROLOG-BLOCK-NEXT: br label %header.prol
731 ; PROLOG-BLOCK: header.prol:
732 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.prol
733 ; PROLOG-BLOCK: for.exiting_block.prol:
734 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
735 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %for.exit2, label %for.body.prol
736 ; PROLOG-BLOCK: for.body.prol:
737 ; PROLOG-BLOCK-NEXT: %1 = load i32, i32* %a, align 4
738 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
739 ; PROLOG-BLOCK: header.prol.loopexit:
740 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.unr = phi i32 [ undef, %entry ], [ %1, %for.body.prol ]
741 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %for.body.prol ]
742 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %1, %for.body.prol ]
743 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %0, 1
744 ; PROLOG-BLOCK-NEXT: br i1 %2, label %for.end, label %entry.new
745 ; PROLOG-BLOCK: entry.new:
746 ; PROLOG-BLOCK-NEXT: br label %header
747 ; PROLOG-BLOCK: header:
748 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %for.body.1 ]
749 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %for.body.1 ]
750 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
751 ; PROLOG-BLOCK: for.exiting_block:
752 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
753 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
754 ; PROLOG-BLOCK: for.body:
755 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
756 ; PROLOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
757 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
758 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
759 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
760 ; PROLOG-BLOCK: for.exiting_block.1:
761 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
762 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
763 ; PROLOG-BLOCK: for.body.1:
764 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
765 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
766 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
767 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
768 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
769 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %for.end.unr-lcssa, label %header, !llvm.loop !2
770 ; PROLOG-BLOCK: for.end.unr-lcssa:
771 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.1, %for.body.1 ]
772 ; PROLOG-BLOCK-NEXT: br label %for.end
773 ; PROLOG-BLOCK: for.end:
774 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %for.end.unr-lcssa ]
775 ; PROLOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
776 ; PROLOG-BLOCK: for.exit2.loopexit:
777 ; PROLOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %for.body ], [ 42, %for.exiting_block.1 ]
778 ; PROLOG-BLOCK-NEXT: br label %for.exit2
779 ; PROLOG-BLOCK: for.exit2:
780 ; PROLOG-BLOCK-NEXT: %retval = phi i32 [ 0, %header.prol ], [ 42, %for.exiting_block.prol ], [ %retval.ph, %for.exit2.loopexit ]
781 ; PROLOG-BLOCK-NEXT: ret i32 %retval
789 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
790 %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
791 br i1 false, label %for.exit2, label %for.exiting_block
794 %cmp = icmp eq i64 %n, 42
795 br i1 %cmp, label %for.exit2, label %for.body
798 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
799 %0 = load i32, i32* %arrayidx, align 4
800 %add = add nsw i32 %0, %sum.02
801 %indvars.iv.next = add i64 %indvars.iv, 1
802 %exitcond = icmp eq i64 %indvars.iv.next, %n
803 br i1 %exitcond, label %for.end, label %header
805 for.end: ; preds = %for.body
806 %sum.0.lcssa = phi i32 [ %add, %for.body ]
810 %retval = phi i32 [ %sum.02, %header ], [ 42, %for.exiting_block ]
814 ; test with two exiting and three exit blocks.
815 ; the non-latch exiting block has a switch.
816 define void @test3(i64 %trip, i64 %add) {
817 ; EPILOG-LABEL: @test3(
818 ; EPILOG-NEXT: entry:
819 ; EPILOG-NEXT: %0 = add i64 %trip, -1
820 ; EPILOG-NEXT: %xtraiter = and i64 %trip, 7
821 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
822 ; EPILOG-NEXT: br i1 %1, label %exit2.loopexit.unr-lcssa, label %entry.new
824 ; EPILOG-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
825 ; EPILOG-NEXT: br label %loop_header
826 ; EPILOG: loop_header:
827 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
828 ; EPILOG-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
829 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
830 ; EPILOG-NEXT: br i1 undef, label %loop_latch, label %loop_exiting_bb1
831 ; EPILOG: loop_exiting_bb1:
832 ; EPILOG-NEXT: switch i64 %sum, label %loop_latch [
833 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
834 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
836 ; EPILOG: exit3.loopexit:
837 ; EPILOG-NEXT: br label %exit3
838 ; EPILOG: exit3.loopexit2:
839 ; EPILOG-NEXT: br label %exit3
841 ; EPILOG-NEXT: ret void
842 ; EPILOG: loop_latch:
843 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
844 ; EPILOG-NEXT: %sum.next = add i64 %sum, %add
845 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
846 ; EPILOG-NEXT: br i1 undef, label %loop_latch.1, label %loop_exiting_bb1.1
847 ; EPILOG: loop_exiting_bb1.1:
848 ; EPILOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
849 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
850 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
852 ; EPILOG: loop_latch.1:
853 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
854 ; EPILOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
855 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
856 ; EPILOG-NEXT: br i1 undef, label %loop_latch.2, label %loop_exiting_bb1.2
857 ; EPILOG: loop_exiting_bb1.2:
858 ; EPILOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
859 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
860 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
862 ; EPILOG: loop_latch.2:
863 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
864 ; EPILOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
865 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
866 ; EPILOG-NEXT: br i1 undef, label %loop_latch.3, label %loop_exiting_bb1.3
867 ; EPILOG: loop_exiting_bb1.3:
868 ; EPILOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
869 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
870 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
872 ; EPILOG: loop_latch.3:
873 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
874 ; EPILOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
875 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
876 ; EPILOG-NEXT: br i1 undef, label %loop_latch.4, label %loop_exiting_bb1.4
877 ; EPILOG: loop_exiting_bb1.4:
878 ; EPILOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
879 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
880 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
882 ; EPILOG: loop_latch.4:
883 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
884 ; EPILOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
885 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
886 ; EPILOG-NEXT: br i1 undef, label %loop_latch.5, label %loop_exiting_bb1.5
887 ; EPILOG: loop_exiting_bb1.5:
888 ; EPILOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
889 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
890 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
892 ; EPILOG: loop_latch.5:
893 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
894 ; EPILOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
895 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
896 ; EPILOG-NEXT: br i1 undef, label %loop_latch.6, label %loop_exiting_bb1.6
897 ; EPILOG: loop_exiting_bb1.6:
898 ; EPILOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
899 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
900 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
902 ; EPILOG: loop_latch.6:
903 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
904 ; EPILOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
905 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
906 ; EPILOG-NEXT: br i1 undef, label %loop_latch.7, label %loop_exiting_bb1.7
907 ; EPILOG: loop_exiting_bb1.7:
908 ; EPILOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
909 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
910 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
912 ; EPILOG: loop_latch.7:
913 ; EPILOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv_next.6, 1
914 ; EPILOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
915 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
916 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
917 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit
918 ; EPILOG: exit1.loopexit:
919 ; EPILOG-NEXT: br label %exit1
920 ; EPILOG: exit1.loopexit1:
921 ; EPILOG-NEXT: br label %exit1
923 ; EPILOG-NEXT: ret void
924 ; EPILOG: exit2.loopexit.unr-lcssa.loopexit:
925 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
926 ; EPILOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
927 ; EPILOG-NEXT: br label %exit2.loopexit.unr-lcssa
928 ; EPILOG: exit2.loopexit.unr-lcssa:
929 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
930 ; EPILOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
931 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
932 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
933 ; EPILOG: loop_header.epil.preheader:
934 ; EPILOG-NEXT: br label %loop_header.epil
935 ; EPILOG: loop_header.epil:
936 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
937 ; EPILOG-NEXT: %sum.epil = phi i64 [ %sum.unr, %loop_header.epil.preheader ], [ %sum.next.epil, %loop_latch.epil ]
938 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
939 ; EPILOG-NEXT: br i1 undef, label %loop_latch.epil, label %loop_exiting_bb1.epil
940 ; EPILOG: loop_exiting_bb1.epil:
941 ; EPILOG-NEXT: switch i64 %sum.epil, label %loop_latch.epil [
942 ; EPILOG-NEXT: i64 24, label %exit1.loopexit1
943 ; EPILOG-NEXT: i64 42, label %exit3.loopexit2
945 ; EPILOG: loop_latch.epil:
946 ; EPILOG-NEXT: %iv_next.epil = add nuw nsw i64 %iv.epil, 1
947 ; EPILOG-NEXT: %sum.next.epil = add i64 %sum.epil, %add
948 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
949 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
950 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
951 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.loopexit.epilog-lcssa, !llvm.loop !3
952 ; EPILOG: exit2.loopexit.epilog-lcssa:
953 ; EPILOG-NEXT: br label %exit2.loopexit
954 ; EPILOG: exit2.loopexit:
955 ; EPILOG-NEXT: ret void
957 ; EPILOG-BLOCK-LABEL: @test3(
958 ; EPILOG-BLOCK-NEXT: entry:
959 ; EPILOG-BLOCK-NEXT: %0 = add i64 %trip, -1
960 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
961 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
962 ; EPILOG-BLOCK-NEXT: br i1 %1, label %exit2.loopexit.unr-lcssa, label %entry.new
963 ; EPILOG-BLOCK: entry.new:
964 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
965 ; EPILOG-BLOCK-NEXT: br label %loop_header
966 ; EPILOG-BLOCK: loop_header:
967 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
968 ; EPILOG-BLOCK-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
969 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
970 ; EPILOG-BLOCK-NEXT: br i1 undef, label %loop_latch, label %loop_exiting_bb1
971 ; EPILOG-BLOCK: loop_exiting_bb1:
972 ; EPILOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
973 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
974 ; EPILOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
975 ; EPILOG-BLOCK-NEXT: ]
976 ; EPILOG-BLOCK: exit3.loopexit:
977 ; EPILOG-BLOCK-NEXT: br label %exit3
978 ; EPILOG-BLOCK: exit3:
979 ; EPILOG-BLOCK-NEXT: ret void
980 ; EPILOG-BLOCK: loop_latch:
981 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
982 ; EPILOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
983 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
984 ; EPILOG-BLOCK-NEXT: br i1 undef, label %loop_latch.1, label %loop_exiting_bb1.1
985 ; EPILOG-BLOCK: loop_exiting_bb1.1:
986 ; EPILOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
987 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
988 ; EPILOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
989 ; EPILOG-BLOCK-NEXT: ]
990 ; EPILOG-BLOCK: loop_latch.1:
991 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
992 ; EPILOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
993 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
994 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
995 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit, !llvm.loop !3
996 ; EPILOG-BLOCK: exit1.loopexit:
997 ; EPILOG-BLOCK-NEXT: br label %exit1
998 ; EPILOG-BLOCK: exit1:
999 ; EPILOG-BLOCK-NEXT: ret void
1000 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa.loopexit:
1001 ; EPILOG-BLOCK-NEXT: %sum.unr.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
1002 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit.unr-lcssa
1003 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa:
1004 ; EPILOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
1005 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1006 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
1007 ; EPILOG-BLOCK: loop_header.epil.preheader:
1008 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
1009 ; EPILOG-BLOCK: loop_header.epil:
1010 ; EPILOG-BLOCK-NEXT: br i1 undef, label %loop_latch.epil, label %loop_exiting_bb1.epil
1011 ; EPILOG-BLOCK: loop_exiting_bb1.epil:
1012 ; EPILOG-BLOCK-NEXT: switch i64 %sum.unr, label %loop_latch.epil [
1013 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1
1014 ; EPILOG-BLOCK-NEXT: i64 42, label %exit3
1015 ; EPILOG-BLOCK-NEXT: ]
1016 ; EPILOG-BLOCK: loop_latch.epil:
1017 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit
1018 ; EPILOG-BLOCK: exit2.loopexit:
1019 ; EPILOG-BLOCK-NEXT: ret void
1021 ; PROLOG-LABEL: @test3(
1022 ; PROLOG-NEXT: entry:
1023 ; PROLOG-NEXT: %0 = add i64 %trip, -1
1024 ; PROLOG-NEXT: %xtraiter = and i64 %trip, 7
1025 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1026 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
1027 ; PROLOG: loop_header.prol.preheader:
1028 ; PROLOG-NEXT: br label %loop_header.prol
1029 ; PROLOG: loop_header.prol:
1030 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
1031 ; PROLOG-NEXT: %sum.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %sum.next.prol, %loop_latch.prol ]
1032 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
1033 ; PROLOG-NEXT: br i1 undef, label %loop_latch.prol, label %loop_exiting_bb1.prol
1034 ; PROLOG: loop_exiting_bb1.prol:
1035 ; PROLOG-NEXT: switch i64 %sum.prol, label %loop_latch.prol [
1036 ; PROLOG-NEXT: i64 24, label %exit1.loopexit1
1037 ; PROLOG-NEXT: i64 42, label %exit3.loopexit2
1039 ; PROLOG: loop_latch.prol:
1040 ; PROLOG-NEXT: %iv_next.prol = add nuw nsw i64 %iv.prol, 1
1041 ; PROLOG-NEXT: %sum.next.prol = add i64 %sum.prol, %add
1042 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
1043 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
1044 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
1045 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !3
1046 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
1047 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
1048 ; PROLOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.prol, %loop_latch.prol ]
1049 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
1050 ; PROLOG: loop_header.prol.loopexit:
1051 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
1052 ; PROLOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
1053 ; PROLOG-NEXT: %1 = icmp ult i64 %0, 7
1054 ; PROLOG-NEXT: br i1 %1, label %exit2.loopexit, label %entry.new
1055 ; PROLOG: entry.new:
1056 ; PROLOG-NEXT: br label %loop_header
1057 ; PROLOG: loop_header:
1058 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
1059 ; PROLOG-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
1060 ; PROLOG-NEXT: br i1 undef, label %loop_latch, label %loop_exiting_bb1
1061 ; PROLOG: loop_exiting_bb1:
1062 ; PROLOG-NEXT: switch i64 %sum, label %loop_latch [
1063 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1064 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1066 ; PROLOG: exit3.loopexit:
1067 ; PROLOG-NEXT: br label %exit3
1068 ; PROLOG: exit3.loopexit2:
1069 ; PROLOG-NEXT: br label %exit3
1071 ; PROLOG-NEXT: ret void
1072 ; PROLOG: loop_latch:
1073 ; PROLOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
1074 ; PROLOG-NEXT: %sum.next = add i64 %sum, %add
1075 ; PROLOG-NEXT: br i1 undef, label %loop_latch.1, label %loop_exiting_bb1.1
1076 ; PROLOG: loop_exiting_bb1.1:
1077 ; PROLOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
1078 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1079 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1081 ; PROLOG: loop_latch.1:
1082 ; PROLOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
1083 ; PROLOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
1084 ; PROLOG-NEXT: br i1 undef, label %loop_latch.2, label %loop_exiting_bb1.2
1085 ; PROLOG: loop_exiting_bb1.2:
1086 ; PROLOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
1087 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1088 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1090 ; PROLOG: loop_latch.2:
1091 ; PROLOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
1092 ; PROLOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
1093 ; PROLOG-NEXT: br i1 undef, label %loop_latch.3, label %loop_exiting_bb1.3
1094 ; PROLOG: loop_exiting_bb1.3:
1095 ; PROLOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
1096 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1097 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1099 ; PROLOG: loop_latch.3:
1100 ; PROLOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
1101 ; PROLOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
1102 ; PROLOG-NEXT: br i1 undef, label %loop_latch.4, label %loop_exiting_bb1.4
1103 ; PROLOG: loop_exiting_bb1.4:
1104 ; PROLOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
1105 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1106 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1108 ; PROLOG: loop_latch.4:
1109 ; PROLOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
1110 ; PROLOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
1111 ; PROLOG-NEXT: br i1 undef, label %loop_latch.5, label %loop_exiting_bb1.5
1112 ; PROLOG: loop_exiting_bb1.5:
1113 ; PROLOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
1114 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1115 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1117 ; PROLOG: loop_latch.5:
1118 ; PROLOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
1119 ; PROLOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
1120 ; PROLOG-NEXT: br i1 undef, label %loop_latch.6, label %loop_exiting_bb1.6
1121 ; PROLOG: loop_exiting_bb1.6:
1122 ; PROLOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
1123 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1124 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1126 ; PROLOG: loop_latch.6:
1127 ; PROLOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
1128 ; PROLOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
1129 ; PROLOG-NEXT: br i1 undef, label %loop_latch.7, label %loop_exiting_bb1.7
1130 ; PROLOG: loop_exiting_bb1.7:
1131 ; PROLOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
1132 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1133 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1135 ; PROLOG: loop_latch.7:
1136 ; PROLOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv_next.6, 1
1137 ; PROLOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
1138 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
1139 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa
1140 ; PROLOG: exit1.loopexit:
1141 ; PROLOG-NEXT: br label %exit1
1142 ; PROLOG: exit1.loopexit1:
1143 ; PROLOG-NEXT: br label %exit1
1145 ; PROLOG-NEXT: ret void
1146 ; PROLOG: exit2.loopexit.unr-lcssa:
1147 ; PROLOG-NEXT: br label %exit2.loopexit
1148 ; PROLOG: exit2.loopexit:
1149 ; PROLOG-NEXT: ret void
1151 ; PROLOG-BLOCK-LABEL: @test3(
1152 ; PROLOG-BLOCK-NEXT: entry:
1153 ; PROLOG-BLOCK-NEXT: %0 = add i64 %trip, -1
1154 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
1155 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1156 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
1157 ; PROLOG-BLOCK: loop_header.prol.preheader:
1158 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
1159 ; PROLOG-BLOCK: loop_header.prol:
1160 ; PROLOG-BLOCK-NEXT: br i1 undef, label %loop_latch.prol, label %loop_exiting_bb1.prol
1161 ; PROLOG-BLOCK: loop_exiting_bb1.prol:
1162 ; PROLOG-BLOCK-NEXT: switch i64 0, label %loop_latch.prol [
1163 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1
1164 ; PROLOG-BLOCK-NEXT: i64 42, label %exit3
1165 ; PROLOG-BLOCK-NEXT: ]
1166 ; PROLOG-BLOCK: loop_latch.prol:
1167 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
1168 ; PROLOG-BLOCK: loop_header.prol.loopexit:
1169 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
1170 ; PROLOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %add, %loop_latch.prol ]
1171 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
1172 ; PROLOG-BLOCK-NEXT: br i1 %1, label %exit2.loopexit, label %entry.new
1173 ; PROLOG-BLOCK: entry.new:
1174 ; PROLOG-BLOCK-NEXT: br label %loop_header
1175 ; PROLOG-BLOCK: loop_header:
1176 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
1177 ; PROLOG-BLOCK-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
1178 ; PROLOG-BLOCK-NEXT: br i1 undef, label %loop_latch, label %loop_exiting_bb1
1179 ; PROLOG-BLOCK: loop_exiting_bb1:
1180 ; PROLOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
1181 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
1182 ; PROLOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
1183 ; PROLOG-BLOCK-NEXT: ]
1184 ; PROLOG-BLOCK: exit3.loopexit:
1185 ; PROLOG-BLOCK-NEXT: br label %exit3
1186 ; PROLOG-BLOCK: exit3:
1187 ; PROLOG-BLOCK-NEXT: ret void
1188 ; PROLOG-BLOCK: loop_latch:
1189 ; PROLOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
1190 ; PROLOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
1191 ; PROLOG-BLOCK-NEXT: br i1 undef, label %loop_latch.1, label %loop_exiting_bb1.1
1192 ; PROLOG-BLOCK: loop_exiting_bb1.1:
1193 ; PROLOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
1194 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
1195 ; PROLOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
1196 ; PROLOG-BLOCK-NEXT: ]
1197 ; PROLOG-BLOCK: loop_latch.1:
1198 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
1199 ; PROLOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
1200 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
1201 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa, !llvm.loop !3
1202 ; PROLOG-BLOCK: exit1.loopexit:
1203 ; PROLOG-BLOCK-NEXT: br label %exit1
1204 ; PROLOG-BLOCK: exit1:
1205 ; PROLOG-BLOCK-NEXT: ret void
1206 ; PROLOG-BLOCK: exit2.loopexit.unr-lcssa:
1207 ; PROLOG-BLOCK-NEXT: br label %exit2.loopexit
1208 ; PROLOG-BLOCK: exit2.loopexit:
1209 ; PROLOG-BLOCK-NEXT: ret void
1213 br label %loop_header
1216 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
1217 %sum = phi i64 [ 0, %entry ], [ %sum.next, %loop_latch ]
1218 br i1 undef, label %loop_latch, label %loop_exiting_bb1
1221 switch i64 %sum, label %loop_latch [
1222 i64 24, label %exit1
1223 i64 42, label %exit3
1230 %iv_next = add nuw nsw i64 %iv, 1
1231 %sum.next = add i64 %sum, %add
1232 %cmp = icmp ne i64 %iv_next, %trip
1233 br i1 %cmp, label %loop_header, label %exit2.loopexit
1242 ; FIXME: Support multiple exiting blocks to the same latch exit block.
1243 ; Three exiting blocks where header and latch exit to same LatchExit.
1244 define i32 @hdr_latch_same_exit(i32* nocapture %a, i64 %n, i1 %cond) {
1245 ; EPILOG-LABEL: @hdr_latch_same_exit(
1246 ; EPILOG-NEXT: entry:
1247 ; EPILOG-NEXT: %0 = add i64 %n, -1
1248 ; EPILOG-NEXT: %xtraiter = and i64 %n, 7
1249 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
1250 ; EPILOG-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %entry.new
1251 ; EPILOG: entry.new:
1252 ; EPILOG-NEXT: %unroll_iter = sub i64 %n, %xtraiter
1253 ; EPILOG-NEXT: br label %header
1255 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1256 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
1257 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
1258 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block
1259 ; EPILOG: for.exiting_block:
1260 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
1261 ; EPILOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1263 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1264 ; EPILOG-NEXT: %2 = load i32, i32* %arrayidx, align 4
1265 ; EPILOG-NEXT: %add = add nsw i32 %2, %sum.02
1266 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1267 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
1268 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.1
1269 ; EPILOG: for.exiting_block.1:
1270 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1271 ; EPILOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1273 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1274 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
1275 ; EPILOG-NEXT: %add.1 = add nsw i32 %3, %add
1276 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
1277 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
1278 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.2
1279 ; EPILOG: for.exiting_block.2:
1280 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1281 ; EPILOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
1283 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
1284 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.2, align 4
1285 ; EPILOG-NEXT: %add.2 = add nsw i32 %4, %add.1
1286 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
1287 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
1288 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.3
1289 ; EPILOG: for.exiting_block.3:
1290 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1291 ; EPILOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
1293 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
1294 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.3, align 4
1295 ; EPILOG-NEXT: %add.3 = add nsw i32 %5, %add.2
1296 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
1297 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
1298 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.4
1299 ; EPILOG: for.exiting_block.4:
1300 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1301 ; EPILOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
1303 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
1304 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.4, align 4
1305 ; EPILOG-NEXT: %add.4 = add nsw i32 %6, %add.3
1306 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
1307 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
1308 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.5
1309 ; EPILOG: for.exiting_block.5:
1310 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1311 ; EPILOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
1313 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
1314 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.5, align 4
1315 ; EPILOG-NEXT: %add.5 = add nsw i32 %7, %add.4
1316 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
1317 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
1318 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.6
1319 ; EPILOG: for.exiting_block.6:
1320 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1321 ; EPILOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
1323 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
1324 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.6, align 4
1325 ; EPILOG-NEXT: %add.6 = add nsw i32 %8, %add.5
1326 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
1327 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
1328 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.7
1329 ; EPILOG: for.exiting_block.7:
1330 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1331 ; EPILOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
1333 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
1334 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.7, align 4
1335 ; EPILOG-NEXT: %add.7 = add nsw i32 %9, %add.6
1336 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
1337 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
1338 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
1339 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
1340 ; EPILOG: latchExit.unr-lcssa.loopexit:
1341 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
1342 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
1343 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
1344 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
1345 ; EPILOG: latchExit.unr-lcssa:
1346 ; EPILOG-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1347 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1348 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1349 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1350 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1351 ; EPILOG: header.epil.preheader:
1352 ; EPILOG-NEXT: br label %header.epil
1353 ; EPILOG: header.epil:
1354 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
1355 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
1356 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
1357 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit2, label %for.exiting_block.epil
1358 ; EPILOG: for.exiting_block.epil:
1359 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
1360 ; EPILOG-NEXT: br i1 %cmp.epil, label %for.exit2.loopexit4, label %latch.epil
1361 ; EPILOG: latch.epil:
1362 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
1363 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.epil, align 4
1364 ; EPILOG-NEXT: %add.epil = add nsw i32 %10, %sum.02.epil
1365 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
1366 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
1367 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
1368 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
1369 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit2, !llvm.loop !4
1370 ; EPILOG: latchExit.epilog-lcssa.loopexit:
1371 ; EPILOG-NEXT: %result.ph1.ph = phi i32 [ 0, %header ], [ 0, %latch ], [ 0, %latch.1 ], [ 0, %latch.2 ], [ 0, %latch.3 ], [ 0, %latch.4 ], [ 0, %latch.5 ], [ 0, %latch.6 ]
1372 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1373 ; EPILOG: latchExit.epilog-lcssa.loopexit2:
1374 ; EPILOG-NEXT: %result.ph1.ph3 = phi i32 [ 0, %header.epil ], [ %add.epil, %latch.epil ]
1375 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1376 ; EPILOG: latchExit.epilog-lcssa:
1377 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph3, %latchExit.epilog-lcssa.loopexit2 ]
1378 ; EPILOG-NEXT: br label %latchExit
1379 ; EPILOG: latchExit:
1380 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1381 ; EPILOG-NEXT: ret i32 %result
1382 ; EPILOG: for.exit2.loopexit:
1383 ; EPILOG-NEXT: br label %for.exit2
1384 ; EPILOG: for.exit2.loopexit4:
1385 ; EPILOG-NEXT: br label %for.exit2
1386 ; EPILOG: for.exit2:
1387 ; EPILOG-NEXT: ret i32 42
1389 ; EPILOG-BLOCK-LABEL: @hdr_latch_same_exit(
1390 ; EPILOG-BLOCK-NEXT: entry:
1391 ; EPILOG-BLOCK-NEXT: %0 = add i64 %n, -1
1392 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
1393 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
1394 ; EPILOG-BLOCK-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %entry.new
1395 ; EPILOG-BLOCK: entry.new:
1396 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %n, %xtraiter
1397 ; EPILOG-BLOCK-NEXT: br label %header
1398 ; EPILOG-BLOCK: header:
1399 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
1400 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
1401 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
1402 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block
1403 ; EPILOG-BLOCK: for.exiting_block:
1404 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
1405 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1406 ; EPILOG-BLOCK: latch:
1407 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1408 ; EPILOG-BLOCK-NEXT: %2 = load i32, i32* %arrayidx, align 4
1409 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %2, %sum.02
1410 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1411 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
1412 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.1
1413 ; EPILOG-BLOCK: for.exiting_block.1:
1414 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
1415 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1416 ; EPILOG-BLOCK: latch.1:
1417 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1418 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
1419 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %3, %add
1420 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1421 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
1422 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
1423 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !4
1424 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
1425 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
1426 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
1427 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
1428 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
1429 ; EPILOG-BLOCK: latchExit.unr-lcssa:
1430 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1431 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1432 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1433 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1434 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1435 ; EPILOG-BLOCK: header.epil.preheader:
1436 ; EPILOG-BLOCK-NEXT: br label %header.epil
1437 ; EPILOG-BLOCK: header.epil:
1438 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %latchExit.epilog-lcssa, label %for.exiting_block.epil
1439 ; EPILOG-BLOCK: for.exiting_block.epil:
1440 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
1441 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %for.exit2, label %latch.epil
1442 ; EPILOG-BLOCK: latch.epil:
1443 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
1444 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.epil, align 4
1445 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %4, %sum.02.unr
1446 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1447 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
1448 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ 0, %header ], [ 0, %latch ]
1449 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1450 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
1451 ; EPILOG-BLOCK-NEXT: %result.ph1 = phi i32 [ %add.epil, %latch.epil ], [ 0, %header.epil ], [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
1452 ; EPILOG-BLOCK-NEXT: br label %latchExit
1453 ; EPILOG-BLOCK: latchExit:
1454 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1455 ; EPILOG-BLOCK-NEXT: ret i32 %result
1456 ; EPILOG-BLOCK: for.exit2.loopexit:
1457 ; EPILOG-BLOCK-NEXT: br label %for.exit2
1458 ; EPILOG-BLOCK: for.exit2:
1459 ; EPILOG-BLOCK-NEXT: ret i32 42
1461 ; PROLOG-LABEL: @hdr_latch_same_exit(
1462 ; PROLOG-NEXT: entry:
1463 ; PROLOG-NEXT: %0 = add i64 %n, -1
1464 ; PROLOG-NEXT: %xtraiter = and i64 %n, 7
1465 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1466 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1467 ; PROLOG: header.prol.preheader:
1468 ; PROLOG-NEXT: br label %header.prol
1469 ; PROLOG: header.prol:
1470 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1471 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1472 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
1473 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit1, label %for.exiting_block.prol
1474 ; PROLOG: for.exiting_block.prol:
1475 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
1476 ; PROLOG-NEXT: br i1 %cmp.prol, label %for.exit2.loopexit3, label %latch.prol
1477 ; PROLOG: latch.prol:
1478 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
1479 ; PROLOG-NEXT: %1 = load i32, i32* %arrayidx.prol, align 4
1480 ; PROLOG-NEXT: %add.prol = add nsw i32 %1, %sum.02.prol
1481 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
1482 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
1483 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
1484 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
1485 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !4
1486 ; PROLOG: header.prol.loopexit.unr-lcssa:
1487 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1488 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
1489 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1490 ; PROLOG-NEXT: br label %header.prol.loopexit
1491 ; PROLOG: header.prol.loopexit:
1492 ; PROLOG-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
1493 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
1494 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
1495 ; PROLOG-NEXT: %2 = icmp ult i64 %0, 7
1496 ; PROLOG-NEXT: br i1 %2, label %latchExit, label %entry.new
1497 ; PROLOG: entry.new:
1498 ; PROLOG-NEXT: br label %header
1500 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1501 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
1502 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block
1503 ; PROLOG: for.exiting_block:
1504 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
1505 ; PROLOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1507 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1508 ; PROLOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
1509 ; PROLOG-NEXT: %add = add nsw i32 %3, %sum.02
1510 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
1511 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.1
1512 ; PROLOG: for.exiting_block.1:
1513 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1514 ; PROLOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1516 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1517 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
1518 ; PROLOG-NEXT: %add.1 = add nsw i32 %4, %add
1519 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1520 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.2
1521 ; PROLOG: for.exiting_block.2:
1522 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1523 ; PROLOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
1525 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
1526 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
1527 ; PROLOG-NEXT: %add.2 = add nsw i32 %5, %add.1
1528 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
1529 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.3
1530 ; PROLOG: for.exiting_block.3:
1531 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1532 ; PROLOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
1534 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
1535 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
1536 ; PROLOG-NEXT: %add.3 = add nsw i32 %6, %add.2
1537 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
1538 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.4
1539 ; PROLOG: for.exiting_block.4:
1540 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1541 ; PROLOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
1543 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
1544 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
1545 ; PROLOG-NEXT: %add.4 = add nsw i32 %7, %add.3
1546 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
1547 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.5
1548 ; PROLOG: for.exiting_block.5:
1549 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1550 ; PROLOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
1552 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
1553 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
1554 ; PROLOG-NEXT: %add.5 = add nsw i32 %8, %add.4
1555 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
1556 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.6
1557 ; PROLOG: for.exiting_block.6:
1558 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1559 ; PROLOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
1561 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
1562 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
1563 ; PROLOG-NEXT: %add.6 = add nsw i32 %9, %add.5
1564 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
1565 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.7
1566 ; PROLOG: for.exiting_block.7:
1567 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1568 ; PROLOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
1570 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
1571 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
1572 ; PROLOG-NEXT: %add.7 = add nsw i32 %10, %add.6
1573 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
1574 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
1575 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
1576 ; PROLOG: latchExit.unr-lcssa.loopexit:
1577 ; PROLOG-NEXT: %result.ph.ph = phi i32 [ 0, %header ], [ 0, %latch ], [ 0, %latch.1 ], [ 0, %latch.2 ], [ 0, %latch.3 ], [ 0, %latch.4 ], [ 0, %latch.5 ], [ 0, %latch.6 ], [ %add.7, %latch.7 ]
1578 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
1579 ; PROLOG: latchExit.unr-lcssa.loopexit1:
1580 ; PROLOG-NEXT: %result.ph.ph2 = phi i32 [ 0, %header.prol ]
1581 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
1582 ; PROLOG: latchExit.unr-lcssa:
1583 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph2, %latchExit.unr-lcssa.loopexit1 ]
1584 ; PROLOG-NEXT: br label %latchExit
1585 ; PROLOG: latchExit:
1586 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
1587 ; PROLOG-NEXT: ret i32 %result
1588 ; PROLOG: for.exit2.loopexit:
1589 ; PROLOG-NEXT: br label %for.exit2
1590 ; PROLOG: for.exit2.loopexit3:
1591 ; PROLOG-NEXT: br label %for.exit2
1592 ; PROLOG: for.exit2:
1593 ; PROLOG-NEXT: ret i32 42
1595 ; PROLOG-BLOCK-LABEL: @hdr_latch_same_exit(
1596 ; PROLOG-BLOCK-NEXT: entry:
1597 ; PROLOG-BLOCK-NEXT: %0 = add i64 %n, -1
1598 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
1599 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1600 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1601 ; PROLOG-BLOCK: header.prol.preheader:
1602 ; PROLOG-BLOCK-NEXT: br label %header.prol
1603 ; PROLOG-BLOCK: header.prol:
1604 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %latchExit.unr-lcssa, label %for.exiting_block.prol
1605 ; PROLOG-BLOCK: for.exiting_block.prol:
1606 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
1607 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %for.exit2, label %latch.prol
1608 ; PROLOG-BLOCK: latch.prol:
1609 ; PROLOG-BLOCK-NEXT: %1 = load i32, i32* %a, align 4
1610 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
1611 ; PROLOG-BLOCK: header.prol.loopexit:
1612 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %1, %latch.prol ]
1613 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
1614 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %1, %latch.prol ]
1615 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %0, 1
1616 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latchExit, label %entry.new
1617 ; PROLOG-BLOCK: entry.new:
1618 ; PROLOG-BLOCK-NEXT: br label %header
1619 ; PROLOG-BLOCK: header:
1620 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
1621 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
1622 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block
1623 ; PROLOG-BLOCK: for.exiting_block:
1624 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
1625 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1626 ; PROLOG-BLOCK: latch:
1627 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1628 ; PROLOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
1629 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
1630 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
1631 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.1
1632 ; PROLOG-BLOCK: for.exiting_block.1:
1633 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
1634 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1635 ; PROLOG-BLOCK: latch.1:
1636 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1637 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
1638 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
1639 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1640 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
1641 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !4
1642 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
1643 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ 0, %header ], [ 0, %latch ], [ %add.1, %latch.1 ]
1644 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
1645 ; PROLOG-BLOCK: latchExit.unr-lcssa:
1646 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 0, %header.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1647 ; PROLOG-BLOCK-NEXT: br label %latchExit
1648 ; PROLOG-BLOCK: latchExit:
1649 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
1650 ; PROLOG-BLOCK-NEXT: ret i32 %result
1651 ; PROLOG-BLOCK: for.exit2.loopexit:
1652 ; PROLOG-BLOCK-NEXT: br label %for.exit2
1653 ; PROLOG-BLOCK: for.exit2:
1654 ; PROLOG-BLOCK-NEXT: ret i32 42
1661 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
1662 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
1663 br i1 %cond, label %latchExit, label %for.exiting_block
1666 %cmp = icmp eq i64 %n, 42
1667 br i1 %cmp, label %for.exit2, label %latch
1669 latch: ; preds = %latch, %entry
1670 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1671 %0 = load i32, i32* %arrayidx, align 4
1672 %add = add nsw i32 %0, %sum.02
1673 %indvars.iv.next = add i64 %indvars.iv, 1
1674 %exitcond = icmp eq i64 %indvars.iv.next, %n
1675 br i1 %exitcond, label %latchExit, label %header
1677 latchExit: ; preds = %latch, %entry
1678 %result = phi i32 [ 0, %header ], [ %add, %latch ]
1685 ; Two exiting blocks to latch where the exiting blocks are Latch and a
1687 ; FIXME: We should unroll this loop.
1688 define i32 @otherblock_latch_same_exit(i32* nocapture %a, i64 %n, i1 %cond) {
1689 ; EPILOG-LABEL: @otherblock_latch_same_exit(
1690 ; EPILOG-NEXT: entry:
1691 ; EPILOG-NEXT: %0 = add i64 %n, -1
1692 ; EPILOG-NEXT: %xtraiter = and i64 %n, 7
1693 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
1694 ; EPILOG-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %entry.new
1695 ; EPILOG: entry.new:
1696 ; EPILOG-NEXT: %unroll_iter = sub i64 %n, %xtraiter
1697 ; EPILOG-NEXT: br label %header
1699 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1700 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
1701 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
1702 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
1703 ; EPILOG: for.exiting_block:
1704 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
1705 ; EPILOG-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
1707 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1708 ; EPILOG-NEXT: %2 = load i32, i32* %arrayidx, align 4
1709 ; EPILOG-NEXT: %add = add nsw i32 %2, %sum.02
1710 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1711 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
1712 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
1713 ; EPILOG: for.exiting_block.1:
1714 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1715 ; EPILOG-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
1717 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1718 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
1719 ; EPILOG-NEXT: %add.1 = add nsw i32 %3, %add
1720 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
1721 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
1722 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
1723 ; EPILOG: for.exiting_block.2:
1724 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1725 ; EPILOG-NEXT: br i1 %cmp.2, label %latchExit.epilog-lcssa.loopexit, label %latch.2
1727 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
1728 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.2, align 4
1729 ; EPILOG-NEXT: %add.2 = add nsw i32 %4, %add.1
1730 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
1731 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
1732 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
1733 ; EPILOG: for.exiting_block.3:
1734 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1735 ; EPILOG-NEXT: br i1 %cmp.3, label %latchExit.epilog-lcssa.loopexit, label %latch.3
1737 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
1738 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.3, align 4
1739 ; EPILOG-NEXT: %add.3 = add nsw i32 %5, %add.2
1740 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
1741 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
1742 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
1743 ; EPILOG: for.exiting_block.4:
1744 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1745 ; EPILOG-NEXT: br i1 %cmp.4, label %latchExit.epilog-lcssa.loopexit, label %latch.4
1747 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
1748 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.4, align 4
1749 ; EPILOG-NEXT: %add.4 = add nsw i32 %6, %add.3
1750 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
1751 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
1752 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
1753 ; EPILOG: for.exiting_block.5:
1754 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1755 ; EPILOG-NEXT: br i1 %cmp.5, label %latchExit.epilog-lcssa.loopexit, label %latch.5
1757 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
1758 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.5, align 4
1759 ; EPILOG-NEXT: %add.5 = add nsw i32 %7, %add.4
1760 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
1761 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
1762 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
1763 ; EPILOG: for.exiting_block.6:
1764 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1765 ; EPILOG-NEXT: br i1 %cmp.6, label %latchExit.epilog-lcssa.loopexit, label %latch.6
1767 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
1768 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.6, align 4
1769 ; EPILOG-NEXT: %add.6 = add nsw i32 %8, %add.5
1770 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
1771 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
1772 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
1773 ; EPILOG: for.exiting_block.7:
1774 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1775 ; EPILOG-NEXT: br i1 %cmp.7, label %latchExit.epilog-lcssa.loopexit, label %latch.7
1777 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
1778 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.7, align 4
1779 ; EPILOG-NEXT: %add.7 = add nsw i32 %9, %add.6
1780 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
1781 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
1782 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
1783 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
1784 ; EPILOG: latchExit.unr-lcssa.loopexit:
1785 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
1786 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
1787 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
1788 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
1789 ; EPILOG: latchExit.unr-lcssa:
1790 ; EPILOG-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1791 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1792 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1793 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1794 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1795 ; EPILOG: header.epil.preheader:
1796 ; EPILOG-NEXT: br label %header.epil
1797 ; EPILOG: header.epil:
1798 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
1799 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
1800 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
1801 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit2, label %for.exiting_block.epil
1802 ; EPILOG: for.exiting_block.epil:
1803 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
1804 ; EPILOG-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa.loopexit3, label %latch.epil
1805 ; EPILOG: latch.epil:
1806 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
1807 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.epil, align 4
1808 ; EPILOG-NEXT: %add.epil = add nsw i32 %10, %sum.02.epil
1809 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
1810 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
1811 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
1812 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
1813 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit3, !llvm.loop !5
1814 ; EPILOG: latchExit.epilog-lcssa.loopexit:
1815 ; EPILOG-NEXT: %result.ph1.ph = phi i32 [ 2, %for.exiting_block ], [ 2, %for.exiting_block.1 ], [ 2, %for.exiting_block.2 ], [ 2, %for.exiting_block.3 ], [ 2, %for.exiting_block.4 ], [ 2, %for.exiting_block.5 ], [ 2, %for.exiting_block.6 ], [ 2, %for.exiting_block.7 ]
1816 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1817 ; EPILOG: latchExit.epilog-lcssa.loopexit3:
1818 ; EPILOG-NEXT: %result.ph1.ph4 = phi i32 [ 2, %for.exiting_block.epil ], [ %add.epil, %latch.epil ]
1819 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1820 ; EPILOG: latchExit.epilog-lcssa:
1821 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph4, %latchExit.epilog-lcssa.loopexit3 ]
1822 ; EPILOG-NEXT: br label %latchExit
1823 ; EPILOG: latchExit:
1824 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1825 ; EPILOG-NEXT: ret i32 %result
1826 ; EPILOG: for.exit2.loopexit:
1827 ; EPILOG-NEXT: br label %for.exit2
1828 ; EPILOG: for.exit2.loopexit2:
1829 ; EPILOG-NEXT: br label %for.exit2
1830 ; EPILOG: for.exit2:
1831 ; EPILOG-NEXT: ret i32 42
1833 ; EPILOG-BLOCK-LABEL: @otherblock_latch_same_exit(
1834 ; EPILOG-BLOCK-NEXT: entry:
1835 ; EPILOG-BLOCK-NEXT: %0 = add i64 %n, -1
1836 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
1837 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
1838 ; EPILOG-BLOCK-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %entry.new
1839 ; EPILOG-BLOCK: entry.new:
1840 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %n, %xtraiter
1841 ; EPILOG-BLOCK-NEXT: br label %header
1842 ; EPILOG-BLOCK: header:
1843 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
1844 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
1845 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
1846 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
1847 ; EPILOG-BLOCK: for.exiting_block:
1848 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
1849 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
1850 ; EPILOG-BLOCK: latch:
1851 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1852 ; EPILOG-BLOCK-NEXT: %2 = load i32, i32* %arrayidx, align 4
1853 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %2, %sum.02
1854 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1855 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
1856 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
1857 ; EPILOG-BLOCK: for.exiting_block.1:
1858 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
1859 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
1860 ; EPILOG-BLOCK: latch.1:
1861 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1862 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
1863 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %3, %add
1864 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1865 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
1866 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
1867 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !5
1868 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
1869 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
1870 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
1871 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
1872 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
1873 ; EPILOG-BLOCK: latchExit.unr-lcssa:
1874 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1875 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1876 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1877 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1878 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1879 ; EPILOG-BLOCK: header.epil.preheader:
1880 ; EPILOG-BLOCK-NEXT: br label %header.epil
1881 ; EPILOG-BLOCK: header.epil:
1882 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.epil
1883 ; EPILOG-BLOCK: for.exiting_block.epil:
1884 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
1885 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa, label %latch.epil
1886 ; EPILOG-BLOCK: latch.epil:
1887 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
1888 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.epil, align 4
1889 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %4, %sum.02.unr
1890 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1891 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
1892 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ 2, %for.exiting_block ], [ 2, %for.exiting_block.1 ]
1893 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1894 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
1895 ; EPILOG-BLOCK-NEXT: %result.ph1 = phi i32 [ %add.epil, %latch.epil ], [ 2, %for.exiting_block.epil ], [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
1896 ; EPILOG-BLOCK-NEXT: br label %latchExit
1897 ; EPILOG-BLOCK: latchExit:
1898 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1899 ; EPILOG-BLOCK-NEXT: ret i32 %result
1900 ; EPILOG-BLOCK: for.exit2.loopexit:
1901 ; EPILOG-BLOCK-NEXT: br label %for.exit2
1902 ; EPILOG-BLOCK: for.exit2:
1903 ; EPILOG-BLOCK-NEXT: ret i32 42
1905 ; PROLOG-LABEL: @otherblock_latch_same_exit(
1906 ; PROLOG-NEXT: entry:
1907 ; PROLOG-NEXT: %0 = add i64 %n, -1
1908 ; PROLOG-NEXT: %xtraiter = and i64 %n, 7
1909 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1910 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1911 ; PROLOG: header.prol.preheader:
1912 ; PROLOG-NEXT: br label %header.prol
1913 ; PROLOG: header.prol:
1914 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1915 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1916 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
1917 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit1, label %for.exiting_block.prol
1918 ; PROLOG: for.exiting_block.prol:
1919 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
1920 ; PROLOG-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa.loopexit2, label %latch.prol
1921 ; PROLOG: latch.prol:
1922 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
1923 ; PROLOG-NEXT: %1 = load i32, i32* %arrayidx.prol, align 4
1924 ; PROLOG-NEXT: %add.prol = add nsw i32 %1, %sum.02.prol
1925 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
1926 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
1927 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
1928 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
1929 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !5
1930 ; PROLOG: header.prol.loopexit.unr-lcssa:
1931 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1932 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
1933 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1934 ; PROLOG-NEXT: br label %header.prol.loopexit
1935 ; PROLOG: header.prol.loopexit:
1936 ; PROLOG-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
1937 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
1938 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
1939 ; PROLOG-NEXT: %2 = icmp ult i64 %0, 7
1940 ; PROLOG-NEXT: br i1 %2, label %latchExit, label %entry.new
1941 ; PROLOG: entry.new:
1942 ; PROLOG-NEXT: br label %header
1944 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1945 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
1946 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
1947 ; PROLOG: for.exiting_block:
1948 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
1949 ; PROLOG-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
1951 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1952 ; PROLOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
1953 ; PROLOG-NEXT: %add = add nsw i32 %3, %sum.02
1954 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
1955 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
1956 ; PROLOG: for.exiting_block.1:
1957 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1958 ; PROLOG-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
1960 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1961 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
1962 ; PROLOG-NEXT: %add.1 = add nsw i32 %4, %add
1963 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1964 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
1965 ; PROLOG: for.exiting_block.2:
1966 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1967 ; PROLOG-NEXT: br i1 %cmp.2, label %latchExit.unr-lcssa.loopexit, label %latch.2
1969 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
1970 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
1971 ; PROLOG-NEXT: %add.2 = add nsw i32 %5, %add.1
1972 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
1973 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
1974 ; PROLOG: for.exiting_block.3:
1975 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1976 ; PROLOG-NEXT: br i1 %cmp.3, label %latchExit.unr-lcssa.loopexit, label %latch.3
1978 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
1979 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
1980 ; PROLOG-NEXT: %add.3 = add nsw i32 %6, %add.2
1981 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
1982 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
1983 ; PROLOG: for.exiting_block.4:
1984 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1985 ; PROLOG-NEXT: br i1 %cmp.4, label %latchExit.unr-lcssa.loopexit, label %latch.4
1987 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
1988 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
1989 ; PROLOG-NEXT: %add.4 = add nsw i32 %7, %add.3
1990 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
1991 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
1992 ; PROLOG: for.exiting_block.5:
1993 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1994 ; PROLOG-NEXT: br i1 %cmp.5, label %latchExit.unr-lcssa.loopexit, label %latch.5
1996 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
1997 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
1998 ; PROLOG-NEXT: %add.5 = add nsw i32 %8, %add.4
1999 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
2000 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2001 ; PROLOG: for.exiting_block.6:
2002 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2003 ; PROLOG-NEXT: br i1 %cmp.6, label %latchExit.unr-lcssa.loopexit, label %latch.6
2005 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2006 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
2007 ; PROLOG-NEXT: %add.6 = add nsw i32 %9, %add.5
2008 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
2009 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2010 ; PROLOG: for.exiting_block.7:
2011 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2012 ; PROLOG-NEXT: br i1 %cmp.7, label %latchExit.unr-lcssa.loopexit, label %latch.7
2014 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2015 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
2016 ; PROLOG-NEXT: %add.7 = add nsw i32 %10, %add.6
2017 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2018 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
2019 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
2020 ; PROLOG: latchExit.unr-lcssa.loopexit:
2021 ; PROLOG-NEXT: %result.ph.ph = phi i32 [ 2, %for.exiting_block ], [ 2, %for.exiting_block.1 ], [ 2, %for.exiting_block.2 ], [ 2, %for.exiting_block.3 ], [ 2, %for.exiting_block.4 ], [ 2, %for.exiting_block.5 ], [ 2, %for.exiting_block.6 ], [ 2, %for.exiting_block.7 ], [ %add.7, %latch.7 ]
2022 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2023 ; PROLOG: latchExit.unr-lcssa.loopexit2:
2024 ; PROLOG-NEXT: %result.ph.ph3 = phi i32 [ 2, %for.exiting_block.prol ]
2025 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2026 ; PROLOG: latchExit.unr-lcssa:
2027 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph3, %latchExit.unr-lcssa.loopexit2 ]
2028 ; PROLOG-NEXT: br label %latchExit
2029 ; PROLOG: latchExit:
2030 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2031 ; PROLOG-NEXT: ret i32 %result
2032 ; PROLOG: for.exit2.loopexit:
2033 ; PROLOG-NEXT: br label %for.exit2
2034 ; PROLOG: for.exit2.loopexit1:
2035 ; PROLOG-NEXT: br label %for.exit2
2036 ; PROLOG: for.exit2:
2037 ; PROLOG-NEXT: ret i32 42
2039 ; PROLOG-BLOCK-LABEL: @otherblock_latch_same_exit(
2040 ; PROLOG-BLOCK-NEXT: entry:
2041 ; PROLOG-BLOCK-NEXT: %0 = add i64 %n, -1
2042 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
2043 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2044 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2045 ; PROLOG-BLOCK: header.prol.preheader:
2046 ; PROLOG-BLOCK-NEXT: br label %header.prol
2047 ; PROLOG-BLOCK: header.prol:
2048 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.prol
2049 ; PROLOG-BLOCK: for.exiting_block.prol:
2050 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
2051 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa, label %latch.prol
2052 ; PROLOG-BLOCK: latch.prol:
2053 ; PROLOG-BLOCK-NEXT: %1 = load i32, i32* %a, align 4
2054 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
2055 ; PROLOG-BLOCK: header.prol.loopexit:
2056 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %1, %latch.prol ]
2057 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
2058 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %1, %latch.prol ]
2059 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %0, 1
2060 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latchExit, label %entry.new
2061 ; PROLOG-BLOCK: entry.new:
2062 ; PROLOG-BLOCK-NEXT: br label %header
2063 ; PROLOG-BLOCK: header:
2064 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2065 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
2066 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2067 ; PROLOG-BLOCK: for.exiting_block:
2068 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2069 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2070 ; PROLOG-BLOCK: latch:
2071 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2072 ; PROLOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
2073 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
2074 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2075 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2076 ; PROLOG-BLOCK: for.exiting_block.1:
2077 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2078 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2079 ; PROLOG-BLOCK: latch.1:
2080 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2081 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
2082 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
2083 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2084 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
2085 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !5
2086 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
2087 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ 2, %for.exiting_block ], [ 2, %for.exiting_block.1 ], [ %add.1, %latch.1 ]
2088 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2089 ; PROLOG-BLOCK: latchExit.unr-lcssa:
2090 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 2, %for.exiting_block.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2091 ; PROLOG-BLOCK-NEXT: br label %latchExit
2092 ; PROLOG-BLOCK: latchExit:
2093 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2094 ; PROLOG-BLOCK-NEXT: ret i32 %result
2095 ; PROLOG-BLOCK: for.exit2.loopexit:
2096 ; PROLOG-BLOCK-NEXT: br label %for.exit2
2097 ; PROLOG-BLOCK: for.exit2:
2098 ; PROLOG-BLOCK-NEXT: ret i32 42
2105 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
2106 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
2107 br i1 %cond, label %for.exit2, label %for.exiting_block
2110 %cmp = icmp eq i64 %n, 42
2111 br i1 %cmp, label %latchExit, label %latch
2113 latch: ; preds = %latch, %entry
2114 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2115 %0 = load i32, i32* %arrayidx, align 4
2116 %add = add nsw i32 %0, %sum.02
2117 %indvars.iv.next = add i64 %indvars.iv, 1
2118 %exitcond = icmp eq i64 %indvars.iv.next, %n
2119 br i1 %exitcond, label %latchExit, label %header
2121 latchExit: ; preds = %latch, %entry
2122 %result = phi i32 [ 2, %for.exiting_block ], [ %add, %latch ]
2129 ; Two exiting blocks to latch where the exiting blocks are Latch and a
2131 ; Same as above test except the incoming value for latch Phi is from the header
2132 ; FIXME: We should be able to runtime unroll.
2133 define i32 @otherblock_latch_same_exit2(i32* nocapture %a, i64 %n, i1 %cond) {
2134 ; EPILOG-LABEL: @otherblock_latch_same_exit2(
2135 ; EPILOG-NEXT: entry:
2136 ; EPILOG-NEXT: %0 = add i64 %n, -1
2137 ; EPILOG-NEXT: %xtraiter = and i64 %n, 7
2138 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
2139 ; EPILOG-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %entry.new
2140 ; EPILOG: entry.new:
2141 ; EPILOG-NEXT: %unroll_iter = sub i64 %n, %xtraiter
2142 ; EPILOG-NEXT: br label %header
2144 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2145 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
2146 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
2147 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2148 ; EPILOG: for.exiting_block:
2149 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
2150 ; EPILOG-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2152 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2153 ; EPILOG-NEXT: %2 = load i32, i32* %arrayidx, align 4
2154 ; EPILOG-NEXT: %add = add nsw i32 %2, %sum.02
2155 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2156 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
2157 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2158 ; EPILOG: for.exiting_block.1:
2159 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2160 ; EPILOG-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2162 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2163 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
2164 ; EPILOG-NEXT: %add.1 = add nsw i32 %3, %add
2165 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
2166 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
2167 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2168 ; EPILOG: for.exiting_block.2:
2169 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2170 ; EPILOG-NEXT: br i1 %cmp.2, label %latchExit.epilog-lcssa.loopexit, label %latch.2
2172 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
2173 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.2, align 4
2174 ; EPILOG-NEXT: %add.2 = add nsw i32 %4, %add.1
2175 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
2176 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
2177 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2178 ; EPILOG: for.exiting_block.3:
2179 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2180 ; EPILOG-NEXT: br i1 %cmp.3, label %latchExit.epilog-lcssa.loopexit, label %latch.3
2182 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
2183 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.3, align 4
2184 ; EPILOG-NEXT: %add.3 = add nsw i32 %5, %add.2
2185 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
2186 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
2187 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2188 ; EPILOG: for.exiting_block.4:
2189 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2190 ; EPILOG-NEXT: br i1 %cmp.4, label %latchExit.epilog-lcssa.loopexit, label %latch.4
2192 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
2193 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.4, align 4
2194 ; EPILOG-NEXT: %add.4 = add nsw i32 %6, %add.3
2195 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
2196 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
2197 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2198 ; EPILOG: for.exiting_block.5:
2199 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2200 ; EPILOG-NEXT: br i1 %cmp.5, label %latchExit.epilog-lcssa.loopexit, label %latch.5
2202 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
2203 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.5, align 4
2204 ; EPILOG-NEXT: %add.5 = add nsw i32 %7, %add.4
2205 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
2206 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
2207 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2208 ; EPILOG: for.exiting_block.6:
2209 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2210 ; EPILOG-NEXT: br i1 %cmp.6, label %latchExit.epilog-lcssa.loopexit, label %latch.6
2212 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2213 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.6, align 4
2214 ; EPILOG-NEXT: %add.6 = add nsw i32 %8, %add.5
2215 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
2216 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
2217 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2218 ; EPILOG: for.exiting_block.7:
2219 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2220 ; EPILOG-NEXT: br i1 %cmp.7, label %latchExit.epilog-lcssa.loopexit, label %latch.7
2222 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2223 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.7, align 4
2224 ; EPILOG-NEXT: %add.7 = add nsw i32 %9, %add.6
2225 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2226 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
2227 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
2228 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
2229 ; EPILOG: latchExit.unr-lcssa.loopexit:
2230 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
2231 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
2232 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
2233 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
2234 ; EPILOG: latchExit.unr-lcssa:
2235 ; EPILOG-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2236 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2237 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2238 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2239 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2240 ; EPILOG: header.epil.preheader:
2241 ; EPILOG-NEXT: br label %header.epil
2242 ; EPILOG: header.epil:
2243 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
2244 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
2245 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
2246 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit2, label %for.exiting_block.epil
2247 ; EPILOG: for.exiting_block.epil:
2248 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
2249 ; EPILOG-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa.loopexit3, label %latch.epil
2250 ; EPILOG: latch.epil:
2251 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
2252 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.epil, align 4
2253 ; EPILOG-NEXT: %add.epil = add nsw i32 %10, %sum.02.epil
2254 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
2255 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
2256 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
2257 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
2258 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit3, !llvm.loop !6
2259 ; EPILOG: latchExit.epilog-lcssa.loopexit:
2260 ; EPILOG-NEXT: %result.ph1.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %for.exiting_block.2 ], [ %add.2, %for.exiting_block.3 ], [ %add.3, %for.exiting_block.4 ], [ %add.4, %for.exiting_block.5 ], [ %add.5, %for.exiting_block.6 ], [ %add.6, %for.exiting_block.7 ]
2261 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2262 ; EPILOG: latchExit.epilog-lcssa.loopexit3:
2263 ; EPILOG-NEXT: %result.ph1.ph4 = phi i32 [ %sum.02.epil, %for.exiting_block.epil ], [ %add.epil, %latch.epil ]
2264 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2265 ; EPILOG: latchExit.epilog-lcssa:
2266 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph4, %latchExit.epilog-lcssa.loopexit3 ]
2267 ; EPILOG-NEXT: br label %latchExit
2268 ; EPILOG: latchExit:
2269 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2270 ; EPILOG-NEXT: ret i32 %result
2271 ; EPILOG: for.exit2.loopexit:
2272 ; EPILOG-NEXT: br label %for.exit2
2273 ; EPILOG: for.exit2.loopexit2:
2274 ; EPILOG-NEXT: br label %for.exit2
2275 ; EPILOG: for.exit2:
2276 ; EPILOG-NEXT: ret i32 42
2278 ; EPILOG-BLOCK-LABEL: @otherblock_latch_same_exit2(
2279 ; EPILOG-BLOCK-NEXT: entry:
2280 ; EPILOG-BLOCK-NEXT: %0 = add i64 %n, -1
2281 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
2282 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
2283 ; EPILOG-BLOCK-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %entry.new
2284 ; EPILOG-BLOCK: entry.new:
2285 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %n, %xtraiter
2286 ; EPILOG-BLOCK-NEXT: br label %header
2287 ; EPILOG-BLOCK: header:
2288 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2289 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
2290 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
2291 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2292 ; EPILOG-BLOCK: for.exiting_block:
2293 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2294 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2295 ; EPILOG-BLOCK: latch:
2296 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2297 ; EPILOG-BLOCK-NEXT: %2 = load i32, i32* %arrayidx, align 4
2298 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %2, %sum.02
2299 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2300 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
2301 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2302 ; EPILOG-BLOCK: for.exiting_block.1:
2303 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2304 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2305 ; EPILOG-BLOCK: latch.1:
2306 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2307 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
2308 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %3, %add
2309 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2310 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
2311 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
2312 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !6
2313 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
2314 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
2315 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
2316 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
2317 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2318 ; EPILOG-BLOCK: latchExit.unr-lcssa:
2319 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2320 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2321 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2322 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2323 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2324 ; EPILOG-BLOCK: header.epil.preheader:
2325 ; EPILOG-BLOCK-NEXT: br label %header.epil
2326 ; EPILOG-BLOCK: header.epil:
2327 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.epil
2328 ; EPILOG-BLOCK: for.exiting_block.epil:
2329 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
2330 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa, label %latch.epil
2331 ; EPILOG-BLOCK: latch.epil:
2332 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
2333 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.epil, align 4
2334 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %4, %sum.02.unr
2335 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2336 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
2337 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ]
2338 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2339 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
2340 ; EPILOG-BLOCK-NEXT: %result.ph1 = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %for.exiting_block.epil ], [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
2341 ; EPILOG-BLOCK-NEXT: br label %latchExit
2342 ; EPILOG-BLOCK: latchExit:
2343 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2344 ; EPILOG-BLOCK-NEXT: ret i32 %result
2345 ; EPILOG-BLOCK: for.exit2.loopexit:
2346 ; EPILOG-BLOCK-NEXT: br label %for.exit2
2347 ; EPILOG-BLOCK: for.exit2:
2348 ; EPILOG-BLOCK-NEXT: ret i32 42
2350 ; PROLOG-LABEL: @otherblock_latch_same_exit2(
2351 ; PROLOG-NEXT: entry:
2352 ; PROLOG-NEXT: %0 = add i64 %n, -1
2353 ; PROLOG-NEXT: %xtraiter = and i64 %n, 7
2354 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2355 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2356 ; PROLOG: header.prol.preheader:
2357 ; PROLOG-NEXT: br label %header.prol
2358 ; PROLOG: header.prol:
2359 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2360 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2361 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
2362 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit1, label %for.exiting_block.prol
2363 ; PROLOG: for.exiting_block.prol:
2364 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
2365 ; PROLOG-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa.loopexit2, label %latch.prol
2366 ; PROLOG: latch.prol:
2367 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
2368 ; PROLOG-NEXT: %1 = load i32, i32* %arrayidx.prol, align 4
2369 ; PROLOG-NEXT: %add.prol = add nsw i32 %1, %sum.02.prol
2370 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
2371 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
2372 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
2373 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
2374 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !6
2375 ; PROLOG: header.prol.loopexit.unr-lcssa:
2376 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2377 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
2378 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2379 ; PROLOG-NEXT: br label %header.prol.loopexit
2380 ; PROLOG: header.prol.loopexit:
2381 ; PROLOG-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
2382 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
2383 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
2384 ; PROLOG-NEXT: %2 = icmp ult i64 %0, 7
2385 ; PROLOG-NEXT: br i1 %2, label %latchExit, label %entry.new
2386 ; PROLOG: entry.new:
2387 ; PROLOG-NEXT: br label %header
2389 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2390 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
2391 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2392 ; PROLOG: for.exiting_block:
2393 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
2394 ; PROLOG-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2396 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2397 ; PROLOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
2398 ; PROLOG-NEXT: %add = add nsw i32 %3, %sum.02
2399 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2400 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2401 ; PROLOG: for.exiting_block.1:
2402 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2403 ; PROLOG-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2405 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2406 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
2407 ; PROLOG-NEXT: %add.1 = add nsw i32 %4, %add
2408 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2409 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2410 ; PROLOG: for.exiting_block.2:
2411 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2412 ; PROLOG-NEXT: br i1 %cmp.2, label %latchExit.unr-lcssa.loopexit, label %latch.2
2414 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
2415 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
2416 ; PROLOG-NEXT: %add.2 = add nsw i32 %5, %add.1
2417 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
2418 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2419 ; PROLOG: for.exiting_block.3:
2420 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2421 ; PROLOG-NEXT: br i1 %cmp.3, label %latchExit.unr-lcssa.loopexit, label %latch.3
2423 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
2424 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
2425 ; PROLOG-NEXT: %add.3 = add nsw i32 %6, %add.2
2426 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
2427 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2428 ; PROLOG: for.exiting_block.4:
2429 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2430 ; PROLOG-NEXT: br i1 %cmp.4, label %latchExit.unr-lcssa.loopexit, label %latch.4
2432 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
2433 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
2434 ; PROLOG-NEXT: %add.4 = add nsw i32 %7, %add.3
2435 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
2436 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2437 ; PROLOG: for.exiting_block.5:
2438 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2439 ; PROLOG-NEXT: br i1 %cmp.5, label %latchExit.unr-lcssa.loopexit, label %latch.5
2441 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
2442 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
2443 ; PROLOG-NEXT: %add.5 = add nsw i32 %8, %add.4
2444 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
2445 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2446 ; PROLOG: for.exiting_block.6:
2447 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2448 ; PROLOG-NEXT: br i1 %cmp.6, label %latchExit.unr-lcssa.loopexit, label %latch.6
2450 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2451 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
2452 ; PROLOG-NEXT: %add.6 = add nsw i32 %9, %add.5
2453 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
2454 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2455 ; PROLOG: for.exiting_block.7:
2456 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2457 ; PROLOG-NEXT: br i1 %cmp.7, label %latchExit.unr-lcssa.loopexit, label %latch.7
2459 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2460 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
2461 ; PROLOG-NEXT: %add.7 = add nsw i32 %10, %add.6
2462 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2463 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
2464 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
2465 ; PROLOG: latchExit.unr-lcssa.loopexit:
2466 ; PROLOG-NEXT: %result.ph.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %for.exiting_block.2 ], [ %add.2, %for.exiting_block.3 ], [ %add.3, %for.exiting_block.4 ], [ %add.4, %for.exiting_block.5 ], [ %add.5, %for.exiting_block.6 ], [ %add.6, %for.exiting_block.7 ], [ %add.7, %latch.7 ]
2467 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2468 ; PROLOG: latchExit.unr-lcssa.loopexit2:
2469 ; PROLOG-NEXT: %result.ph.ph3 = phi i32 [ %sum.02.prol, %for.exiting_block.prol ]
2470 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2471 ; PROLOG: latchExit.unr-lcssa:
2472 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph3, %latchExit.unr-lcssa.loopexit2 ]
2473 ; PROLOG-NEXT: br label %latchExit
2474 ; PROLOG: latchExit:
2475 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2476 ; PROLOG-NEXT: ret i32 %result
2477 ; PROLOG: for.exit2.loopexit:
2478 ; PROLOG-NEXT: br label %for.exit2
2479 ; PROLOG: for.exit2.loopexit1:
2480 ; PROLOG-NEXT: br label %for.exit2
2481 ; PROLOG: for.exit2:
2482 ; PROLOG-NEXT: ret i32 42
2484 ; PROLOG-BLOCK-LABEL: @otherblock_latch_same_exit2(
2485 ; PROLOG-BLOCK-NEXT: entry:
2486 ; PROLOG-BLOCK-NEXT: %0 = add i64 %n, -1
2487 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
2488 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2489 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2490 ; PROLOG-BLOCK: header.prol.preheader:
2491 ; PROLOG-BLOCK-NEXT: br label %header.prol
2492 ; PROLOG-BLOCK: header.prol:
2493 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.prol
2494 ; PROLOG-BLOCK: for.exiting_block.prol:
2495 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
2496 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa, label %latch.prol
2497 ; PROLOG-BLOCK: latch.prol:
2498 ; PROLOG-BLOCK-NEXT: %1 = load i32, i32* %a, align 4
2499 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
2500 ; PROLOG-BLOCK: header.prol.loopexit:
2501 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %1, %latch.prol ]
2502 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
2503 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %1, %latch.prol ]
2504 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %0, 1
2505 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latchExit, label %entry.new
2506 ; PROLOG-BLOCK: entry.new:
2507 ; PROLOG-BLOCK-NEXT: br label %header
2508 ; PROLOG-BLOCK: header:
2509 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2510 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
2511 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2512 ; PROLOG-BLOCK: for.exiting_block:
2513 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2514 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2515 ; PROLOG-BLOCK: latch:
2516 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2517 ; PROLOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
2518 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
2519 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2520 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2521 ; PROLOG-BLOCK: for.exiting_block.1:
2522 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2523 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2524 ; PROLOG-BLOCK: latch.1:
2525 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2526 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
2527 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
2528 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2529 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
2530 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !6
2531 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
2532 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %latch.1 ]
2533 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2534 ; PROLOG-BLOCK: latchExit.unr-lcssa:
2535 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 0, %for.exiting_block.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2536 ; PROLOG-BLOCK-NEXT: br label %latchExit
2537 ; PROLOG-BLOCK: latchExit:
2538 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2539 ; PROLOG-BLOCK-NEXT: ret i32 %result
2540 ; PROLOG-BLOCK: for.exit2.loopexit:
2541 ; PROLOG-BLOCK-NEXT: br label %for.exit2
2542 ; PROLOG-BLOCK: for.exit2:
2543 ; PROLOG-BLOCK-NEXT: ret i32 42
2550 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
2551 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
2552 br i1 %cond, label %for.exit2, label %for.exiting_block
2555 %cmp = icmp eq i64 %n, 42
2556 br i1 %cmp, label %latchExit, label %latch
2558 latch: ; preds = %latch, %entry
2559 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2560 %0 = load i32, i32* %arrayidx, align 4
2561 %add = add nsw i32 %0, %sum.02
2562 %indvars.iv.next = add i64 %indvars.iv, 1
2563 %exitcond = icmp eq i64 %indvars.iv.next, %n
2564 br i1 %exitcond, label %latchExit, label %header
2566 latchExit: ; preds = %latch, %entry
2567 %result = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %latch ]
2574 ; Two exiting blocks to latch where the exiting blocks are Latch and a
2576 ; Same as above test except the incoming value for cloned latch Phi is from the
2577 ; for.exiting_block.
2578 ; FIXME: We should be able to runtime unroll.
2579 define i32 @otherblock_latch_same_exit3(i32* nocapture %a, i64 %n, i1 %cond) {
2580 ; EPILOG-LABEL: @otherblock_latch_same_exit3(
2581 ; EPILOG-NEXT: entry:
2582 ; EPILOG-NEXT: %0 = add i64 %n, -1
2583 ; EPILOG-NEXT: %xtraiter = and i64 %n, 7
2584 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
2585 ; EPILOG-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %entry.new
2586 ; EPILOG: entry.new:
2587 ; EPILOG-NEXT: %unroll_iter = sub i64 %n, %xtraiter
2588 ; EPILOG-NEXT: br label %header
2590 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2591 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
2592 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
2593 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2594 ; EPILOG: for.exiting_block:
2595 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2596 ; EPILOG-NEXT: %2 = load i32, i32* %arrayidx, align 4
2597 ; EPILOG-NEXT: %add = add nsw i32 %2, %sum.02
2598 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
2599 ; EPILOG-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2601 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2602 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
2603 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2604 ; EPILOG: for.exiting_block.1:
2605 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2606 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
2607 ; EPILOG-NEXT: %add.1 = add nsw i32 %3, %add
2608 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2609 ; EPILOG-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2611 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
2612 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
2613 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2614 ; EPILOG: for.exiting_block.2:
2615 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
2616 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.2, align 4
2617 ; EPILOG-NEXT: %add.2 = add nsw i32 %4, %add.1
2618 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2619 ; EPILOG-NEXT: br i1 %cmp.2, label %latchExit.epilog-lcssa.loopexit, label %latch.2
2621 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
2622 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
2623 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2624 ; EPILOG: for.exiting_block.3:
2625 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
2626 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.3, align 4
2627 ; EPILOG-NEXT: %add.3 = add nsw i32 %5, %add.2
2628 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2629 ; EPILOG-NEXT: br i1 %cmp.3, label %latchExit.epilog-lcssa.loopexit, label %latch.3
2631 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
2632 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
2633 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2634 ; EPILOG: for.exiting_block.4:
2635 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
2636 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.4, align 4
2637 ; EPILOG-NEXT: %add.4 = add nsw i32 %6, %add.3
2638 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2639 ; EPILOG-NEXT: br i1 %cmp.4, label %latchExit.epilog-lcssa.loopexit, label %latch.4
2641 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
2642 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
2643 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2644 ; EPILOG: for.exiting_block.5:
2645 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
2646 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.5, align 4
2647 ; EPILOG-NEXT: %add.5 = add nsw i32 %7, %add.4
2648 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2649 ; EPILOG-NEXT: br i1 %cmp.5, label %latchExit.epilog-lcssa.loopexit, label %latch.5
2651 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
2652 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
2653 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2654 ; EPILOG: for.exiting_block.6:
2655 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2656 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.6, align 4
2657 ; EPILOG-NEXT: %add.6 = add nsw i32 %8, %add.5
2658 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2659 ; EPILOG-NEXT: br i1 %cmp.6, label %latchExit.epilog-lcssa.loopexit, label %latch.6
2661 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
2662 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
2663 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2664 ; EPILOG: for.exiting_block.7:
2665 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2666 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.7, align 4
2667 ; EPILOG-NEXT: %add.7 = add nsw i32 %9, %add.6
2668 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2669 ; EPILOG-NEXT: br i1 %cmp.7, label %latchExit.epilog-lcssa.loopexit, label %latch.7
2671 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2672 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
2673 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
2674 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
2675 ; EPILOG: latchExit.unr-lcssa.loopexit:
2676 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
2677 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
2678 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
2679 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
2680 ; EPILOG: latchExit.unr-lcssa:
2681 ; EPILOG-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2682 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2683 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2684 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2685 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2686 ; EPILOG: header.epil.preheader:
2687 ; EPILOG-NEXT: br label %header.epil
2688 ; EPILOG: header.epil:
2689 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
2690 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
2691 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
2692 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit2, label %for.exiting_block.epil
2693 ; EPILOG: for.exiting_block.epil:
2694 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
2695 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.epil, align 4
2696 ; EPILOG-NEXT: %add.epil = add nsw i32 %10, %sum.02.epil
2697 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
2698 ; EPILOG-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa.loopexit3, label %latch.epil
2699 ; EPILOG: latch.epil:
2700 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
2701 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
2702 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
2703 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
2704 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit3, !llvm.loop !7
2705 ; EPILOG: latchExit.epilog-lcssa.loopexit:
2706 ; EPILOG-NEXT: %result.ph1.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %for.exiting_block.2 ], [ %add.2, %for.exiting_block.3 ], [ %add.3, %for.exiting_block.4 ], [ %add.4, %for.exiting_block.5 ], [ %add.5, %for.exiting_block.6 ], [ %add.6, %for.exiting_block.7 ]
2707 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2708 ; EPILOG: latchExit.epilog-lcssa.loopexit3:
2709 ; EPILOG-NEXT: %result.ph1.ph4 = phi i32 [ %sum.02.epil, %for.exiting_block.epil ], [ %add.epil, %latch.epil ]
2710 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2711 ; EPILOG: latchExit.epilog-lcssa:
2712 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph4, %latchExit.epilog-lcssa.loopexit3 ]
2713 ; EPILOG-NEXT: br label %latchExit
2714 ; EPILOG: latchExit:
2715 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2716 ; EPILOG-NEXT: ret i32 %result
2717 ; EPILOG: for.exit2.loopexit:
2718 ; EPILOG-NEXT: br label %for.exit2
2719 ; EPILOG: for.exit2.loopexit2:
2720 ; EPILOG-NEXT: br label %for.exit2
2721 ; EPILOG: for.exit2:
2722 ; EPILOG-NEXT: ret i32 42
2724 ; EPILOG-BLOCK-LABEL: @otherblock_latch_same_exit3(
2725 ; EPILOG-BLOCK-NEXT: entry:
2726 ; EPILOG-BLOCK-NEXT: %0 = add i64 %n, -1
2727 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
2728 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
2729 ; EPILOG-BLOCK-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %entry.new
2730 ; EPILOG-BLOCK: entry.new:
2731 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %n, %xtraiter
2732 ; EPILOG-BLOCK-NEXT: br label %header
2733 ; EPILOG-BLOCK: header:
2734 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2735 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
2736 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
2737 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2738 ; EPILOG-BLOCK: for.exiting_block:
2739 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2740 ; EPILOG-BLOCK-NEXT: %2 = load i32, i32* %arrayidx, align 4
2741 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %2, %sum.02
2742 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2743 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2744 ; EPILOG-BLOCK: latch:
2745 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2746 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
2747 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2748 ; EPILOG-BLOCK: for.exiting_block.1:
2749 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2750 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx.1, align 4
2751 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %3, %add
2752 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2753 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2754 ; EPILOG-BLOCK: latch.1:
2755 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2756 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
2757 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
2758 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !7
2759 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
2760 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
2761 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
2762 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
2763 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2764 ; EPILOG-BLOCK: latchExit.unr-lcssa:
2765 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2766 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2767 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2768 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2769 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2770 ; EPILOG-BLOCK: header.epil.preheader:
2771 ; EPILOG-BLOCK-NEXT: br label %header.epil
2772 ; EPILOG-BLOCK: header.epil:
2773 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.epil
2774 ; EPILOG-BLOCK: for.exiting_block.epil:
2775 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
2776 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.epil, align 4
2777 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %4, %sum.02.unr
2778 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
2779 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa, label %latch.epil
2780 ; EPILOG-BLOCK: latch.epil:
2781 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2782 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
2783 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ]
2784 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2785 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
2786 ; EPILOG-BLOCK-NEXT: %result.ph1 = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %for.exiting_block.epil ], [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
2787 ; EPILOG-BLOCK-NEXT: br label %latchExit
2788 ; EPILOG-BLOCK: latchExit:
2789 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2790 ; EPILOG-BLOCK-NEXT: ret i32 %result
2791 ; EPILOG-BLOCK: for.exit2.loopexit:
2792 ; EPILOG-BLOCK-NEXT: br label %for.exit2
2793 ; EPILOG-BLOCK: for.exit2:
2794 ; EPILOG-BLOCK-NEXT: ret i32 42
2796 ; PROLOG-LABEL: @otherblock_latch_same_exit3(
2797 ; PROLOG-NEXT: entry:
2798 ; PROLOG-NEXT: %0 = add i64 %n, -1
2799 ; PROLOG-NEXT: %xtraiter = and i64 %n, 7
2800 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2801 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2802 ; PROLOG: header.prol.preheader:
2803 ; PROLOG-NEXT: br label %header.prol
2804 ; PROLOG: header.prol:
2805 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2806 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2807 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
2808 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit1, label %for.exiting_block.prol
2809 ; PROLOG: for.exiting_block.prol:
2810 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
2811 ; PROLOG-NEXT: %1 = load i32, i32* %arrayidx.prol, align 4
2812 ; PROLOG-NEXT: %add.prol = add nsw i32 %1, %sum.02.prol
2813 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
2814 ; PROLOG-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa.loopexit2, label %latch.prol
2815 ; PROLOG: latch.prol:
2816 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
2817 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
2818 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
2819 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
2820 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !7
2821 ; PROLOG: header.prol.loopexit.unr-lcssa:
2822 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2823 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
2824 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2825 ; PROLOG-NEXT: br label %header.prol.loopexit
2826 ; PROLOG: header.prol.loopexit:
2827 ; PROLOG-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
2828 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
2829 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
2830 ; PROLOG-NEXT: %2 = icmp ult i64 %0, 7
2831 ; PROLOG-NEXT: br i1 %2, label %latchExit, label %entry.new
2832 ; PROLOG: entry.new:
2833 ; PROLOG-NEXT: br label %header
2835 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2836 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
2837 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2838 ; PROLOG: for.exiting_block:
2839 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2840 ; PROLOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
2841 ; PROLOG-NEXT: %add = add nsw i32 %3, %sum.02
2842 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
2843 ; PROLOG-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2845 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2846 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2847 ; PROLOG: for.exiting_block.1:
2848 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2849 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
2850 ; PROLOG-NEXT: %add.1 = add nsw i32 %4, %add
2851 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2852 ; PROLOG-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2854 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2855 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2856 ; PROLOG: for.exiting_block.2:
2857 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
2858 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
2859 ; PROLOG-NEXT: %add.2 = add nsw i32 %5, %add.1
2860 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2861 ; PROLOG-NEXT: br i1 %cmp.2, label %latchExit.unr-lcssa.loopexit, label %latch.2
2863 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
2864 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2865 ; PROLOG: for.exiting_block.3:
2866 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
2867 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
2868 ; PROLOG-NEXT: %add.3 = add nsw i32 %6, %add.2
2869 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2870 ; PROLOG-NEXT: br i1 %cmp.3, label %latchExit.unr-lcssa.loopexit, label %latch.3
2872 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
2873 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2874 ; PROLOG: for.exiting_block.4:
2875 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
2876 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
2877 ; PROLOG-NEXT: %add.4 = add nsw i32 %7, %add.3
2878 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2879 ; PROLOG-NEXT: br i1 %cmp.4, label %latchExit.unr-lcssa.loopexit, label %latch.4
2881 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
2882 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2883 ; PROLOG: for.exiting_block.5:
2884 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
2885 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
2886 ; PROLOG-NEXT: %add.5 = add nsw i32 %8, %add.4
2887 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2888 ; PROLOG-NEXT: br i1 %cmp.5, label %latchExit.unr-lcssa.loopexit, label %latch.5
2890 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
2891 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2892 ; PROLOG: for.exiting_block.6:
2893 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2894 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
2895 ; PROLOG-NEXT: %add.6 = add nsw i32 %9, %add.5
2896 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2897 ; PROLOG-NEXT: br i1 %cmp.6, label %latchExit.unr-lcssa.loopexit, label %latch.6
2899 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
2900 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2901 ; PROLOG: for.exiting_block.7:
2902 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2903 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
2904 ; PROLOG-NEXT: %add.7 = add nsw i32 %10, %add.6
2905 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2906 ; PROLOG-NEXT: br i1 %cmp.7, label %latchExit.unr-lcssa.loopexit, label %latch.7
2908 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2909 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
2910 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
2911 ; PROLOG: latchExit.unr-lcssa.loopexit:
2912 ; PROLOG-NEXT: %result.ph.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %for.exiting_block.2 ], [ %add.2, %for.exiting_block.3 ], [ %add.3, %for.exiting_block.4 ], [ %add.4, %for.exiting_block.5 ], [ %add.5, %for.exiting_block.6 ], [ %add.6, %for.exiting_block.7 ], [ %add.7, %latch.7 ]
2913 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2914 ; PROLOG: latchExit.unr-lcssa.loopexit2:
2915 ; PROLOG-NEXT: %result.ph.ph3 = phi i32 [ %sum.02.prol, %for.exiting_block.prol ]
2916 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2917 ; PROLOG: latchExit.unr-lcssa:
2918 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph3, %latchExit.unr-lcssa.loopexit2 ]
2919 ; PROLOG-NEXT: br label %latchExit
2920 ; PROLOG: latchExit:
2921 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2922 ; PROLOG-NEXT: ret i32 %result
2923 ; PROLOG: for.exit2.loopexit:
2924 ; PROLOG-NEXT: br label %for.exit2
2925 ; PROLOG: for.exit2.loopexit1:
2926 ; PROLOG-NEXT: br label %for.exit2
2927 ; PROLOG: for.exit2:
2928 ; PROLOG-NEXT: ret i32 42
2930 ; PROLOG-BLOCK-LABEL: @otherblock_latch_same_exit3(
2931 ; PROLOG-BLOCK-NEXT: entry:
2932 ; PROLOG-BLOCK-NEXT: %0 = add i64 %n, -1
2933 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
2934 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2935 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2936 ; PROLOG-BLOCK: header.prol.preheader:
2937 ; PROLOG-BLOCK-NEXT: br label %header.prol
2938 ; PROLOG-BLOCK: header.prol:
2939 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.prol
2940 ; PROLOG-BLOCK: for.exiting_block.prol:
2941 ; PROLOG-BLOCK-NEXT: %1 = load i32, i32* %a, align 4
2942 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
2943 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa, label %latch.prol
2944 ; PROLOG-BLOCK: latch.prol:
2945 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
2946 ; PROLOG-BLOCK: header.prol.loopexit:
2947 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %1, %latch.prol ]
2948 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
2949 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %1, %latch.prol ]
2950 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %0, 1
2951 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latchExit, label %entry.new
2952 ; PROLOG-BLOCK: entry.new:
2953 ; PROLOG-BLOCK-NEXT: br label %header
2954 ; PROLOG-BLOCK: header:
2955 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2956 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
2957 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2958 ; PROLOG-BLOCK: for.exiting_block:
2959 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2960 ; PROLOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
2961 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
2962 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2963 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2964 ; PROLOG-BLOCK: latch:
2965 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2966 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2967 ; PROLOG-BLOCK: for.exiting_block.1:
2968 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2969 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
2970 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
2971 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2972 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2973 ; PROLOG-BLOCK: latch.1:
2974 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2975 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
2976 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !7
2977 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
2978 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %latch.1 ]
2979 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2980 ; PROLOG-BLOCK: latchExit.unr-lcssa:
2981 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 0, %for.exiting_block.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2982 ; PROLOG-BLOCK-NEXT: br label %latchExit
2983 ; PROLOG-BLOCK: latchExit:
2984 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2985 ; PROLOG-BLOCK-NEXT: ret i32 %result
2986 ; PROLOG-BLOCK: for.exit2.loopexit:
2987 ; PROLOG-BLOCK-NEXT: br label %for.exit2
2988 ; PROLOG-BLOCK: for.exit2:
2989 ; PROLOG-BLOCK-NEXT: ret i32 42
2996 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
2997 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
2998 br i1 %cond, label %for.exit2, label %for.exiting_block
3001 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
3002 %0 = load i32, i32* %arrayidx, align 4
3003 %add = add nsw i32 %0, %sum.02
3004 %cmp = icmp eq i64 %n, 42
3005 br i1 %cmp, label %latchExit, label %latch
3007 latch: ; preds = %latch, %entry
3008 %indvars.iv.next = add i64 %indvars.iv, 1
3009 %exitcond = icmp eq i64 %indvars.iv.next, %n
3010 br i1 %exitcond, label %latchExit, label %header
3012 latchExit: ; preds = %latch, %entry
3013 %result = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %latch ]
3020 ; Show a case where we have multiple exits, but (provably) exit on the
3021 ; first iteration and thus have nothing to unroll
3022 define void @non_loop(i32 %arg) {
3023 ; CHECK-LABEL: @non_loop(
3024 ; CHECK-NEXT: entry:
3025 ; CHECK-NEXT: %i = icmp sgt i32 undef, %arg
3026 ; CHECK-NEXT: br i1 %i, label %preheader, label %returnblock
3028 ; CHECK-NEXT: br label %header
3030 ; CHECK-NEXT: br i1 true, label %latchExit, label %latch
3032 ; CHECK-NEXT: br label %latchExit
3034 ; CHECK-NEXT: %i2.ph = phi i32 [ %arg, %header ], [ -1, %latch ]
3035 ; CHECK-NEXT: br label %returnblock
3036 ; CHECK: returnblock:
3037 ; CHECK-NEXT: %i2 = phi i32 [ -1, %entry ], [ %i2.ph, %latchExit ]
3038 ; CHECK-NEXT: ret void
3042 %i = icmp sgt i32 undef, %arg
3043 br i1 %i, label %preheader, label %returnblock
3045 preheader: ; preds = %entry
3048 header: ; preds = %preheader, %latch
3049 %i4 = phi i32 [ %inc, %latch ], [ %arg, %preheader ]
3050 %inc = add nsw i32 %i4, 1
3051 br i1 true, label %latchExit, label %latch
3053 latch: ; preds = %header
3054 %cmp = icmp slt i32 %inc, undef
3055 br i1 %cmp, label %header, label %latchExit
3057 latchExit: ; preds = %header, %latch
3058 %i2.ph = phi i32 [ %i4, %header ], [ -1, %latch ]
3059 br label %returnblock
3061 returnblock: ; preds = %latchExit, %entry
3062 %i2 = phi i32 [ -1, %entry ], [ %i2.ph, %latchExit ]
3066 ; Latch exit is shared by all exiting blocks
3067 define void @unique_exit(i32 %N, i32 %M) {
3068 ; EPILOG-LABEL: @unique_exit(
3069 ; EPILOG-NEXT: preheader:
3070 ; EPILOG-NEXT: %M.shifted = shl i32 %M, 3
3071 ; EPILOG-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3072 ; EPILOG-NEXT: %0 = add i32 %umax, -1
3073 ; EPILOG-NEXT: %xtraiter = and i32 %umax, 7
3074 ; EPILOG-NEXT: %1 = icmp ult i32 %0, 7
3075 ; EPILOG-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %preheader.new
3076 ; EPILOG: preheader.new:
3077 ; EPILOG-NEXT: %unroll_iter = sub i32 %umax, %xtraiter
3078 ; EPILOG-NEXT: br label %header
3080 ; EPILOG-NEXT: %i4 = phi i32 [ 0, %preheader.new ], [ %inc.7, %latch.7 ]
3081 ; EPILOG-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.7, %latch.7 ]
3082 ; EPILOG-NEXT: %inc = add nuw nsw i32 %i4, 1
3083 ; EPILOG-NEXT: %cmp1 = icmp ult i32 %inc, %N
3084 ; EPILOG-NEXT: br i1 %cmp1, label %latch, label %latchExit.epilog-lcssa.loopexit
3086 ; EPILOG-NEXT: %niter.next = add nuw nsw i32 %niter, 1
3087 ; EPILOG-NEXT: %inc.1 = add nuw nsw i32 %inc, 1
3088 ; EPILOG-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3089 ; EPILOG-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.epilog-lcssa.loopexit
3091 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i32 %niter.next, 1
3092 ; EPILOG-NEXT: %inc.2 = add nuw nsw i32 %inc.1, 1
3093 ; EPILOG-NEXT: %cmp1.2 = icmp ult i32 %inc.2, %N
3094 ; EPILOG-NEXT: br i1 %cmp1.2, label %latch.2, label %latchExit.epilog-lcssa.loopexit
3096 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i32 %niter.next.1, 1
3097 ; EPILOG-NEXT: %inc.3 = add nuw nsw i32 %inc.2, 1
3098 ; EPILOG-NEXT: %cmp1.3 = icmp ult i32 %inc.3, %N
3099 ; EPILOG-NEXT: br i1 %cmp1.3, label %latch.3, label %latchExit.epilog-lcssa.loopexit
3101 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i32 %niter.next.2, 1
3102 ; EPILOG-NEXT: %inc.4 = add nuw nsw i32 %inc.3, 1
3103 ; EPILOG-NEXT: %cmp1.4 = icmp ult i32 %inc.4, %N
3104 ; EPILOG-NEXT: br i1 %cmp1.4, label %latch.4, label %latchExit.epilog-lcssa.loopexit
3106 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i32 %niter.next.3, 1
3107 ; EPILOG-NEXT: %inc.5 = add nuw nsw i32 %inc.4, 1
3108 ; EPILOG-NEXT: %cmp1.5 = icmp ult i32 %inc.5, %N
3109 ; EPILOG-NEXT: br i1 %cmp1.5, label %latch.5, label %latchExit.epilog-lcssa.loopexit
3111 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i32 %niter.next.4, 1
3112 ; EPILOG-NEXT: %inc.6 = add nuw nsw i32 %inc.5, 1
3113 ; EPILOG-NEXT: %cmp1.6 = icmp ult i32 %inc.6, %N
3114 ; EPILOG-NEXT: br i1 %cmp1.6, label %latch.6, label %latchExit.epilog-lcssa.loopexit
3116 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i32 %niter.next.5, 1
3117 ; EPILOG-NEXT: %inc.7 = add nuw i32 %inc.6, 1
3118 ; EPILOG-NEXT: %cmp1.7 = icmp ult i32 %inc.7, %N
3119 ; EPILOG-NEXT: br i1 %cmp1.7, label %latch.7, label %latchExit.epilog-lcssa.loopexit
3121 ; EPILOG-NEXT: %niter.next.7 = add i32 %niter.next.6, 1
3122 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i32 %niter.next.7, %unroll_iter
3123 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %header, label %latchExit.unr-lcssa.loopexit
3124 ; EPILOG: latchExit.unr-lcssa.loopexit:
3125 ; EPILOG-NEXT: %i2.ph.ph.ph = phi i32 [ -1, %latch.7 ]
3126 ; EPILOG-NEXT: %i4.unr.ph = phi i32 [ %inc.7, %latch.7 ]
3127 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
3128 ; EPILOG: latchExit.unr-lcssa:
3129 ; EPILOG-NEXT: %i2.ph.ph = phi i32 [ undef, %preheader ], [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ]
3130 ; EPILOG-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ %i4.unr.ph, %latchExit.unr-lcssa.loopexit ]
3131 ; EPILOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3132 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
3133 ; EPILOG: header.epil.preheader:
3134 ; EPILOG-NEXT: br label %header.epil
3135 ; EPILOG: header.epil:
3136 ; EPILOG-NEXT: %i4.epil = phi i32 [ %inc.epil, %latch.epil ], [ %i4.unr, %header.epil.preheader ]
3137 ; EPILOG-NEXT: %epil.iter = phi i32 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
3138 ; EPILOG-NEXT: %inc.epil = add nuw i32 %i4.epil, 1
3139 ; EPILOG-NEXT: %cmp1.epil = icmp ult i32 %inc.epil, %N
3140 ; EPILOG-NEXT: br i1 %cmp1.epil, label %latch.epil, label %latchExit.epilog-lcssa.loopexit2
3141 ; EPILOG: latch.epil:
3142 ; EPILOG-NEXT: %cmp.epil = icmp ult i32 %inc.epil, %M.shifted
3143 ; EPILOG-NEXT: %epil.iter.next = add i32 %epil.iter, 1
3144 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i32 %epil.iter.next, %xtraiter
3145 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit2, !llvm.loop !8
3146 ; EPILOG: latchExit.epilog-lcssa.loopexit:
3147 ; EPILOG-NEXT: %i2.ph.ph1.ph = phi i32 [ %i4, %header ], [ %inc, %latch ], [ %inc.1, %latch.1 ], [ %inc.2, %latch.2 ], [ %inc.3, %latch.3 ], [ %inc.4, %latch.4 ], [ %inc.5, %latch.5 ], [ %inc.6, %latch.6 ]
3148 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
3149 ; EPILOG: latchExit.epilog-lcssa.loopexit2:
3150 ; EPILOG-NEXT: %i2.ph.ph1.ph3 = phi i32 [ %i4.epil, %header.epil ], [ -1, %latch.epil ]
3151 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
3152 ; EPILOG: latchExit.epilog-lcssa:
3153 ; EPILOG-NEXT: %i2.ph.ph1 = phi i32 [ %i2.ph.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %i2.ph.ph1.ph3, %latchExit.epilog-lcssa.loopexit2 ]
3154 ; EPILOG-NEXT: br label %latchExit
3155 ; EPILOG: latchExit:
3156 ; EPILOG-NEXT: %i2.ph = phi i32 [ %i2.ph.ph, %latchExit.unr-lcssa ], [ %i2.ph.ph1, %latchExit.epilog-lcssa ]
3157 ; EPILOG-NEXT: ret void
3159 ; EPILOG-BLOCK-LABEL: @unique_exit(
3160 ; EPILOG-BLOCK-NEXT: preheader:
3161 ; EPILOG-BLOCK-NEXT: %M.shifted = shl i32 %M, 3
3162 ; EPILOG-BLOCK-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3163 ; EPILOG-BLOCK-NEXT: %0 = add i32 %umax, -1
3164 ; EPILOG-BLOCK-NEXT: %xtraiter = and i32 %umax, 1
3165 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i32 %0, 1
3166 ; EPILOG-BLOCK-NEXT: br i1 %1, label %latchExit.unr-lcssa, label %preheader.new
3167 ; EPILOG-BLOCK: preheader.new:
3168 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i32 %umax, %xtraiter
3169 ; EPILOG-BLOCK-NEXT: br label %header
3170 ; EPILOG-BLOCK: header:
3171 ; EPILOG-BLOCK-NEXT: %i4 = phi i32 [ 0, %preheader.new ], [ %inc.1, %latch.1 ]
3172 ; EPILOG-BLOCK-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.1, %latch.1 ]
3173 ; EPILOG-BLOCK-NEXT: %inc = add nuw nsw i32 %i4, 1
3174 ; EPILOG-BLOCK-NEXT: %cmp1 = icmp ult i32 %inc, %N
3175 ; EPILOG-BLOCK-NEXT: br i1 %cmp1, label %latch, label %latchExit.epilog-lcssa.loopexit
3176 ; EPILOG-BLOCK: latch:
3177 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i32 %niter, 1
3178 ; EPILOG-BLOCK-NEXT: %inc.1 = add nuw i32 %inc, 1
3179 ; EPILOG-BLOCK-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3180 ; EPILOG-BLOCK-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.epilog-lcssa.loopexit
3181 ; EPILOG-BLOCK: latch.1:
3182 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i32 %niter.next, 1
3183 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i32 %niter.next.1, %unroll_iter
3184 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %header, label %latchExit.unr-lcssa.loopexit, !llvm.loop !8
3185 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
3186 ; EPILOG-BLOCK-NEXT: %i2.ph.ph.ph = phi i32 [ -1, %latch.1 ]
3187 ; EPILOG-BLOCK-NEXT: %i4.unr.ph = phi i32 [ %inc.1, %latch.1 ]
3188 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
3189 ; EPILOG-BLOCK: latchExit.unr-lcssa:
3190 ; EPILOG-BLOCK-NEXT: %i2.ph.ph = phi i32 [ undef, %preheader ], [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ]
3191 ; EPILOG-BLOCK-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ %i4.unr.ph, %latchExit.unr-lcssa.loopexit ]
3192 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3193 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
3194 ; EPILOG-BLOCK: header.epil.preheader:
3195 ; EPILOG-BLOCK-NEXT: br label %header.epil
3196 ; EPILOG-BLOCK: header.epil:
3197 ; EPILOG-BLOCK-NEXT: %inc.epil = add nuw i32 %i4.unr, 1
3198 ; EPILOG-BLOCK-NEXT: %cmp1.epil = icmp ult i32 %inc.epil, %N
3199 ; EPILOG-BLOCK-NEXT: br i1 %cmp1.epil, label %latch.epil, label %latchExit.epilog-lcssa
3200 ; EPILOG-BLOCK: latch.epil:
3201 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
3202 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
3203 ; EPILOG-BLOCK-NEXT: %i2.ph.ph1.ph = phi i32 [ %i4, %header ], [ %inc, %latch ]
3204 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
3205 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
3206 ; EPILOG-BLOCK-NEXT: %i2.ph.ph1 = phi i32 [ -1, %latch.epil ], [ %i4.unr, %header.epil ], [ %i2.ph.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
3207 ; EPILOG-BLOCK-NEXT: br label %latchExit
3208 ; EPILOG-BLOCK: latchExit:
3209 ; EPILOG-BLOCK-NEXT: %i2.ph = phi i32 [ %i2.ph.ph, %latchExit.unr-lcssa ], [ %i2.ph.ph1, %latchExit.epilog-lcssa ]
3210 ; EPILOG-BLOCK-NEXT: ret void
3212 ; PROLOG-LABEL: @unique_exit(
3213 ; PROLOG-NEXT: preheader:
3214 ; PROLOG-NEXT: %M.shifted = shl i32 %M, 3
3215 ; PROLOG-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3216 ; PROLOG-NEXT: %0 = add i32 %umax, -1
3217 ; PROLOG-NEXT: %xtraiter = and i32 %umax, 7
3218 ; PROLOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3219 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
3220 ; PROLOG: header.prol.preheader:
3221 ; PROLOG-NEXT: br label %header.prol
3222 ; PROLOG: header.prol:
3223 ; PROLOG-NEXT: %i4.prol = phi i32 [ %inc.prol, %latch.prol ], [ 0, %header.prol.preheader ]
3224 ; PROLOG-NEXT: %prol.iter = phi i32 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
3225 ; PROLOG-NEXT: %inc.prol = add nuw i32 %i4.prol, 1
3226 ; PROLOG-NEXT: %cmp1.prol = icmp ult i32 %inc.prol, %N
3227 ; PROLOG-NEXT: br i1 %cmp1.prol, label %latch.prol, label %latchExit.unr-lcssa.loopexit1
3228 ; PROLOG: latch.prol:
3229 ; PROLOG-NEXT: %cmp.prol = icmp ult i32 %inc.prol, %M.shifted
3230 ; PROLOG-NEXT: %prol.iter.next = add i32 %prol.iter, 1
3231 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i32 %prol.iter.next, %xtraiter
3232 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !8
3233 ; PROLOG: header.prol.loopexit.unr-lcssa:
3234 ; PROLOG-NEXT: %i4.unr.ph = phi i32 [ %inc.prol, %latch.prol ]
3235 ; PROLOG-NEXT: %i2.ph.unr.ph = phi i32 [ -1, %latch.prol ]
3236 ; PROLOG-NEXT: br label %header.prol.loopexit
3237 ; PROLOG: header.prol.loopexit:
3238 ; PROLOG-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ %i4.unr.ph, %header.prol.loopexit.unr-lcssa ]
3239 ; PROLOG-NEXT: %i2.ph.unr = phi i32 [ undef, %preheader ], [ %i2.ph.unr.ph, %header.prol.loopexit.unr-lcssa ]
3240 ; PROLOG-NEXT: %1 = icmp ult i32 %0, 7
3241 ; PROLOG-NEXT: br i1 %1, label %latchExit, label %preheader.new
3242 ; PROLOG: preheader.new:
3243 ; PROLOG-NEXT: br label %header
3245 ; PROLOG-NEXT: %i4 = phi i32 [ %i4.unr, %preheader.new ], [ %inc.7, %latch.7 ]
3246 ; PROLOG-NEXT: %inc = add nuw i32 %i4, 1
3247 ; PROLOG-NEXT: %cmp1 = icmp ult i32 %inc, %N
3248 ; PROLOG-NEXT: br i1 %cmp1, label %latch, label %latchExit.unr-lcssa.loopexit
3250 ; PROLOG-NEXT: %inc.1 = add nuw i32 %inc, 1
3251 ; PROLOG-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3252 ; PROLOG-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.unr-lcssa.loopexit
3254 ; PROLOG-NEXT: %inc.2 = add nuw i32 %inc.1, 1
3255 ; PROLOG-NEXT: %cmp1.2 = icmp ult i32 %inc.2, %N
3256 ; PROLOG-NEXT: br i1 %cmp1.2, label %latch.2, label %latchExit.unr-lcssa.loopexit
3258 ; PROLOG-NEXT: %inc.3 = add nuw i32 %inc.2, 1
3259 ; PROLOG-NEXT: %cmp1.3 = icmp ult i32 %inc.3, %N
3260 ; PROLOG-NEXT: br i1 %cmp1.3, label %latch.3, label %latchExit.unr-lcssa.loopexit
3262 ; PROLOG-NEXT: %inc.4 = add nuw i32 %inc.3, 1
3263 ; PROLOG-NEXT: %cmp1.4 = icmp ult i32 %inc.4, %N
3264 ; PROLOG-NEXT: br i1 %cmp1.4, label %latch.4, label %latchExit.unr-lcssa.loopexit
3266 ; PROLOG-NEXT: %inc.5 = add nuw i32 %inc.4, 1
3267 ; PROLOG-NEXT: %cmp1.5 = icmp ult i32 %inc.5, %N
3268 ; PROLOG-NEXT: br i1 %cmp1.5, label %latch.5, label %latchExit.unr-lcssa.loopexit
3270 ; PROLOG-NEXT: %inc.6 = add nuw i32 %inc.5, 1
3271 ; PROLOG-NEXT: %cmp1.6 = icmp ult i32 %inc.6, %N
3272 ; PROLOG-NEXT: br i1 %cmp1.6, label %latch.6, label %latchExit.unr-lcssa.loopexit
3274 ; PROLOG-NEXT: %inc.7 = add nuw i32 %inc.6, 1
3275 ; PROLOG-NEXT: %cmp1.7 = icmp ult i32 %inc.7, %N
3276 ; PROLOG-NEXT: br i1 %cmp1.7, label %latch.7, label %latchExit.unr-lcssa.loopexit
3278 ; PROLOG-NEXT: %cmp.7 = icmp ult i32 %inc.7, %M.shifted
3279 ; PROLOG-NEXT: br i1 %cmp.7, label %header, label %latchExit.unr-lcssa.loopexit
3280 ; PROLOG: latchExit.unr-lcssa.loopexit:
3281 ; PROLOG-NEXT: %i2.ph.ph.ph = phi i32 [ %i4, %header ], [ %inc, %latch ], [ %inc.1, %latch.1 ], [ %inc.2, %latch.2 ], [ %inc.3, %latch.3 ], [ %inc.4, %latch.4 ], [ %inc.5, %latch.5 ], [ %inc.6, %latch.6 ], [ -1, %latch.7 ]
3282 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
3283 ; PROLOG: latchExit.unr-lcssa.loopexit1:
3284 ; PROLOG-NEXT: %i2.ph.ph.ph2 = phi i32 [ %i4.prol, %header.prol ]
3285 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
3286 ; PROLOG: latchExit.unr-lcssa:
3287 ; PROLOG-NEXT: %i2.ph.ph = phi i32 [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %i2.ph.ph.ph2, %latchExit.unr-lcssa.loopexit1 ]
3288 ; PROLOG-NEXT: br label %latchExit
3289 ; PROLOG: latchExit:
3290 ; PROLOG-NEXT: %i2.ph = phi i32 [ %i2.ph.unr, %header.prol.loopexit ], [ %i2.ph.ph, %latchExit.unr-lcssa ]
3291 ; PROLOG-NEXT: ret void
3293 ; PROLOG-BLOCK-LABEL: @unique_exit(
3294 ; PROLOG-BLOCK-NEXT: preheader:
3295 ; PROLOG-BLOCK-NEXT: %M.shifted = shl i32 %M, 3
3296 ; PROLOG-BLOCK-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3297 ; PROLOG-BLOCK-NEXT: %0 = add i32 %umax, -1
3298 ; PROLOG-BLOCK-NEXT: %xtraiter = and i32 %umax, 1
3299 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3300 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
3301 ; PROLOG-BLOCK: header.prol.preheader:
3302 ; PROLOG-BLOCK-NEXT: br label %header.prol
3303 ; PROLOG-BLOCK: header.prol:
3304 ; PROLOG-BLOCK-NEXT: %cmp1.prol = icmp ult i32 1, %N
3305 ; PROLOG-BLOCK-NEXT: br i1 %cmp1.prol, label %latch.prol, label %latchExit.unr-lcssa
3306 ; PROLOG-BLOCK: latch.prol:
3307 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
3308 ; PROLOG-BLOCK: header.prol.loopexit:
3309 ; PROLOG-BLOCK-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ 1, %latch.prol ]
3310 ; PROLOG-BLOCK-NEXT: %i2.ph.unr = phi i32 [ undef, %preheader ], [ -1, %latch.prol ]
3311 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i32 %0, 1
3312 ; PROLOG-BLOCK-NEXT: br i1 %1, label %latchExit, label %preheader.new
3313 ; PROLOG-BLOCK: preheader.new:
3314 ; PROLOG-BLOCK-NEXT: br label %header
3315 ; PROLOG-BLOCK: header:
3316 ; PROLOG-BLOCK-NEXT: %i4 = phi i32 [ %i4.unr, %preheader.new ], [ %inc.1, %latch.1 ]
3317 ; PROLOG-BLOCK-NEXT: %inc = add nuw i32 %i4, 1
3318 ; PROLOG-BLOCK-NEXT: %cmp1 = icmp ult i32 %inc, %N
3319 ; PROLOG-BLOCK-NEXT: br i1 %cmp1, label %latch, label %latchExit.unr-lcssa.loopexit
3320 ; PROLOG-BLOCK: latch:
3321 ; PROLOG-BLOCK-NEXT: %inc.1 = add nuw i32 %inc, 1
3322 ; PROLOG-BLOCK-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3323 ; PROLOG-BLOCK-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.unr-lcssa.loopexit
3324 ; PROLOG-BLOCK: latch.1:
3325 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ult i32 %inc.1, %M.shifted
3326 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %header, label %latchExit.unr-lcssa.loopexit, !llvm.loop !8
3327 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
3328 ; PROLOG-BLOCK-NEXT: %i2.ph.ph.ph = phi i32 [ %i4, %header ], [ %inc, %latch ], [ -1, %latch.1 ]
3329 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
3330 ; PROLOG-BLOCK: latchExit.unr-lcssa:
3331 ; PROLOG-BLOCK-NEXT: %i2.ph.ph = phi i32 [ 0, %header.prol ], [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ]
3332 ; PROLOG-BLOCK-NEXT: br label %latchExit
3333 ; PROLOG-BLOCK: latchExit:
3334 ; PROLOG-BLOCK-NEXT: %i2.ph = phi i32 [ %i2.ph.unr, %header.prol.loopexit ], [ %i2.ph.ph, %latchExit.unr-lcssa ]
3335 ; PROLOG-BLOCK-NEXT: ret void
3339 %M.shifted = shl nuw i32 %M, 3
3342 header: ; preds = %preheader, %latch
3343 %i4 = phi i32 [ %inc, %latch ], [ 0, %preheader ]
3344 %inc = add nuw i32 %i4, 1
3345 %cmp1 = icmp ult i32 %inc, %N
3346 br i1 %cmp1, label %latch, label %latchExit
3348 latch: ; preds = %header
3349 %cmp = icmp ult i32 %inc, %M.shifted
3350 br i1 %cmp, label %header, label %latchExit
3352 latchExit: ; preds = %header, %latch
3353 %i2.ph = phi i32 [ %i4, %header ], [ -1, %latch ]
3358 ; two exiting and two exit blocks.
3359 ; the non-latch exiting block has duplicate edges to the non-latch exit block.
3360 define i64 @test5(i64 %trip, i64 %add, i1 %cond) {
3361 ; EPILOG-LABEL: @test5(
3362 ; EPILOG-NEXT: entry:
3363 ; EPILOG-NEXT: %0 = add i64 %trip, -1
3364 ; EPILOG-NEXT: %xtraiter = and i64 %trip, 7
3365 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
3366 ; EPILOG-NEXT: br i1 %1, label %latchexit.unr-lcssa, label %entry.new
3367 ; EPILOG: entry.new:
3368 ; EPILOG-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
3369 ; EPILOG-NEXT: br label %loop_header
3370 ; EPILOG: loop_header:
3371 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
3372 ; EPILOG-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
3373 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
3374 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3375 ; EPILOG: loop_exiting:
3376 ; EPILOG-NEXT: %ivy = add i64 %iv, %add
3377 ; EPILOG-NEXT: switch i64 %sum, label %loop_latch [
3378 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3379 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3381 ; EPILOG: loop_latch:
3382 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3383 ; EPILOG-NEXT: %sum.next = add i64 %sum, %add
3384 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
3385 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3386 ; EPILOG: loop_exiting.1:
3387 ; EPILOG-NEXT: %ivy.1 = add i64 %iv_next, %add
3388 ; EPILOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3389 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3390 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3392 ; EPILOG: loop_latch.1:
3393 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
3394 ; EPILOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
3395 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
3396 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting.2
3397 ; EPILOG: loop_exiting.2:
3398 ; EPILOG-NEXT: %ivy.2 = add i64 %iv_next.1, %add
3399 ; EPILOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
3400 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3401 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3403 ; EPILOG: loop_latch.2:
3404 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
3405 ; EPILOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
3406 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
3407 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting.3
3408 ; EPILOG: loop_exiting.3:
3409 ; EPILOG-NEXT: %ivy.3 = add i64 %iv_next.2, %add
3410 ; EPILOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
3411 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3412 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3414 ; EPILOG: loop_latch.3:
3415 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
3416 ; EPILOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
3417 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
3418 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting.4
3419 ; EPILOG: loop_exiting.4:
3420 ; EPILOG-NEXT: %ivy.4 = add i64 %iv_next.3, %add
3421 ; EPILOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
3422 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3423 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3425 ; EPILOG: loop_latch.4:
3426 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
3427 ; EPILOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
3428 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
3429 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting.5
3430 ; EPILOG: loop_exiting.5:
3431 ; EPILOG-NEXT: %ivy.5 = add i64 %iv_next.4, %add
3432 ; EPILOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
3433 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3434 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3436 ; EPILOG: loop_latch.5:
3437 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
3438 ; EPILOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
3439 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
3440 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting.6
3441 ; EPILOG: loop_exiting.6:
3442 ; EPILOG-NEXT: %ivy.6 = add i64 %iv_next.5, %add
3443 ; EPILOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
3444 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3445 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3447 ; EPILOG: loop_latch.6:
3448 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
3449 ; EPILOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
3450 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
3451 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting.7
3452 ; EPILOG: loop_exiting.7:
3453 ; EPILOG-NEXT: %ivy.7 = add i64 %iv_next.6, %add
3454 ; EPILOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
3455 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3456 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3458 ; EPILOG: loop_latch.7:
3459 ; EPILOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv_next.6, 1
3460 ; EPILOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
3461 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
3462 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
3463 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %latchexit.unr-lcssa.loopexit
3464 ; EPILOG: exit1.loopexit:
3465 ; EPILOG-NEXT: %result.ph = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.2, %loop_exiting.2 ], [ %ivy.2, %loop_exiting.2 ], [ %ivy.3, %loop_exiting.3 ], [ %ivy.3, %loop_exiting.3 ], [ %ivy.4, %loop_exiting.4 ], [ %ivy.4, %loop_exiting.4 ], [ %ivy.5, %loop_exiting.5 ], [ %ivy.5, %loop_exiting.5 ], [ %ivy.6, %loop_exiting.6 ], [ %ivy.6, %loop_exiting.6 ], [ %ivy.7, %loop_exiting.7 ], [ %ivy.7, %loop_exiting.7 ]
3466 ; EPILOG-NEXT: br label %exit1
3467 ; EPILOG: exit1.loopexit2:
3468 ; EPILOG-NEXT: %result.ph3 = phi i64 [ %ivy.epil, %loop_exiting.epil ], [ %ivy.epil, %loop_exiting.epil ]
3469 ; EPILOG-NEXT: br label %exit1
3471 ; EPILOG-NEXT: %result = phi i64 [ %result.ph, %exit1.loopexit ], [ %result.ph3, %exit1.loopexit2 ]
3472 ; EPILOG-NEXT: ret i64 %result
3473 ; EPILOG: latchexit.unr-lcssa.loopexit:
3474 ; EPILOG-NEXT: %sum.next.lcssa.ph.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
3475 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
3476 ; EPILOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
3477 ; EPILOG-NEXT: br label %latchexit.unr-lcssa
3478 ; EPILOG: latchexit.unr-lcssa:
3479 ; EPILOG-NEXT: %sum.next.lcssa.ph = phi i64 [ undef, %entry ], [ %sum.next.lcssa.ph.ph, %latchexit.unr-lcssa.loopexit ]
3480 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %latchexit.unr-lcssa.loopexit ]
3481 ; EPILOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %latchexit.unr-lcssa.loopexit ]
3482 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3483 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %latchexit
3484 ; EPILOG: loop_header.epil.preheader:
3485 ; EPILOG-NEXT: br label %loop_header.epil
3486 ; EPILOG: loop_header.epil:
3487 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
3488 ; EPILOG-NEXT: %sum.epil = phi i64 [ %sum.unr, %loop_header.epil.preheader ], [ %sum.next.epil, %loop_latch.epil ]
3489 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
3490 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting.epil
3491 ; EPILOG: loop_exiting.epil:
3492 ; EPILOG-NEXT: %ivy.epil = add i64 %iv.epil, %add
3493 ; EPILOG-NEXT: switch i64 %sum.epil, label %loop_latch.epil [
3494 ; EPILOG-NEXT: i64 24, label %exit1.loopexit2
3495 ; EPILOG-NEXT: i64 42, label %exit1.loopexit2
3497 ; EPILOG: loop_latch.epil:
3498 ; EPILOG-NEXT: %iv_next.epil = add nuw nsw i64 %iv.epil, 1
3499 ; EPILOG-NEXT: %sum.next.epil = add i64 %sum.epil, %add
3500 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
3501 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
3502 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
3503 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %latchexit.epilog-lcssa, !llvm.loop !9
3504 ; EPILOG: latchexit.epilog-lcssa:
3505 ; EPILOG-NEXT: %sum.next.lcssa.ph1 = phi i64 [ %sum.next.epil, %loop_latch.epil ]
3506 ; EPILOG-NEXT: br label %latchexit
3507 ; EPILOG: latchexit:
3508 ; EPILOG-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ], [ %sum.next.lcssa.ph1, %latchexit.epilog-lcssa ]
3509 ; EPILOG-NEXT: ret i64 %sum.next.lcssa
3511 ; EPILOG-BLOCK-LABEL: @test5(
3512 ; EPILOG-BLOCK-NEXT: entry:
3513 ; EPILOG-BLOCK-NEXT: %0 = add i64 %trip, -1
3514 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
3515 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
3516 ; EPILOG-BLOCK-NEXT: br i1 %1, label %latchexit.unr-lcssa, label %entry.new
3517 ; EPILOG-BLOCK: entry.new:
3518 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
3519 ; EPILOG-BLOCK-NEXT: br label %loop_header
3520 ; EPILOG-BLOCK: loop_header:
3521 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
3522 ; EPILOG-BLOCK-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
3523 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
3524 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3525 ; EPILOG-BLOCK: loop_exiting:
3526 ; EPILOG-BLOCK-NEXT: %ivy = add i64 %iv, %add
3527 ; EPILOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
3528 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3529 ; EPILOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3530 ; EPILOG-BLOCK-NEXT: ]
3531 ; EPILOG-BLOCK: loop_latch:
3532 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3533 ; EPILOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
3534 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
3535 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3536 ; EPILOG-BLOCK: loop_exiting.1:
3537 ; EPILOG-BLOCK-NEXT: %ivy.1 = add i64 %iv_next, %add
3538 ; EPILOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3539 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3540 ; EPILOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3541 ; EPILOG-BLOCK-NEXT: ]
3542 ; EPILOG-BLOCK: loop_latch.1:
3543 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
3544 ; EPILOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
3545 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
3546 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
3547 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %latchexit.unr-lcssa.loopexit, !llvm.loop !9
3548 ; EPILOG-BLOCK: exit1.loopexit:
3549 ; EPILOG-BLOCK-NEXT: %result.ph = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.1, %loop_exiting.1 ]
3550 ; EPILOG-BLOCK-NEXT: br label %exit1
3551 ; EPILOG-BLOCK: exit1:
3552 ; EPILOG-BLOCK-NEXT: %result = phi i64 [ %ivy.epil, %loop_exiting.epil ], [ %ivy.epil, %loop_exiting.epil ], [ %result.ph, %exit1.loopexit ]
3553 ; EPILOG-BLOCK-NEXT: ret i64 %result
3554 ; EPILOG-BLOCK: latchexit.unr-lcssa.loopexit:
3555 ; EPILOG-BLOCK-NEXT: %sum.next.lcssa.ph.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
3556 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
3557 ; EPILOG-BLOCK-NEXT: %sum.unr.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
3558 ; EPILOG-BLOCK-NEXT: br label %latchexit.unr-lcssa
3559 ; EPILOG-BLOCK: latchexit.unr-lcssa:
3560 ; EPILOG-BLOCK-NEXT: %sum.next.lcssa.ph = phi i64 [ undef, %entry ], [ %sum.next.lcssa.ph.ph, %latchexit.unr-lcssa.loopexit ]
3561 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %latchexit.unr-lcssa.loopexit ]
3562 ; EPILOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %latchexit.unr-lcssa.loopexit ]
3563 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3564 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %latchexit
3565 ; EPILOG-BLOCK: loop_header.epil.preheader:
3566 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
3567 ; EPILOG-BLOCK: loop_header.epil:
3568 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting.epil
3569 ; EPILOG-BLOCK: loop_exiting.epil:
3570 ; EPILOG-BLOCK-NEXT: %ivy.epil = add i64 %iv.unr, %add
3571 ; EPILOG-BLOCK-NEXT: switch i64 %sum.unr, label %loop_latch.epil [
3572 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1
3573 ; EPILOG-BLOCK-NEXT: i64 42, label %exit1
3574 ; EPILOG-BLOCK-NEXT: ]
3575 ; EPILOG-BLOCK: loop_latch.epil:
3576 ; EPILOG-BLOCK-NEXT: %sum.next.epil = add i64 %sum.unr, %add
3577 ; EPILOG-BLOCK-NEXT: br label %latchexit
3578 ; EPILOG-BLOCK: latchexit:
3579 ; EPILOG-BLOCK-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ], [ %sum.next.epil, %loop_latch.epil ]
3580 ; EPILOG-BLOCK-NEXT: ret i64 %sum.next.lcssa
3582 ; PROLOG-LABEL: @test5(
3583 ; PROLOG-NEXT: entry:
3584 ; PROLOG-NEXT: %0 = add i64 %trip, -1
3585 ; PROLOG-NEXT: %xtraiter = and i64 %trip, 7
3586 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3587 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
3588 ; PROLOG: loop_header.prol.preheader:
3589 ; PROLOG-NEXT: br label %loop_header.prol
3590 ; PROLOG: loop_header.prol:
3591 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
3592 ; PROLOG-NEXT: %sum.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %sum.next.prol, %loop_latch.prol ]
3593 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
3594 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting.prol
3595 ; PROLOG: loop_exiting.prol:
3596 ; PROLOG-NEXT: %ivy.prol = add i64 %iv.prol, %add
3597 ; PROLOG-NEXT: switch i64 %sum.prol, label %loop_latch.prol [
3598 ; PROLOG-NEXT: i64 24, label %exit1.loopexit1
3599 ; PROLOG-NEXT: i64 42, label %exit1.loopexit1
3601 ; PROLOG: loop_latch.prol:
3602 ; PROLOG-NEXT: %iv_next.prol = add nuw nsw i64 %iv.prol, 1
3603 ; PROLOG-NEXT: %sum.next.prol = add i64 %sum.prol, %add
3604 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
3605 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
3606 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
3607 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !9
3608 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
3609 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
3610 ; PROLOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.prol, %loop_latch.prol ]
3611 ; PROLOG-NEXT: %sum.next.lcssa.unr.ph = phi i64 [ %sum.next.prol, %loop_latch.prol ]
3612 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
3613 ; PROLOG: loop_header.prol.loopexit:
3614 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
3615 ; PROLOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
3616 ; PROLOG-NEXT: %sum.next.lcssa.unr = phi i64 [ undef, %entry ], [ %sum.next.lcssa.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
3617 ; PROLOG-NEXT: %1 = icmp ult i64 %0, 7
3618 ; PROLOG-NEXT: br i1 %1, label %latchexit, label %entry.new
3619 ; PROLOG: entry.new:
3620 ; PROLOG-NEXT: br label %loop_header
3621 ; PROLOG: loop_header:
3622 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
3623 ; PROLOG-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
3624 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3625 ; PROLOG: loop_exiting:
3626 ; PROLOG-NEXT: %ivy = add i64 %iv, %add
3627 ; PROLOG-NEXT: switch i64 %sum, label %loop_latch [
3628 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3629 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3631 ; PROLOG: loop_latch:
3632 ; PROLOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3633 ; PROLOG-NEXT: %sum.next = add i64 %sum, %add
3634 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3635 ; PROLOG: loop_exiting.1:
3636 ; PROLOG-NEXT: %ivy.1 = add i64 %iv_next, %add
3637 ; PROLOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3638 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3639 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3641 ; PROLOG: loop_latch.1:
3642 ; PROLOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
3643 ; PROLOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
3644 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting.2
3645 ; PROLOG: loop_exiting.2:
3646 ; PROLOG-NEXT: %ivy.2 = add i64 %iv_next.1, %add
3647 ; PROLOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
3648 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3649 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3651 ; PROLOG: loop_latch.2:
3652 ; PROLOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
3653 ; PROLOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
3654 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting.3
3655 ; PROLOG: loop_exiting.3:
3656 ; PROLOG-NEXT: %ivy.3 = add i64 %iv_next.2, %add
3657 ; PROLOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
3658 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3659 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3661 ; PROLOG: loop_latch.3:
3662 ; PROLOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
3663 ; PROLOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
3664 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting.4
3665 ; PROLOG: loop_exiting.4:
3666 ; PROLOG-NEXT: %ivy.4 = add i64 %iv_next.3, %add
3667 ; PROLOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
3668 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3669 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3671 ; PROLOG: loop_latch.4:
3672 ; PROLOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
3673 ; PROLOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
3674 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting.5
3675 ; PROLOG: loop_exiting.5:
3676 ; PROLOG-NEXT: %ivy.5 = add i64 %iv_next.4, %add
3677 ; PROLOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
3678 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3679 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3681 ; PROLOG: loop_latch.5:
3682 ; PROLOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
3683 ; PROLOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
3684 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting.6
3685 ; PROLOG: loop_exiting.6:
3686 ; PROLOG-NEXT: %ivy.6 = add i64 %iv_next.5, %add
3687 ; PROLOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
3688 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3689 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3691 ; PROLOG: loop_latch.6:
3692 ; PROLOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
3693 ; PROLOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
3694 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting.7
3695 ; PROLOG: loop_exiting.7:
3696 ; PROLOG-NEXT: %ivy.7 = add i64 %iv_next.6, %add
3697 ; PROLOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
3698 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3699 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3701 ; PROLOG: loop_latch.7:
3702 ; PROLOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv_next.6, 1
3703 ; PROLOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
3704 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
3705 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %latchexit.unr-lcssa
3706 ; PROLOG: exit1.loopexit:
3707 ; PROLOG-NEXT: %result.ph = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.2, %loop_exiting.2 ], [ %ivy.2, %loop_exiting.2 ], [ %ivy.3, %loop_exiting.3 ], [ %ivy.3, %loop_exiting.3 ], [ %ivy.4, %loop_exiting.4 ], [ %ivy.4, %loop_exiting.4 ], [ %ivy.5, %loop_exiting.5 ], [ %ivy.5, %loop_exiting.5 ], [ %ivy.6, %loop_exiting.6 ], [ %ivy.6, %loop_exiting.6 ], [ %ivy.7, %loop_exiting.7 ], [ %ivy.7, %loop_exiting.7 ]
3708 ; PROLOG-NEXT: br label %exit1
3709 ; PROLOG: exit1.loopexit1:
3710 ; PROLOG-NEXT: %result.ph2 = phi i64 [ %ivy.prol, %loop_exiting.prol ], [ %ivy.prol, %loop_exiting.prol ]
3711 ; PROLOG-NEXT: br label %exit1
3713 ; PROLOG-NEXT: %result = phi i64 [ %result.ph, %exit1.loopexit ], [ %result.ph2, %exit1.loopexit1 ]
3714 ; PROLOG-NEXT: ret i64 %result
3715 ; PROLOG: latchexit.unr-lcssa:
3716 ; PROLOG-NEXT: %sum.next.lcssa.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
3717 ; PROLOG-NEXT: br label %latchexit
3718 ; PROLOG: latchexit:
3719 ; PROLOG-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.unr, %loop_header.prol.loopexit ], [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ]
3720 ; PROLOG-NEXT: ret i64 %sum.next.lcssa
3722 ; PROLOG-BLOCK-LABEL: @test5(
3723 ; PROLOG-BLOCK-NEXT: entry:
3724 ; PROLOG-BLOCK-NEXT: %0 = add i64 %trip, -1
3725 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
3726 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3727 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
3728 ; PROLOG-BLOCK: loop_header.prol.preheader:
3729 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
3730 ; PROLOG-BLOCK: loop_header.prol:
3731 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting.prol
3732 ; PROLOG-BLOCK: loop_exiting.prol:
3733 ; PROLOG-BLOCK-NEXT: switch i64 0, label %loop_latch.prol [
3734 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1
3735 ; PROLOG-BLOCK-NEXT: i64 42, label %exit1
3736 ; PROLOG-BLOCK-NEXT: ]
3737 ; PROLOG-BLOCK: loop_latch.prol:
3738 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
3739 ; PROLOG-BLOCK: loop_header.prol.loopexit:
3740 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
3741 ; PROLOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %add, %loop_latch.prol ]
3742 ; PROLOG-BLOCK-NEXT: %sum.next.lcssa.unr = phi i64 [ undef, %entry ], [ %add, %loop_latch.prol ]
3743 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
3744 ; PROLOG-BLOCK-NEXT: br i1 %1, label %latchexit, label %entry.new
3745 ; PROLOG-BLOCK: entry.new:
3746 ; PROLOG-BLOCK-NEXT: br label %loop_header
3747 ; PROLOG-BLOCK: loop_header:
3748 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
3749 ; PROLOG-BLOCK-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
3750 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3751 ; PROLOG-BLOCK: loop_exiting:
3752 ; PROLOG-BLOCK-NEXT: %ivy = add i64 %iv, %add
3753 ; PROLOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
3754 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3755 ; PROLOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3756 ; PROLOG-BLOCK-NEXT: ]
3757 ; PROLOG-BLOCK: loop_latch:
3758 ; PROLOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3759 ; PROLOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
3760 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3761 ; PROLOG-BLOCK: loop_exiting.1:
3762 ; PROLOG-BLOCK-NEXT: %ivy.1 = add i64 %iv_next, %add
3763 ; PROLOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3764 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3765 ; PROLOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3766 ; PROLOG-BLOCK-NEXT: ]
3767 ; PROLOG-BLOCK: loop_latch.1:
3768 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
3769 ; PROLOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
3770 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
3771 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %latchexit.unr-lcssa, !llvm.loop !9
3772 ; PROLOG-BLOCK: exit1.loopexit:
3773 ; PROLOG-BLOCK-NEXT: %result.ph = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.1, %loop_exiting.1 ]
3774 ; PROLOG-BLOCK-NEXT: br label %exit1
3775 ; PROLOG-BLOCK: exit1:
3776 ; PROLOG-BLOCK-NEXT: %result = phi i64 [ %add, %loop_exiting.prol ], [ %add, %loop_exiting.prol ], [ %result.ph, %exit1.loopexit ]
3777 ; PROLOG-BLOCK-NEXT: ret i64 %result
3778 ; PROLOG-BLOCK: latchexit.unr-lcssa:
3779 ; PROLOG-BLOCK-NEXT: %sum.next.lcssa.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
3780 ; PROLOG-BLOCK-NEXT: br label %latchexit
3781 ; PROLOG-BLOCK: latchexit:
3782 ; PROLOG-BLOCK-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.unr, %loop_header.prol.loopexit ], [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ]
3783 ; PROLOG-BLOCK-NEXT: ret i64 %sum.next.lcssa
3787 br label %loop_header
3790 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
3791 %sum = phi i64 [ 0, %entry ], [ %sum.next, %loop_latch ]
3792 br i1 %cond, label %loop_latch, label %loop_exiting
3795 %ivy = add i64 %iv, %add
3796 switch i64 %sum, label %loop_latch [
3797 i64 24, label %exit1
3798 i64 42, label %exit1
3802 %iv_next = add nuw nsw i64 %iv, 1
3803 %sum.next = add i64 %sum, %add
3804 %cmp = icmp ne i64 %iv_next, %trip
3805 br i1 %cmp, label %loop_header, label %latchexit
3808 %result = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ]
3815 ; test when exit blocks have successors.
3816 define i32 @test6(i32* nocapture %a, i64 %n, i1 %cond, i32 %x) {
3817 ; EPILOG-LABEL: @test6(
3818 ; EPILOG-NEXT: entry:
3819 ; EPILOG-NEXT: %0 = add i64 %n, -1
3820 ; EPILOG-NEXT: %xtraiter = and i64 %n, 7
3821 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
3822 ; EPILOG-NEXT: br i1 %1, label %latch_exit.unr-lcssa, label %entry.new
3823 ; EPILOG: entry.new:
3824 ; EPILOG-NEXT: %unroll_iter = sub i64 %n, %xtraiter
3825 ; EPILOG-NEXT: br label %header
3827 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
3828 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
3829 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
3830 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
3831 ; EPILOG: for.exiting_block:
3832 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
3833 ; EPILOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
3835 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
3836 ; EPILOG-NEXT: %load = load i32, i32* %arrayidx, align 4
3837 ; EPILOG-NEXT: %add = add nsw i32 %load, %sum.02
3838 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
3839 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
3840 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
3841 ; EPILOG: for.exiting_block.1:
3842 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
3843 ; EPILOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
3845 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
3846 ; EPILOG-NEXT: %load.1 = load i32, i32* %arrayidx.1, align 4
3847 ; EPILOG-NEXT: %add.1 = add nsw i32 %load.1, %add
3848 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
3849 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
3850 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
3851 ; EPILOG: for.exiting_block.2:
3852 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
3853 ; EPILOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
3855 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
3856 ; EPILOG-NEXT: %load.2 = load i32, i32* %arrayidx.2, align 4
3857 ; EPILOG-NEXT: %add.2 = add nsw i32 %load.2, %add.1
3858 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
3859 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
3860 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
3861 ; EPILOG: for.exiting_block.3:
3862 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
3863 ; EPILOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
3865 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
3866 ; EPILOG-NEXT: %load.3 = load i32, i32* %arrayidx.3, align 4
3867 ; EPILOG-NEXT: %add.3 = add nsw i32 %load.3, %add.2
3868 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
3869 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
3870 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
3871 ; EPILOG: for.exiting_block.4:
3872 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
3873 ; EPILOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
3875 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
3876 ; EPILOG-NEXT: %load.4 = load i32, i32* %arrayidx.4, align 4
3877 ; EPILOG-NEXT: %add.4 = add nsw i32 %load.4, %add.3
3878 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
3879 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
3880 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
3881 ; EPILOG: for.exiting_block.5:
3882 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
3883 ; EPILOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
3885 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
3886 ; EPILOG-NEXT: %load.5 = load i32, i32* %arrayidx.5, align 4
3887 ; EPILOG-NEXT: %add.5 = add nsw i32 %load.5, %add.4
3888 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
3889 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
3890 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
3891 ; EPILOG: for.exiting_block.6:
3892 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
3893 ; EPILOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
3895 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
3896 ; EPILOG-NEXT: %load.6 = load i32, i32* %arrayidx.6, align 4
3897 ; EPILOG-NEXT: %add.6 = add nsw i32 %load.6, %add.5
3898 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
3899 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
3900 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
3901 ; EPILOG: for.exiting_block.7:
3902 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
3903 ; EPILOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
3905 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
3906 ; EPILOG-NEXT: %load.7 = load i32, i32* %arrayidx.7, align 4
3907 ; EPILOG-NEXT: %add.7 = add nsw i32 %load.7, %add.6
3908 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
3909 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
3910 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
3911 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latch_exit.unr-lcssa.loopexit, label %header
3912 ; EPILOG: latch_exit.unr-lcssa.loopexit:
3913 ; EPILOG-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.7, %latch.7 ]
3914 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
3915 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
3916 ; EPILOG-NEXT: br label %latch_exit.unr-lcssa
3917 ; EPILOG: latch_exit.unr-lcssa:
3918 ; EPILOG-NEXT: %sum.0.lcssa.ph = phi i32 [ undef, %entry ], [ %sum.0.lcssa.ph.ph, %latch_exit.unr-lcssa.loopexit ]
3919 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latch_exit.unr-lcssa.loopexit ]
3920 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latch_exit.unr-lcssa.loopexit ]
3921 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3922 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latch_exit
3923 ; EPILOG: header.epil.preheader:
3924 ; EPILOG-NEXT: br label %header.epil
3925 ; EPILOG: header.epil:
3926 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
3927 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
3928 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
3929 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit2, label %for.exiting_block.epil
3930 ; EPILOG: for.exiting_block.epil:
3931 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
3932 ; EPILOG-NEXT: br i1 %cmp.epil, label %for.exit2.loopexit2, label %latch.epil
3933 ; EPILOG: latch.epil:
3934 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
3935 ; EPILOG-NEXT: %load.epil = load i32, i32* %arrayidx.epil, align 4
3936 ; EPILOG-NEXT: %add.epil = add nsw i32 %load.epil, %sum.02.epil
3937 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
3938 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
3939 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
3940 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
3941 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latch_exit.epilog-lcssa, !llvm.loop !10
3942 ; EPILOG: latch_exit.epilog-lcssa:
3943 ; EPILOG-NEXT: %sum.0.lcssa.ph1 = phi i32 [ %add.epil, %latch.epil ]
3944 ; EPILOG-NEXT: br label %latch_exit
3945 ; EPILOG: latch_exit:
3946 ; EPILOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ], [ %sum.0.lcssa.ph1, %latch_exit.epilog-lcssa ]
3947 ; EPILOG-NEXT: ret i32 %sum.0.lcssa
3948 ; EPILOG: for.exit2.loopexit:
3949 ; EPILOG-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %latch ], [ 42, %for.exiting_block.1 ], [ %add.1, %latch.1 ], [ 42, %for.exiting_block.2 ], [ %add.2, %latch.2 ], [ 42, %for.exiting_block.3 ], [ %add.3, %latch.3 ], [ 42, %for.exiting_block.4 ], [ %add.4, %latch.4 ], [ 42, %for.exiting_block.5 ], [ %add.5, %latch.5 ], [ 42, %for.exiting_block.6 ], [ %add.6, %latch.6 ], [ 42, %for.exiting_block.7 ]
3950 ; EPILOG-NEXT: br label %for.exit2
3951 ; EPILOG: for.exit2.loopexit2:
3952 ; EPILOG-NEXT: %retval.ph3 = phi i32 [ 42, %for.exiting_block.epil ], [ %sum.02.epil, %header.epil ]
3953 ; EPILOG-NEXT: br label %for.exit2
3954 ; EPILOG: for.exit2:
3955 ; EPILOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph3, %for.exit2.loopexit2 ]
3956 ; EPILOG-NEXT: %addx = add i32 %retval, %x
3957 ; EPILOG-NEXT: br i1 %cond, label %exit_true, label %exit_false
3958 ; EPILOG: exit_true:
3959 ; EPILOG-NEXT: ret i32 %retval
3960 ; EPILOG: exit_false:
3961 ; EPILOG-NEXT: ret i32 %addx
3963 ; EPILOG-BLOCK-LABEL: @test6(
3964 ; EPILOG-BLOCK-NEXT: entry:
3965 ; EPILOG-BLOCK-NEXT: %0 = add i64 %n, -1
3966 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
3967 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
3968 ; EPILOG-BLOCK-NEXT: br i1 %1, label %latch_exit.unr-lcssa, label %entry.new
3969 ; EPILOG-BLOCK: entry.new:
3970 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %n, %xtraiter
3971 ; EPILOG-BLOCK-NEXT: br label %header
3972 ; EPILOG-BLOCK: header:
3973 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
3974 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
3975 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
3976 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
3977 ; EPILOG-BLOCK: for.exiting_block:
3978 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
3979 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
3980 ; EPILOG-BLOCK: latch:
3981 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
3982 ; EPILOG-BLOCK-NEXT: %load = load i32, i32* %arrayidx, align 4
3983 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %load, %sum.02
3984 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
3985 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
3986 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
3987 ; EPILOG-BLOCK: for.exiting_block.1:
3988 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
3989 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
3990 ; EPILOG-BLOCK: latch.1:
3991 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
3992 ; EPILOG-BLOCK-NEXT: %load.1 = load i32, i32* %arrayidx.1, align 4
3993 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %load.1, %add
3994 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
3995 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
3996 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
3997 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latch_exit.unr-lcssa.loopexit, label %header, !llvm.loop !10
3998 ; EPILOG-BLOCK: latch_exit.unr-lcssa.loopexit:
3999 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.1, %latch.1 ]
4000 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
4001 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
4002 ; EPILOG-BLOCK-NEXT: br label %latch_exit.unr-lcssa
4003 ; EPILOG-BLOCK: latch_exit.unr-lcssa:
4004 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ undef, %entry ], [ %sum.0.lcssa.ph.ph, %latch_exit.unr-lcssa.loopexit ]
4005 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latch_exit.unr-lcssa.loopexit ]
4006 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latch_exit.unr-lcssa.loopexit ]
4007 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4008 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latch_exit
4009 ; EPILOG-BLOCK: header.epil.preheader:
4010 ; EPILOG-BLOCK-NEXT: br label %header.epil
4011 ; EPILOG-BLOCK: header.epil:
4012 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.epil
4013 ; EPILOG-BLOCK: for.exiting_block.epil:
4014 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
4015 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %for.exit2, label %latch.epil
4016 ; EPILOG-BLOCK: latch.epil:
4017 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
4018 ; EPILOG-BLOCK-NEXT: %load.epil = load i32, i32* %arrayidx.epil, align 4
4019 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %load.epil, %sum.02.unr
4020 ; EPILOG-BLOCK-NEXT: br label %latch_exit
4021 ; EPILOG-BLOCK: latch_exit:
4022 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ], [ %add.epil, %latch.epil ]
4023 ; EPILOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
4024 ; EPILOG-BLOCK: for.exit2.loopexit:
4025 ; EPILOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %latch ], [ 42, %for.exiting_block.1 ]
4026 ; EPILOG-BLOCK-NEXT: br label %for.exit2
4027 ; EPILOG-BLOCK: for.exit2:
4028 ; EPILOG-BLOCK-NEXT: %retval = phi i32 [ %sum.02.unr, %header.epil ], [ 42, %for.exiting_block.epil ], [ %retval.ph, %for.exit2.loopexit ]
4029 ; EPILOG-BLOCK-NEXT: %addx = add i32 %retval, %x
4030 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %exit_true, label %exit_false
4031 ; EPILOG-BLOCK: exit_true:
4032 ; EPILOG-BLOCK-NEXT: ret i32 %retval
4033 ; EPILOG-BLOCK: exit_false:
4034 ; EPILOG-BLOCK-NEXT: ret i32 %addx
4036 ; PROLOG-LABEL: @test6(
4037 ; PROLOG-NEXT: entry:
4038 ; PROLOG-NEXT: %0 = add i64 %n, -1
4039 ; PROLOG-NEXT: %xtraiter = and i64 %n, 7
4040 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4041 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4042 ; PROLOG: header.prol.preheader:
4043 ; PROLOG-NEXT: br label %header.prol
4044 ; PROLOG: header.prol:
4045 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
4046 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
4047 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
4048 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit1, label %for.exiting_block.prol
4049 ; PROLOG: for.exiting_block.prol:
4050 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
4051 ; PROLOG-NEXT: br i1 %cmp.prol, label %for.exit2.loopexit1, label %latch.prol
4052 ; PROLOG: latch.prol:
4053 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
4054 ; PROLOG-NEXT: %load.prol = load i32, i32* %arrayidx.prol, align 4
4055 ; PROLOG-NEXT: %add.prol = add nsw i32 %load.prol, %sum.02.prol
4056 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
4057 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
4058 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
4059 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
4060 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !10
4061 ; PROLOG: header.prol.loopexit.unr-lcssa:
4062 ; PROLOG-NEXT: %sum.0.lcssa.unr.ph = phi i32 [ %add.prol, %latch.prol ]
4063 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
4064 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
4065 ; PROLOG-NEXT: br label %header.prol.loopexit
4066 ; PROLOG: header.prol.loopexit:
4067 ; PROLOG-NEXT: %sum.0.lcssa.unr = phi i32 [ undef, %entry ], [ %sum.0.lcssa.unr.ph, %header.prol.loopexit.unr-lcssa ]
4068 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
4069 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
4070 ; PROLOG-NEXT: %1 = icmp ult i64 %0, 7
4071 ; PROLOG-NEXT: br i1 %1, label %latch_exit, label %entry.new
4072 ; PROLOG: entry.new:
4073 ; PROLOG-NEXT: br label %header
4075 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
4076 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
4077 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
4078 ; PROLOG: for.exiting_block:
4079 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
4080 ; PROLOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
4082 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
4083 ; PROLOG-NEXT: %load = load i32, i32* %arrayidx, align 4
4084 ; PROLOG-NEXT: %add = add nsw i32 %load, %sum.02
4085 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
4086 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
4087 ; PROLOG: for.exiting_block.1:
4088 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
4089 ; PROLOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
4091 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
4092 ; PROLOG-NEXT: %load.1 = load i32, i32* %arrayidx.1, align 4
4093 ; PROLOG-NEXT: %add.1 = add nsw i32 %load.1, %add
4094 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
4095 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
4096 ; PROLOG: for.exiting_block.2:
4097 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
4098 ; PROLOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
4100 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
4101 ; PROLOG-NEXT: %load.2 = load i32, i32* %arrayidx.2, align 4
4102 ; PROLOG-NEXT: %add.2 = add nsw i32 %load.2, %add.1
4103 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
4104 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
4105 ; PROLOG: for.exiting_block.3:
4106 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
4107 ; PROLOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
4109 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
4110 ; PROLOG-NEXT: %load.3 = load i32, i32* %arrayidx.3, align 4
4111 ; PROLOG-NEXT: %add.3 = add nsw i32 %load.3, %add.2
4112 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
4113 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
4114 ; PROLOG: for.exiting_block.4:
4115 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
4116 ; PROLOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
4118 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
4119 ; PROLOG-NEXT: %load.4 = load i32, i32* %arrayidx.4, align 4
4120 ; PROLOG-NEXT: %add.4 = add nsw i32 %load.4, %add.3
4121 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
4122 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
4123 ; PROLOG: for.exiting_block.5:
4124 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
4125 ; PROLOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
4127 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
4128 ; PROLOG-NEXT: %load.5 = load i32, i32* %arrayidx.5, align 4
4129 ; PROLOG-NEXT: %add.5 = add nsw i32 %load.5, %add.4
4130 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
4131 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
4132 ; PROLOG: for.exiting_block.6:
4133 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
4134 ; PROLOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
4136 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
4137 ; PROLOG-NEXT: %load.6 = load i32, i32* %arrayidx.6, align 4
4138 ; PROLOG-NEXT: %add.6 = add nsw i32 %load.6, %add.5
4139 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
4140 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
4141 ; PROLOG: for.exiting_block.7:
4142 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
4143 ; PROLOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
4145 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
4146 ; PROLOG-NEXT: %load.7 = load i32, i32* %arrayidx.7, align 4
4147 ; PROLOG-NEXT: %add.7 = add nsw i32 %load.7, %add.6
4148 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
4149 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
4150 ; PROLOG-NEXT: br i1 %exitcond.7, label %latch_exit.unr-lcssa, label %header
4151 ; PROLOG: latch_exit.unr-lcssa:
4152 ; PROLOG-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.7, %latch.7 ]
4153 ; PROLOG-NEXT: br label %latch_exit
4154 ; PROLOG: latch_exit:
4155 ; PROLOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ]
4156 ; PROLOG-NEXT: ret i32 %sum.0.lcssa
4157 ; PROLOG: for.exit2.loopexit:
4158 ; PROLOG-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %latch ], [ 42, %for.exiting_block.1 ], [ %add.1, %latch.1 ], [ 42, %for.exiting_block.2 ], [ %add.2, %latch.2 ], [ 42, %for.exiting_block.3 ], [ %add.3, %latch.3 ], [ 42, %for.exiting_block.4 ], [ %add.4, %latch.4 ], [ 42, %for.exiting_block.5 ], [ %add.5, %latch.5 ], [ 42, %for.exiting_block.6 ], [ %add.6, %latch.6 ], [ 42, %for.exiting_block.7 ]
4159 ; PROLOG-NEXT: br label %for.exit2
4160 ; PROLOG: for.exit2.loopexit1:
4161 ; PROLOG-NEXT: %retval.ph2 = phi i32 [ 42, %for.exiting_block.prol ], [ %sum.02.prol, %header.prol ]
4162 ; PROLOG-NEXT: br label %for.exit2
4163 ; PROLOG: for.exit2:
4164 ; PROLOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph2, %for.exit2.loopexit1 ]
4165 ; PROLOG-NEXT: %addx = add i32 %retval, %x
4166 ; PROLOG-NEXT: br i1 %cond, label %exit_true, label %exit_false
4167 ; PROLOG: exit_true:
4168 ; PROLOG-NEXT: ret i32 %retval
4169 ; PROLOG: exit_false:
4170 ; PROLOG-NEXT: ret i32 %addx
4172 ; PROLOG-BLOCK-LABEL: @test6(
4173 ; PROLOG-BLOCK-NEXT: entry:
4174 ; PROLOG-BLOCK-NEXT: %0 = add i64 %n, -1
4175 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %n, 1
4176 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4177 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4178 ; PROLOG-BLOCK: header.prol.preheader:
4179 ; PROLOG-BLOCK-NEXT: br label %header.prol
4180 ; PROLOG-BLOCK: header.prol:
4181 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.prol
4182 ; PROLOG-BLOCK: for.exiting_block.prol:
4183 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
4184 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %for.exit2, label %latch.prol
4185 ; PROLOG-BLOCK: latch.prol:
4186 ; PROLOG-BLOCK-NEXT: %load.prol = load i32, i32* %a, align 4
4187 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
4188 ; PROLOG-BLOCK: header.prol.loopexit:
4189 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.unr = phi i32 [ undef, %entry ], [ %load.prol, %latch.prol ]
4190 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
4191 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %load.prol, %latch.prol ]
4192 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
4193 ; PROLOG-BLOCK-NEXT: br i1 %1, label %latch_exit, label %entry.new
4194 ; PROLOG-BLOCK: entry.new:
4195 ; PROLOG-BLOCK-NEXT: br label %header
4196 ; PROLOG-BLOCK: header:
4197 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
4198 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
4199 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
4200 ; PROLOG-BLOCK: for.exiting_block:
4201 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
4202 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
4203 ; PROLOG-BLOCK: latch:
4204 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
4205 ; PROLOG-BLOCK-NEXT: %load = load i32, i32* %arrayidx, align 4
4206 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %load, %sum.02
4207 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
4208 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
4209 ; PROLOG-BLOCK: for.exiting_block.1:
4210 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
4211 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
4212 ; PROLOG-BLOCK: latch.1:
4213 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
4214 ; PROLOG-BLOCK-NEXT: %load.1 = load i32, i32* %arrayidx.1, align 4
4215 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %load.1, %add
4216 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
4217 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
4218 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latch_exit.unr-lcssa, label %header, !llvm.loop !10
4219 ; PROLOG-BLOCK: latch_exit.unr-lcssa:
4220 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.1, %latch.1 ]
4221 ; PROLOG-BLOCK-NEXT: br label %latch_exit
4222 ; PROLOG-BLOCK: latch_exit:
4223 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ]
4224 ; PROLOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
4225 ; PROLOG-BLOCK: for.exit2.loopexit:
4226 ; PROLOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %latch ], [ 42, %for.exiting_block.1 ]
4227 ; PROLOG-BLOCK-NEXT: br label %for.exit2
4228 ; PROLOG-BLOCK: for.exit2:
4229 ; PROLOG-BLOCK-NEXT: %retval = phi i32 [ 0, %header.prol ], [ 42, %for.exiting_block.prol ], [ %retval.ph, %for.exit2.loopexit ]
4230 ; PROLOG-BLOCK-NEXT: %addx = add i32 %retval, %x
4231 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %exit_true, label %exit_false
4232 ; PROLOG-BLOCK: exit_true:
4233 ; PROLOG-BLOCK-NEXT: ret i32 %retval
4234 ; PROLOG-BLOCK: exit_false:
4235 ; PROLOG-BLOCK-NEXT: ret i32 %addx
4242 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
4243 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
4244 br i1 false, label %for.exit2, label %for.exiting_block
4247 %cmp = icmp eq i64 %n, 42
4248 br i1 %cmp, label %for.exit2, label %latch
4251 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
4252 %load = load i32, i32* %arrayidx, align 4
4253 %add = add nsw i32 %load, %sum.02
4254 %indvars.iv.next = add i64 %indvars.iv, 1
4255 %exitcond = icmp eq i64 %indvars.iv.next, %n
4256 br i1 %exitcond, label %latch_exit, label %header
4259 %sum.0.lcssa = phi i32 [ %add, %latch ]
4260 ret i32 %sum.0.lcssa
4263 %retval = phi i32 [ %sum.02, %header ], [ 42, %for.exiting_block ]
4264 %addx = add i32 %retval, %x
4265 br i1 %cond, label %exit_true, label %exit_false
4274 ; test when value in exit block does not have VMap.
4275 define i32 @test7(i32 %arg, i32 %arg1, i32 %arg2) {
4276 ; EPILOG-LABEL: @test7(
4278 ; EPILOG-NEXT: %i = icmp slt i32 undef, 2
4279 ; EPILOG-NEXT: %sext = sext i32 undef to i64
4280 ; EPILOG-NEXT: %shft = ashr exact i32 %arg, 16
4281 ; EPILOG-NEXT: br i1 %i, label %loopexit2, label %preheader
4282 ; EPILOG: preheader:
4283 ; EPILOG-NEXT: %0 = add nsw i64 %sext, -1
4284 ; EPILOG-NEXT: %1 = add nsw i64 %sext, -2
4285 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
4286 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
4287 ; EPILOG-NEXT: br i1 %2, label %latchexit.unr-lcssa, label %preheader.new
4288 ; EPILOG: preheader.new:
4289 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
4290 ; EPILOG-NEXT: br label %header
4292 ; EPILOG-NEXT: %i6 = phi i64 [ 1, %preheader.new ], [ %add.7, %latch.7 ]
4293 ; EPILOG-NEXT: %niter = phi i64 [ 0, %preheader.new ], [ %niter.next.7, %latch.7 ]
4294 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4296 ; EPILOG-NEXT: %add = add nuw nsw i64 %i6, 1
4297 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
4298 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4300 ; EPILOG-NEXT: %add.1 = add nuw nsw i64 %add, 1
4301 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
4302 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.2
4304 ; EPILOG-NEXT: %add.2 = add nuw nsw i64 %add.1, 1
4305 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
4306 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.3
4308 ; EPILOG-NEXT: %add.3 = add nuw nsw i64 %add.2, 1
4309 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
4310 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.4
4312 ; EPILOG-NEXT: %add.4 = add nuw nsw i64 %add.3, 1
4313 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
4314 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.5
4316 ; EPILOG-NEXT: %add.5 = add nuw nsw i64 %add.4, 1
4317 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
4318 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.6
4320 ; EPILOG-NEXT: %add.6 = add nuw nsw i64 %add.5, 1
4321 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
4322 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.7
4324 ; EPILOG-NEXT: %add.7 = add nuw nsw i64 %add.6, 1
4325 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
4326 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
4327 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %header, label %latchexit.unr-lcssa.loopexit
4328 ; EPILOG: latchexit.unr-lcssa.loopexit:
4329 ; EPILOG-NEXT: %i6.unr.ph = phi i64 [ %add.7, %latch.7 ]
4330 ; EPILOG-NEXT: br label %latchexit.unr-lcssa
4331 ; EPILOG: latchexit.unr-lcssa:
4332 ; EPILOG-NEXT: %i6.unr = phi i64 [ 1, %preheader ], [ %i6.unr.ph, %latchexit.unr-lcssa.loopexit ]
4333 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4334 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchexit
4335 ; EPILOG: header.epil.preheader:
4336 ; EPILOG-NEXT: br label %header.epil
4337 ; EPILOG: header.epil:
4338 ; EPILOG-NEXT: %i6.epil = phi i64 [ %i6.unr, %header.epil.preheader ], [ %add.epil, %latch.epil ]
4339 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
4340 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit1, label %latch.epil
4341 ; EPILOG: latch.epil:
4342 ; EPILOG-NEXT: %add.epil = add nuw nsw i64 %i6.epil, 1
4343 ; EPILOG-NEXT: %i9.epil = icmp slt i64 %add.epil, %sext
4344 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
4345 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
4346 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchexit.epilog-lcssa, !llvm.loop !11
4347 ; EPILOG: latchexit.epilog-lcssa:
4348 ; EPILOG-NEXT: br label %latchexit
4349 ; EPILOG: latchexit:
4350 ; EPILOG-NEXT: unreachable
4351 ; EPILOG: loopexit2:
4352 ; EPILOG-NEXT: ret i32 %shft
4353 ; EPILOG: loopexit1.loopexit:
4354 ; EPILOG-NEXT: %sext3.ph = phi i32 [ %shft, %header ], [ %shft, %latch ], [ %shft, %latch.1 ], [ %shft, %latch.2 ], [ %shft, %latch.3 ], [ %shft, %latch.4 ], [ %shft, %latch.5 ], [ %shft, %latch.6 ]
4355 ; EPILOG-NEXT: br label %loopexit1
4356 ; EPILOG: loopexit1.loopexit1:
4357 ; EPILOG-NEXT: %sext3.ph2 = phi i32 [ %shft, %header.epil ]
4358 ; EPILOG-NEXT: br label %loopexit1
4359 ; EPILOG: loopexit1:
4360 ; EPILOG-NEXT: %sext3 = phi i32 [ %sext3.ph, %loopexit1.loopexit ], [ %sext3.ph2, %loopexit1.loopexit1 ]
4361 ; EPILOG-NEXT: ret i32 %sext3
4363 ; EPILOG-BLOCK-LABEL: @test7(
4364 ; EPILOG-BLOCK-NEXT: bb:
4365 ; EPILOG-BLOCK-NEXT: %i = icmp slt i32 undef, 2
4366 ; EPILOG-BLOCK-NEXT: %sext = sext i32 undef to i64
4367 ; EPILOG-BLOCK-NEXT: %shft = ashr exact i32 %arg, 16
4368 ; EPILOG-BLOCK-NEXT: br i1 %i, label %loopexit2, label %preheader
4369 ; EPILOG-BLOCK: preheader:
4370 ; EPILOG-BLOCK-NEXT: %0 = add nsw i64 %sext, -1
4371 ; EPILOG-BLOCK-NEXT: %1 = add nsw i64 %sext, -2
4372 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4373 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4374 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchexit.unr-lcssa, label %preheader.new
4375 ; EPILOG-BLOCK: preheader.new:
4376 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
4377 ; EPILOG-BLOCK-NEXT: br label %header
4378 ; EPILOG-BLOCK: header:
4379 ; EPILOG-BLOCK-NEXT: %i6 = phi i64 [ 1, %preheader.new ], [ %add.1, %latch.1 ]
4380 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %preheader.new ], [ %niter.next.1, %latch.1 ]
4381 ; EPILOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4382 ; EPILOG-BLOCK: latch:
4383 ; EPILOG-BLOCK-NEXT: %add = add nuw nsw i64 %i6, 1
4384 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
4385 ; EPILOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4386 ; EPILOG-BLOCK: latch.1:
4387 ; EPILOG-BLOCK-NEXT: %add.1 = add nuw nsw i64 %add, 1
4388 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
4389 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
4390 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %header, label %latchexit.unr-lcssa.loopexit, !llvm.loop !11
4391 ; EPILOG-BLOCK: latchexit.unr-lcssa.loopexit:
4392 ; EPILOG-BLOCK-NEXT: br label %latchexit.unr-lcssa
4393 ; EPILOG-BLOCK: latchexit.unr-lcssa:
4394 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4395 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchexit
4396 ; EPILOG-BLOCK: header.epil.preheader:
4397 ; EPILOG-BLOCK-NEXT: br label %header.epil
4398 ; EPILOG-BLOCK: header.epil:
4399 ; EPILOG-BLOCK-NEXT: br i1 false, label %loopexit1, label %latch.epil
4400 ; EPILOG-BLOCK: latch.epil:
4401 ; EPILOG-BLOCK-NEXT: br label %latchexit
4402 ; EPILOG-BLOCK: latchexit:
4403 ; EPILOG-BLOCK-NEXT: unreachable
4404 ; EPILOG-BLOCK: loopexit2:
4405 ; EPILOG-BLOCK-NEXT: ret i32 %shft
4406 ; EPILOG-BLOCK: loopexit1.loopexit:
4407 ; EPILOG-BLOCK-NEXT: %sext3.ph = phi i32 [ %shft, %header ], [ %shft, %latch ]
4408 ; EPILOG-BLOCK-NEXT: br label %loopexit1
4409 ; EPILOG-BLOCK: loopexit1:
4410 ; EPILOG-BLOCK-NEXT: %sext3 = phi i32 [ %shft, %header.epil ], [ %sext3.ph, %loopexit1.loopexit ]
4411 ; EPILOG-BLOCK-NEXT: ret i32 %sext3
4413 ; PROLOG-LABEL: @test7(
4415 ; PROLOG-NEXT: %i = icmp slt i32 undef, 2
4416 ; PROLOG-NEXT: %sext = sext i32 undef to i64
4417 ; PROLOG-NEXT: %shft = ashr exact i32 %arg, 16
4418 ; PROLOG-NEXT: br i1 %i, label %loopexit2, label %preheader
4419 ; PROLOG: preheader:
4420 ; PROLOG-NEXT: %0 = add nsw i64 %sext, -1
4421 ; PROLOG-NEXT: %1 = add nsw i64 %sext, -2
4422 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
4423 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4424 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4425 ; PROLOG: header.prol.preheader:
4426 ; PROLOG-NEXT: br label %header.prol
4427 ; PROLOG: header.prol:
4428 ; PROLOG-NEXT: %i6.prol = phi i64 [ 1, %header.prol.preheader ], [ %add.prol, %latch.prol ]
4429 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
4430 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit1, label %latch.prol
4431 ; PROLOG: latch.prol:
4432 ; PROLOG-NEXT: %add.prol = add nuw nsw i64 %i6.prol, 1
4433 ; PROLOG-NEXT: %i9.prol = icmp slt i64 %add.prol, %sext
4434 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
4435 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
4436 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !11
4437 ; PROLOG: header.prol.loopexit.unr-lcssa:
4438 ; PROLOG-NEXT: %i6.unr.ph = phi i64 [ %add.prol, %latch.prol ]
4439 ; PROLOG-NEXT: br label %header.prol.loopexit
4440 ; PROLOG: header.prol.loopexit:
4441 ; PROLOG-NEXT: %i6.unr = phi i64 [ 1, %preheader ], [ %i6.unr.ph, %header.prol.loopexit.unr-lcssa ]
4442 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
4443 ; PROLOG-NEXT: br i1 %2, label %latchexit, label %preheader.new
4444 ; PROLOG: preheader.new:
4445 ; PROLOG-NEXT: br label %header
4447 ; PROLOG-NEXT: %i6 = phi i64 [ %i6.unr, %preheader.new ], [ %add.7, %latch.7 ]
4448 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4450 ; PROLOG-NEXT: %add = add nuw nsw i64 %i6, 1
4451 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4453 ; PROLOG-NEXT: %add.1 = add nuw nsw i64 %add, 1
4454 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.2
4456 ; PROLOG-NEXT: %add.2 = add nuw nsw i64 %add.1, 1
4457 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.3
4459 ; PROLOG-NEXT: %add.3 = add nuw nsw i64 %add.2, 1
4460 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.4
4462 ; PROLOG-NEXT: %add.4 = add nuw nsw i64 %add.3, 1
4463 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.5
4465 ; PROLOG-NEXT: %add.5 = add nuw nsw i64 %add.4, 1
4466 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.6
4468 ; PROLOG-NEXT: %add.6 = add nuw nsw i64 %add.5, 1
4469 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.7
4471 ; PROLOG-NEXT: %add.7 = add nuw nsw i64 %add.6, 1
4472 ; PROLOG-NEXT: %i9.7 = icmp slt i64 %add.7, %sext
4473 ; PROLOG-NEXT: br i1 %i9.7, label %header, label %latchexit.unr-lcssa
4474 ; PROLOG: latchexit.unr-lcssa:
4475 ; PROLOG-NEXT: br label %latchexit
4476 ; PROLOG: latchexit:
4477 ; PROLOG-NEXT: unreachable
4478 ; PROLOG: loopexit2:
4479 ; PROLOG-NEXT: ret i32 %shft
4480 ; PROLOG: loopexit1.loopexit:
4481 ; PROLOG-NEXT: %sext3.ph = phi i32 [ %shft, %header ], [ %shft, %latch ], [ %shft, %latch.1 ], [ %shft, %latch.2 ], [ %shft, %latch.3 ], [ %shft, %latch.4 ], [ %shft, %latch.5 ], [ %shft, %latch.6 ]
4482 ; PROLOG-NEXT: br label %loopexit1
4483 ; PROLOG: loopexit1.loopexit1:
4484 ; PROLOG-NEXT: %sext3.ph2 = phi i32 [ %shft, %header.prol ]
4485 ; PROLOG-NEXT: br label %loopexit1
4486 ; PROLOG: loopexit1:
4487 ; PROLOG-NEXT: %sext3 = phi i32 [ %sext3.ph, %loopexit1.loopexit ], [ %sext3.ph2, %loopexit1.loopexit1 ]
4488 ; PROLOG-NEXT: ret i32 %sext3
4490 ; PROLOG-BLOCK-LABEL: @test7(
4491 ; PROLOG-BLOCK-NEXT: bb:
4492 ; PROLOG-BLOCK-NEXT: %i = icmp slt i32 undef, 2
4493 ; PROLOG-BLOCK-NEXT: %sext = sext i32 undef to i64
4494 ; PROLOG-BLOCK-NEXT: %shft = ashr exact i32 %arg, 16
4495 ; PROLOG-BLOCK-NEXT: br i1 %i, label %loopexit2, label %preheader
4496 ; PROLOG-BLOCK: preheader:
4497 ; PROLOG-BLOCK-NEXT: %0 = add nsw i64 %sext, -1
4498 ; PROLOG-BLOCK-NEXT: %1 = add nsw i64 %sext, -2
4499 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4500 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4501 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4502 ; PROLOG-BLOCK: header.prol.preheader:
4503 ; PROLOG-BLOCK-NEXT: br label %header.prol
4504 ; PROLOG-BLOCK: header.prol:
4505 ; PROLOG-BLOCK-NEXT: br i1 false, label %loopexit1, label %latch.prol
4506 ; PROLOG-BLOCK: latch.prol:
4507 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
4508 ; PROLOG-BLOCK: header.prol.loopexit:
4509 ; PROLOG-BLOCK-NEXT: %i6.unr = phi i64 [ 1, %preheader ], [ 2, %latch.prol ]
4510 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4511 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latchexit, label %preheader.new
4512 ; PROLOG-BLOCK: preheader.new:
4513 ; PROLOG-BLOCK-NEXT: br label %header
4514 ; PROLOG-BLOCK: header:
4515 ; PROLOG-BLOCK-NEXT: %i6 = phi i64 [ %i6.unr, %preheader.new ], [ %add.1, %latch.1 ]
4516 ; PROLOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4517 ; PROLOG-BLOCK: latch:
4518 ; PROLOG-BLOCK-NEXT: %add = add nuw nsw i64 %i6, 1
4519 ; PROLOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4520 ; PROLOG-BLOCK: latch.1:
4521 ; PROLOG-BLOCK-NEXT: %add.1 = add nuw nsw i64 %add, 1
4522 ; PROLOG-BLOCK-NEXT: %i9.1 = icmp slt i64 %add.1, %sext
4523 ; PROLOG-BLOCK-NEXT: br i1 %i9.1, label %header, label %latchexit.unr-lcssa, !llvm.loop !11
4524 ; PROLOG-BLOCK: latchexit.unr-lcssa:
4525 ; PROLOG-BLOCK-NEXT: br label %latchexit
4526 ; PROLOG-BLOCK: latchexit:
4527 ; PROLOG-BLOCK-NEXT: unreachable
4528 ; PROLOG-BLOCK: loopexit2:
4529 ; PROLOG-BLOCK-NEXT: ret i32 %shft
4530 ; PROLOG-BLOCK: loopexit1.loopexit:
4531 ; PROLOG-BLOCK-NEXT: %sext3.ph = phi i32 [ %shft, %header ], [ %shft, %latch ]
4532 ; PROLOG-BLOCK-NEXT: br label %loopexit1
4533 ; PROLOG-BLOCK: loopexit1:
4534 ; PROLOG-BLOCK-NEXT: %sext3 = phi i32 [ %shft, %header.prol ], [ %sext3.ph, %loopexit1.loopexit ]
4535 ; PROLOG-BLOCK-NEXT: ret i32 %sext3
4538 %i = icmp slt i32 undef, 2
4539 %sext = sext i32 undef to i64
4540 %shft = ashr exact i32 %arg, 16
4541 br i1 %i, label %loopexit2, label %preheader
4543 preheader: ; preds = %bb2
4546 header: ; preds = %latch, %preheader
4547 %i6 = phi i64 [ 1, %preheader ], [ %add, %latch ]
4548 br i1 false, label %loopexit1, label %latch
4550 latch: ; preds = %header
4551 %add = add nuw nsw i64 %i6, 1
4552 %i9 = icmp slt i64 %add, %sext
4553 br i1 %i9, label %header, label %latchexit
4555 latchexit: ; preds = %latch
4558 loopexit2: ; preds = %bb2
4561 loopexit1: ; preds = %header
4562 %sext3 = phi i32 [ %shft, %header ]
4566 ; Nested loop and inner loop is unrolled. The tricky bit here is that
4567 ; several blocks in the inner loop fall out of the outer block when we
4568 ; use the epilogue block remainder strategy.
4569 define void @test8() {
4570 ; EPILOG-LABEL: @test8(
4572 ; EPILOG-NEXT: br label %outerloop
4573 ; EPILOG: outerloop.loopexit.loopexit:
4574 ; EPILOG-NEXT: br label %outerloop.loopexit
4575 ; EPILOG: outerloop.loopexit.loopexit1:
4576 ; EPILOG-NEXT: br label %outerloop.loopexit
4577 ; EPILOG: outerloop.loopexit:
4578 ; EPILOG-NEXT: br label %outerloop
4579 ; EPILOG: outerloop:
4580 ; EPILOG-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit ]
4581 ; EPILOG-NEXT: %0 = sub i64 100, %i
4582 ; EPILOG-NEXT: %1 = sub i64 99, %i
4583 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
4584 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
4585 ; EPILOG-NEXT: br i1 %2, label %exit.unr-lcssa, label %outerloop.new
4586 ; EPILOG: outerloop.new:
4587 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
4588 ; EPILOG-NEXT: br label %innerH
4590 ; EPILOG-NEXT: %i3 = phi i64 [ %i, %outerloop.new ], [ %i4.7, %latch.7 ]
4591 ; EPILOG-NEXT: %niter = phi i64 [ 0, %outerloop.new ], [ %niter.next.7, %latch.7 ]
4592 ; EPILOG-NEXT: %i4 = add nuw nsw i64 %i3, 1
4593 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4595 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
4596 ; EPILOG-NEXT: %i4.1 = add nuw nsw i64 %i4, 1
4597 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4599 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
4600 ; EPILOG-NEXT: %i4.2 = add nuw nsw i64 %i4.1, 1
4601 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.2
4603 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
4604 ; EPILOG-NEXT: %i4.3 = add nuw nsw i64 %i4.2, 1
4605 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.3
4607 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
4608 ; EPILOG-NEXT: %i4.4 = add nuw nsw i64 %i4.3, 1
4609 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.4
4611 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
4612 ; EPILOG-NEXT: %i4.5 = add nuw nsw i64 %i4.4, 1
4613 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.5
4615 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
4616 ; EPILOG-NEXT: %i4.6 = add nuw nsw i64 %i4.5, 1
4617 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.6
4619 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
4620 ; EPILOG-NEXT: %i4.7 = add nuw nsw i64 %i4.6, 1
4621 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.7
4623 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
4624 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
4625 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %innerH, label %exit.unr-lcssa.loopexit
4626 ; EPILOG: exit.unr-lcssa.loopexit:
4627 ; EPILOG-NEXT: %i3.unr.ph = phi i64 [ %i4.7, %latch.7 ]
4628 ; EPILOG-NEXT: br label %exit.unr-lcssa
4629 ; EPILOG: exit.unr-lcssa:
4630 ; EPILOG-NEXT: %i3.unr = phi i64 [ %i, %outerloop ], [ %i3.unr.ph, %exit.unr-lcssa.loopexit ]
4631 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4632 ; EPILOG-NEXT: br i1 %lcmp.mod, label %innerH.epil.preheader, label %exit.loopexit
4633 ; EPILOG: innerH.epil.preheader:
4634 ; EPILOG-NEXT: br label %innerH.epil
4635 ; EPILOG: innerH.epil:
4636 ; EPILOG-NEXT: %i3.epil = phi i64 [ %i4.epil, %latch.epil ], [ %i3.unr, %innerH.epil.preheader ]
4637 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %innerH.epil.preheader ], [ %epil.iter.next, %latch.epil ]
4638 ; EPILOG-NEXT: %i4.epil = add nuw nsw i64 %i3.epil, 1
4639 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit1, label %latch.epil
4640 ; EPILOG: latch.epil:
4641 ; EPILOG-NEXT: %i6.epil = icmp ult i64 %i4.epil, 100
4642 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
4643 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
4644 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %innerH.epil, label %exit.epilog-lcssa, !llvm.loop !12
4645 ; EPILOG: exit.epilog-lcssa:
4646 ; EPILOG-NEXT: br label %exit
4647 ; EPILOG: exit.loopexit:
4648 ; EPILOG-NEXT: br label %exit
4650 ; EPILOG-NEXT: ret void
4652 ; EPILOG-BLOCK-LABEL: @test8(
4653 ; EPILOG-BLOCK-NEXT: bb:
4654 ; EPILOG-BLOCK-NEXT: br label %outerloop
4655 ; EPILOG-BLOCK: outerloop.loopexit.loopexit:
4656 ; EPILOG-BLOCK-NEXT: br label %outerloop.loopexit
4657 ; EPILOG-BLOCK: outerloop.loopexit:
4658 ; EPILOG-BLOCK-NEXT: br i1 false, label %exit.unr-lcssa.1, label %outerloop.new.1
4659 ; EPILOG-BLOCK: outerloop.new.1:
4660 ; EPILOG-BLOCK-NEXT: br label %innerH.1
4661 ; EPILOG-BLOCK: innerH.1:
4662 ; EPILOG-BLOCK-NEXT: %i3.1 = phi i64 [ 0, %outerloop.new.1 ], [ %i4.1.1, %latch.1.1 ]
4663 ; EPILOG-BLOCK-NEXT: %niter.1 = phi i64 [ 0, %outerloop.new.1 ], [ %niter.next.1.1, %latch.1.1 ]
4664 ; EPILOG-BLOCK-NEXT: %i4.12 = add nuw nsw i64 %i3.1, 1
4665 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.14
4666 ; EPILOG-BLOCK: latch.14:
4667 ; EPILOG-BLOCK-NEXT: %niter.next.13 = add nuw nsw i64 %niter.1, 1
4668 ; EPILOG-BLOCK-NEXT: %i4.1.1 = add nuw nsw i64 %i4.12, 1
4669 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.1.1
4670 ; EPILOG-BLOCK: latch.1.1:
4671 ; EPILOG-BLOCK-NEXT: %niter.next.1.1 = add i64 %niter.next.13, 1
4672 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1.1 = icmp ne i64 %niter.next.1.1, 100
4673 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1.1, label %innerH.1, label %exit.unr-lcssa.loopexit.1, !llvm.loop !12
4674 ; EPILOG-BLOCK: exit.unr-lcssa.loopexit.1:
4675 ; EPILOG-BLOCK-NEXT: br label %exit.unr-lcssa.1
4676 ; EPILOG-BLOCK: outerloop.loopexit.loopexit.1:
4677 ; EPILOG-BLOCK-NEXT: br label %outerloop.loopexit.1
4678 ; EPILOG-BLOCK: exit.unr-lcssa.1:
4679 ; EPILOG-BLOCK-NEXT: br i1 false, label %innerH.epil.preheader.1, label %exit.loopexit
4680 ; EPILOG-BLOCK: innerH.epil.preheader.1:
4681 ; EPILOG-BLOCK-NEXT: br label %innerH.epil.1
4682 ; EPILOG-BLOCK: innerH.epil.1:
4683 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.1, label %latch.epil
4684 ; EPILOG-BLOCK: outerloop.loopexit.1:
4685 ; EPILOG-BLOCK-NEXT: br label %outerloop, !llvm.loop !13
4686 ; EPILOG-BLOCK: outerloop:
4687 ; EPILOG-BLOCK-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit.1 ]
4688 ; EPILOG-BLOCK-NEXT: %0 = sub i64 100, %i
4689 ; EPILOG-BLOCK-NEXT: %1 = sub i64 99, %i
4690 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4691 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4692 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit.unr-lcssa, label %outerloop.new
4693 ; EPILOG-BLOCK: outerloop.new:
4694 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
4695 ; EPILOG-BLOCK-NEXT: br label %innerH
4696 ; EPILOG-BLOCK: innerH:
4697 ; EPILOG-BLOCK-NEXT: %i3 = phi i64 [ %i, %outerloop.new ], [ %i4.1, %latch.1 ]
4698 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %outerloop.new ], [ %niter.next.1, %latch.1 ]
4699 ; EPILOG-BLOCK-NEXT: %i4 = add nuw nsw i64 %i3, 1
4700 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4701 ; EPILOG-BLOCK: latch:
4702 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
4703 ; EPILOG-BLOCK-NEXT: %i4.1 = add nuw nsw i64 %i4, 1
4704 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4705 ; EPILOG-BLOCK: latch.1:
4706 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
4707 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
4708 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %innerH, label %exit.unr-lcssa.loopexit, !llvm.loop !12
4709 ; EPILOG-BLOCK: exit.unr-lcssa.loopexit:
4710 ; EPILOG-BLOCK-NEXT: br label %exit.unr-lcssa
4711 ; EPILOG-BLOCK: exit.unr-lcssa:
4712 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4713 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %innerH.epil.preheader, label %exit.loopexit
4714 ; EPILOG-BLOCK: innerH.epil.preheader:
4715 ; EPILOG-BLOCK-NEXT: br label %innerH.epil
4716 ; EPILOG-BLOCK: innerH.epil:
4717 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit, label %latch.epil
4718 ; EPILOG-BLOCK: latch.epil:
4719 ; EPILOG-BLOCK-NEXT: br label %exit
4720 ; EPILOG-BLOCK: exit.loopexit:
4721 ; EPILOG-BLOCK-NEXT: br label %exit
4722 ; EPILOG-BLOCK: exit:
4723 ; EPILOG-BLOCK-NEXT: ret void
4725 ; PROLOG-LABEL: @test8(
4727 ; PROLOG-NEXT: br label %outerloop
4728 ; PROLOG: outerloop.loopexit.loopexit:
4729 ; PROLOG-NEXT: br label %outerloop.loopexit
4730 ; PROLOG: outerloop.loopexit.loopexit1:
4731 ; PROLOG-NEXT: br label %outerloop.loopexit
4732 ; PROLOG: outerloop.loopexit:
4733 ; PROLOG-NEXT: br label %outerloop
4734 ; PROLOG: outerloop:
4735 ; PROLOG-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit ]
4736 ; PROLOG-NEXT: %0 = sub i64 100, %i
4737 ; PROLOG-NEXT: %1 = sub i64 99, %i
4738 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
4739 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4740 ; PROLOG-NEXT: br i1 %lcmp.mod, label %innerH.prol.preheader, label %innerH.prol.loopexit
4741 ; PROLOG: innerH.prol.preheader:
4742 ; PROLOG-NEXT: br label %innerH.prol
4743 ; PROLOG: innerH.prol:
4744 ; PROLOG-NEXT: %i3.prol = phi i64 [ %i4.prol, %latch.prol ], [ %i, %innerH.prol.preheader ]
4745 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %innerH.prol.preheader ], [ %prol.iter.next, %latch.prol ]
4746 ; PROLOG-NEXT: %i4.prol = add nuw nsw i64 %i3.prol, 1
4747 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit1, label %latch.prol
4748 ; PROLOG: latch.prol:
4749 ; PROLOG-NEXT: %i6.prol = icmp ult i64 %i4.prol, 100
4750 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
4751 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
4752 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %innerH.prol, label %innerH.prol.loopexit.unr-lcssa, !llvm.loop !12
4753 ; PROLOG: innerH.prol.loopexit.unr-lcssa:
4754 ; PROLOG-NEXT: %i3.unr.ph = phi i64 [ %i4.prol, %latch.prol ]
4755 ; PROLOG-NEXT: br label %innerH.prol.loopexit
4756 ; PROLOG: innerH.prol.loopexit:
4757 ; PROLOG-NEXT: %i3.unr = phi i64 [ %i, %outerloop ], [ %i3.unr.ph, %innerH.prol.loopexit.unr-lcssa ]
4758 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
4759 ; PROLOG-NEXT: br i1 %2, label %exit.loopexit, label %outerloop.new
4760 ; PROLOG: outerloop.new:
4761 ; PROLOG-NEXT: br label %innerH
4763 ; PROLOG-NEXT: %i3 = phi i64 [ %i3.unr, %outerloop.new ], [ %i4.7, %latch.7 ]
4764 ; PROLOG-NEXT: %i4 = add nuw nsw i64 %i3, 1
4765 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4767 ; PROLOG-NEXT: %i4.1 = add nuw nsw i64 %i4, 1
4768 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4770 ; PROLOG-NEXT: %i4.2 = add nuw nsw i64 %i4.1, 1
4771 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.2
4773 ; PROLOG-NEXT: %i4.3 = add nuw nsw i64 %i4.2, 1
4774 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.3
4776 ; PROLOG-NEXT: %i4.4 = add nuw nsw i64 %i4.3, 1
4777 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.4
4779 ; PROLOG-NEXT: %i4.5 = add nuw nsw i64 %i4.4, 1
4780 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.5
4782 ; PROLOG-NEXT: %i4.6 = add nuw nsw i64 %i4.5, 1
4783 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.6
4785 ; PROLOG-NEXT: %i4.7 = add nuw nsw i64 %i4.6, 1
4786 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.7
4788 ; PROLOG-NEXT: %i6.7 = icmp ult i64 %i4.7, 100
4789 ; PROLOG-NEXT: br i1 %i6.7, label %innerH, label %exit.unr-lcssa
4790 ; PROLOG: exit.unr-lcssa:
4791 ; PROLOG-NEXT: br label %exit
4792 ; PROLOG: exit.loopexit:
4793 ; PROLOG-NEXT: br label %exit
4795 ; PROLOG-NEXT: ret void
4797 ; PROLOG-BLOCK-LABEL: @test8(
4798 ; PROLOG-BLOCK-NEXT: bb:
4799 ; PROLOG-BLOCK-NEXT: br label %outerloop
4800 ; PROLOG-BLOCK: outerloop.loopexit.loopexit:
4801 ; PROLOG-BLOCK-NEXT: br label %outerloop.loopexit
4802 ; PROLOG-BLOCK: outerloop.loopexit:
4803 ; PROLOG-BLOCK-NEXT: br i1 false, label %innerH.prol.preheader.1, label %innerH.prol.loopexit.1
4804 ; PROLOG-BLOCK: innerH.prol.preheader.1:
4805 ; PROLOG-BLOCK-NEXT: br label %innerH.prol.1
4806 ; PROLOG-BLOCK: innerH.prol.1:
4807 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.1, label %latch.prol.1
4808 ; PROLOG-BLOCK: latch.prol.1:
4809 ; PROLOG-BLOCK-NEXT: br label %innerH.prol.loopexit.1
4810 ; PROLOG-BLOCK: innerH.prol.loopexit.1:
4811 ; PROLOG-BLOCK-NEXT: %i3.unr.1 = phi i64 [ 0, %outerloop.loopexit ], [ 1, %latch.prol.1 ]
4812 ; PROLOG-BLOCK-NEXT: br i1 false, label %exit.loopexit, label %outerloop.new.1
4813 ; PROLOG-BLOCK: outerloop.new.1:
4814 ; PROLOG-BLOCK-NEXT: br label %innerH.1
4815 ; PROLOG-BLOCK: innerH.1:
4816 ; PROLOG-BLOCK-NEXT: %i3.1 = phi i64 [ %i3.unr.1, %outerloop.new.1 ], [ %i4.1.1, %latch.1.1 ]
4817 ; PROLOG-BLOCK-NEXT: %i4.11 = add nuw nsw i64 %i3.1, 1
4818 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.12
4819 ; PROLOG-BLOCK: latch.12:
4820 ; PROLOG-BLOCK-NEXT: %i4.1.1 = add nuw nsw i64 %i4.11, 1
4821 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.1.1
4822 ; PROLOG-BLOCK: latch.1.1:
4823 ; PROLOG-BLOCK-NEXT: %i6.1.1 = icmp ult i64 %i4.1.1, 100
4824 ; PROLOG-BLOCK-NEXT: br i1 %i6.1.1, label %innerH.1, label %exit.unr-lcssa.loopexit3, !llvm.loop !12
4825 ; PROLOG-BLOCK: outerloop.loopexit.loopexit.1:
4826 ; PROLOG-BLOCK-NEXT: br label %outerloop.loopexit.1
4827 ; PROLOG-BLOCK: outerloop.loopexit.1:
4828 ; PROLOG-BLOCK-NEXT: br label %outerloop, !llvm.loop !13
4829 ; PROLOG-BLOCK: outerloop:
4830 ; PROLOG-BLOCK-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit.1 ]
4831 ; PROLOG-BLOCK-NEXT: %0 = sub i64 100, %i
4832 ; PROLOG-BLOCK-NEXT: %1 = sub i64 99, %i
4833 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4834 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4835 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %innerH.prol.preheader, label %innerH.prol.loopexit
4836 ; PROLOG-BLOCK: innerH.prol.preheader:
4837 ; PROLOG-BLOCK-NEXT: br label %innerH.prol
4838 ; PROLOG-BLOCK: innerH.prol:
4839 ; PROLOG-BLOCK-NEXT: %i4.prol = add nuw nsw i64 %i, 1
4840 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit, label %latch.prol
4841 ; PROLOG-BLOCK: latch.prol:
4842 ; PROLOG-BLOCK-NEXT: br label %innerH.prol.loopexit
4843 ; PROLOG-BLOCK: innerH.prol.loopexit:
4844 ; PROLOG-BLOCK-NEXT: %i3.unr = phi i64 [ %i, %outerloop ], [ %i4.prol, %latch.prol ]
4845 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4846 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit.loopexit, label %outerloop.new
4847 ; PROLOG-BLOCK: outerloop.new:
4848 ; PROLOG-BLOCK-NEXT: br label %innerH
4849 ; PROLOG-BLOCK: innerH:
4850 ; PROLOG-BLOCK-NEXT: %i3 = phi i64 [ %i3.unr, %outerloop.new ], [ %i4.1, %latch.1 ]
4851 ; PROLOG-BLOCK-NEXT: %i4 = add nuw nsw i64 %i3, 1
4852 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4853 ; PROLOG-BLOCK: latch:
4854 ; PROLOG-BLOCK-NEXT: %i4.1 = add nuw nsw i64 %i4, 1
4855 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4856 ; PROLOG-BLOCK: latch.1:
4857 ; PROLOG-BLOCK-NEXT: %i6.1 = icmp ult i64 %i4.1, 100
4858 ; PROLOG-BLOCK-NEXT: br i1 %i6.1, label %innerH, label %exit.unr-lcssa.loopexit, !llvm.loop !12
4859 ; PROLOG-BLOCK: exit.unr-lcssa.loopexit:
4860 ; PROLOG-BLOCK-NEXT: br label %exit.unr-lcssa
4861 ; PROLOG-BLOCK: exit.unr-lcssa.loopexit3:
4862 ; PROLOG-BLOCK-NEXT: br label %exit.unr-lcssa
4863 ; PROLOG-BLOCK: exit.unr-lcssa:
4864 ; PROLOG-BLOCK-NEXT: br label %exit
4865 ; PROLOG-BLOCK: exit.loopexit:
4866 ; PROLOG-BLOCK-NEXT: br label %exit
4867 ; PROLOG-BLOCK: exit:
4868 ; PROLOG-BLOCK-NEXT: ret void
4874 outerloop: ; preds = %innerH, %bb
4875 %i = phi i64 [ 3, %bb ], [ 0, %innerH ]
4878 innerH: ; preds = %latch, %outerloop
4879 %i3 = phi i64 [ %i4, %latch ], [ %i, %outerloop ]
4880 %i4 = add nuw nsw i64 %i3, 1
4881 br i1 false, label %outerloop, label %latch
4883 latch: ; preds = %innerH
4884 %i6 = icmp ult i64 %i4, 100
4885 br i1 %i6, label %innerH, label %exit
4887 exit: ; preds = %latch
4891 declare i8 addrspace(1)* @foo(i32)
4892 ; inner loop prolog unrolled
4893 ; a value from outer loop is used in exit block of inner loop.
4894 ; Don't create VMap entries for such values (%trip).
4895 define i8 addrspace(1)* @test9(i8* nocapture readonly %arg, i32 %n) {
4896 ; EPILOG-LABEL: @test9(
4898 ; EPILOG-NEXT: %0 = add i32 %n, -1
4899 ; EPILOG-NEXT: %1 = add i32 %n, -2
4900 ; EPILOG-NEXT: br label %outerloopHdr
4901 ; EPILOG: outerloopHdr:
4902 ; EPILOG-NEXT: %trip = add i32 %n, -1
4903 ; EPILOG-NEXT: %outercnd = icmp slt i32 0, %trip
4904 ; EPILOG-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
4905 ; EPILOG: preheader:
4906 ; EPILOG-NEXT: %i4 = zext i32 0 to i64
4907 ; EPILOG-NEXT: %xtraiter = and i32 %0, 7
4908 ; EPILOG-NEXT: %2 = icmp ult i32 %1, 7
4909 ; EPILOG-NEXT: br i1 %2, label %outerLatch.loopexit.unr-lcssa, label %preheader.new
4910 ; EPILOG: preheader.new:
4911 ; EPILOG-NEXT: %unroll_iter = sub i32 %0, %xtraiter
4912 ; EPILOG-NEXT: br label %header
4914 ; EPILOG-NEXT: %phi = phi i64 [ %i4, %preheader.new ], [ %iv.next.7, %latch.7 ]
4915 ; EPILOG-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.7, %latch.7 ]
4916 ; EPILOG-NEXT: br i1 true, label %latch, label %innerexit.loopexit
4917 ; EPILOG: innerexit.loopexit:
4918 ; EPILOG-NEXT: %trip.lcssa.ph = phi i32 [ %trip, %header ], [ %trip, %latch ], [ %trip, %latch.1 ], [ %trip, %latch.2 ], [ %trip, %latch.3 ], [ %trip, %latch.4 ], [ %trip, %latch.5 ], [ %trip, %latch.6 ]
4919 ; EPILOG-NEXT: br label %innerexit
4920 ; EPILOG: innerexit.loopexit1:
4921 ; EPILOG-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.epil ]
4922 ; EPILOG-NEXT: br label %innerexit
4923 ; EPILOG: innerexit:
4924 ; EPILOG-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
4925 ; EPILOG-NEXT: %i9 = call i8 addrspace(1)* @foo(i32 %trip.lcssa)
4926 ; EPILOG-NEXT: ret i8 addrspace(1)* %i9
4928 ; EPILOG-NEXT: %iv.next = add nuw nsw i64 %phi, 1
4929 ; EPILOG-NEXT: %niter.next = add nuw nsw i32 %niter, 1
4930 ; EPILOG-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit
4932 ; EPILOG-NEXT: %iv.next.1 = add nuw nsw i64 %iv.next, 1
4933 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i32 %niter.next, 1
4934 ; EPILOG-NEXT: br i1 true, label %latch.2, label %innerexit.loopexit
4936 ; EPILOG-NEXT: %iv.next.2 = add nuw nsw i64 %iv.next.1, 1
4937 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i32 %niter.next.1, 1
4938 ; EPILOG-NEXT: br i1 true, label %latch.3, label %innerexit.loopexit
4940 ; EPILOG-NEXT: %iv.next.3 = add nuw nsw i64 %iv.next.2, 1
4941 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i32 %niter.next.2, 1
4942 ; EPILOG-NEXT: br i1 true, label %latch.4, label %innerexit.loopexit
4944 ; EPILOG-NEXT: %iv.next.4 = add nuw nsw i64 %iv.next.3, 1
4945 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i32 %niter.next.3, 1
4946 ; EPILOG-NEXT: br i1 true, label %latch.5, label %innerexit.loopexit
4948 ; EPILOG-NEXT: %iv.next.5 = add nuw nsw i64 %iv.next.4, 1
4949 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i32 %niter.next.4, 1
4950 ; EPILOG-NEXT: br i1 true, label %latch.6, label %innerexit.loopexit
4952 ; EPILOG-NEXT: %iv.next.6 = add nuw nsw i64 %iv.next.5, 1
4953 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i32 %niter.next.5, 1
4954 ; EPILOG-NEXT: br i1 true, label %latch.7, label %innerexit.loopexit
4956 ; EPILOG-NEXT: %iv.next.7 = add nuw nsw i64 %iv.next.6, 1
4957 ; EPILOG-NEXT: %niter.next.7 = add i32 %niter.next.6, 1
4958 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i32 %niter.next.7, %unroll_iter
4959 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %header, label %outerLatch.loopexit.unr-lcssa.loopexit
4960 ; EPILOG: outerLatch.loopexit.unr-lcssa.loopexit:
4961 ; EPILOG-NEXT: %phi.unr.ph = phi i64 [ %iv.next.7, %latch.7 ]
4962 ; EPILOG-NEXT: br label %outerLatch.loopexit.unr-lcssa
4963 ; EPILOG: outerLatch.loopexit.unr-lcssa:
4964 ; EPILOG-NEXT: %phi.unr = phi i64 [ %i4, %preheader ], [ %phi.unr.ph, %outerLatch.loopexit.unr-lcssa.loopexit ]
4965 ; EPILOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
4966 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %outerLatch.loopexit
4967 ; EPILOG: header.epil.preheader:
4968 ; EPILOG-NEXT: br label %header.epil
4969 ; EPILOG: header.epil:
4970 ; EPILOG-NEXT: %phi.epil = phi i64 [ %phi.unr, %header.epil.preheader ], [ %iv.next.epil, %latch.epil ]
4971 ; EPILOG-NEXT: %epil.iter = phi i32 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
4972 ; EPILOG-NEXT: %i7.epil = trunc i64 %phi.epil to i32
4973 ; EPILOG-NEXT: br i1 true, label %latch.epil, label %innerexit.loopexit1
4974 ; EPILOG: latch.epil:
4975 ; EPILOG-NEXT: %i11.epil = add nsw i32 %i7.epil, 1
4976 ; EPILOG-NEXT: %innercnd.epil = icmp slt i32 %i11.epil, %trip
4977 ; EPILOG-NEXT: %iv.next.epil = add nuw nsw i64 %phi.epil, 1
4978 ; EPILOG-NEXT: %epil.iter.next = add i32 %epil.iter, 1
4979 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i32 %epil.iter.next, %xtraiter
4980 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %outerLatch.loopexit.epilog-lcssa, !llvm.loop !13
4981 ; EPILOG: outerLatch.loopexit.epilog-lcssa:
4982 ; EPILOG-NEXT: br label %outerLatch.loopexit
4983 ; EPILOG: outerLatch.loopexit:
4984 ; EPILOG-NEXT: br label %outerLatch
4985 ; EPILOG: outerLatch:
4986 ; EPILOG-NEXT: br label %outerloopHdr
4988 ; EPILOG-BLOCK-LABEL: @test9(
4989 ; EPILOG-BLOCK-NEXT: bb:
4990 ; EPILOG-BLOCK-NEXT: %0 = add i32 %n, -1
4991 ; EPILOG-BLOCK-NEXT: %1 = add i32 %n, -2
4992 ; EPILOG-BLOCK-NEXT: br label %outerloopHdr
4993 ; EPILOG-BLOCK: outerloopHdr:
4994 ; EPILOG-BLOCK-NEXT: %trip = add i32 %n, -1
4995 ; EPILOG-BLOCK-NEXT: %outercnd = icmp slt i32 0, %trip
4996 ; EPILOG-BLOCK-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
4997 ; EPILOG-BLOCK: preheader:
4998 ; EPILOG-BLOCK-NEXT: %xtraiter = and i32 %0, 1
4999 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i32 %1, 1
5000 ; EPILOG-BLOCK-NEXT: br i1 %2, label %outerLatch.loopexit.unr-lcssa, label %preheader.new
5001 ; EPILOG-BLOCK: preheader.new:
5002 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i32 %0, %xtraiter
5003 ; EPILOG-BLOCK-NEXT: br label %header
5004 ; EPILOG-BLOCK: header:
5005 ; EPILOG-BLOCK-NEXT: %phi = phi i64 [ 0, %preheader.new ], [ %iv.next.1, %latch.1 ]
5006 ; EPILOG-BLOCK-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.1, %latch.1 ]
5007 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch, label %innerexit.loopexit.loopexit
5008 ; EPILOG-BLOCK: innerexit.loopexit.loopexit:
5009 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph.ph = phi i32 [ %trip, %latch ], [ %trip, %header ]
5010 ; EPILOG-BLOCK-NEXT: br label %innerexit.loopexit
5011 ; EPILOG-BLOCK: innerexit.loopexit.loopexit6:
5012 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph.ph7 = phi i32 [ %trip.1, %latch.15 ], [ %trip.1, %header.1 ]
5013 ; EPILOG-BLOCK-NEXT: br label %innerexit.loopexit
5014 ; EPILOG-BLOCK: innerexit.loopexit:
5015 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph = phi i32 [ %trip.lcssa.ph.ph, %innerexit.loopexit.loopexit ], [ %trip.lcssa.ph.ph7, %innerexit.loopexit.loopexit6 ]
5016 ; EPILOG-BLOCK-NEXT: br label %innerexit
5017 ; EPILOG-BLOCK: innerexit.loopexit1:
5018 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.epil ], [ %trip.1, %header.epil.1 ]
5019 ; EPILOG-BLOCK-NEXT: br label %innerexit
5020 ; EPILOG-BLOCK: innerexit:
5021 ; EPILOG-BLOCK-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
5022 ; EPILOG-BLOCK-NEXT: %i9 = call i8 addrspace(1)* @foo(i32 %trip.lcssa)
5023 ; EPILOG-BLOCK-NEXT: ret i8 addrspace(1)* %i9
5024 ; EPILOG-BLOCK: latch:
5025 ; EPILOG-BLOCK-NEXT: %iv.next = add nuw nsw i64 %phi, 1
5026 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i32 %niter, 1
5027 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit.loopexit
5028 ; EPILOG-BLOCK: latch.1:
5029 ; EPILOG-BLOCK-NEXT: %iv.next.1 = add nuw nsw i64 %iv.next, 1
5030 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i32 %niter.next, 1
5031 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i32 %niter.next.1, %unroll_iter
5032 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %header, label %outerLatch.loopexit.unr-lcssa.loopexit, !llvm.loop !14
5033 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa.loopexit:
5034 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit.unr-lcssa
5035 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa:
5036 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
5037 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %outerLatch.loopexit
5038 ; EPILOG-BLOCK: header.epil.preheader:
5039 ; EPILOG-BLOCK-NEXT: br label %header.epil
5040 ; EPILOG-BLOCK: header.epil:
5041 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.epil, label %innerexit.loopexit1
5042 ; EPILOG-BLOCK: latch.epil:
5043 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit
5044 ; EPILOG-BLOCK: outerLatch.loopexit:
5045 ; EPILOG-BLOCK-NEXT: br label %outerLatch
5046 ; EPILOG-BLOCK: outerLatch:
5047 ; EPILOG-BLOCK-NEXT: %trip.1 = add i32 %n, -1
5048 ; EPILOG-BLOCK-NEXT: %outercnd.1 = icmp slt i32 0, %trip.1
5049 ; EPILOG-BLOCK-NEXT: br i1 %outercnd.1, label %preheader.1, label %outerLatch.1
5050 ; EPILOG-BLOCK: preheader.1:
5051 ; EPILOG-BLOCK-NEXT: %xtraiter.1 = and i32 %0, 1
5052 ; EPILOG-BLOCK-NEXT: %3 = icmp ult i32 %1, 1
5053 ; EPILOG-BLOCK-NEXT: br i1 %3, label %outerLatch.loopexit.unr-lcssa.1, label %preheader.new.1
5054 ; EPILOG-BLOCK: preheader.new.1:
5055 ; EPILOG-BLOCK-NEXT: %unroll_iter.1 = sub i32 %0, %xtraiter.1
5056 ; EPILOG-BLOCK-NEXT: br label %header.1
5057 ; EPILOG-BLOCK: header.1:
5058 ; EPILOG-BLOCK-NEXT: %phi.1 = phi i64 [ 0, %preheader.new.1 ], [ %iv.next.1.1, %latch.1.1 ]
5059 ; EPILOG-BLOCK-NEXT: %niter.1 = phi i32 [ 0, %preheader.new.1 ], [ %niter.next.1.1, %latch.1.1 ]
5060 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.15, label %innerexit.loopexit.loopexit6
5061 ; EPILOG-BLOCK: latch.15:
5062 ; EPILOG-BLOCK-NEXT: %iv.next.13 = add nuw nsw i64 %phi.1, 1
5063 ; EPILOG-BLOCK-NEXT: %niter.next.14 = add nuw nsw i32 %niter.1, 1
5064 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.1.1, label %innerexit.loopexit.loopexit6
5065 ; EPILOG-BLOCK: latch.1.1:
5066 ; EPILOG-BLOCK-NEXT: %iv.next.1.1 = add nuw nsw i64 %iv.next.13, 1
5067 ; EPILOG-BLOCK-NEXT: %niter.next.1.1 = add i32 %niter.next.14, 1
5068 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1.1 = icmp ne i32 %niter.next.1.1, %unroll_iter.1
5069 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1.1, label %header.1, label %outerLatch.loopexit.unr-lcssa.loopexit.1, !llvm.loop !14
5070 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa.loopexit.1:
5071 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit.unr-lcssa.1
5072 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa.1:
5073 ; EPILOG-BLOCK-NEXT: %lcmp.mod.1 = icmp ne i32 %xtraiter.1, 0
5074 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod.1, label %header.epil.preheader.1, label %outerLatch.loopexit.1
5075 ; EPILOG-BLOCK: header.epil.preheader.1:
5076 ; EPILOG-BLOCK-NEXT: br label %header.epil.1
5077 ; EPILOG-BLOCK: header.epil.1:
5078 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.epil.1, label %innerexit.loopexit1
5079 ; EPILOG-BLOCK: latch.epil.1:
5080 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit.1
5081 ; EPILOG-BLOCK: outerLatch.loopexit.1:
5082 ; EPILOG-BLOCK-NEXT: br label %outerLatch.1
5083 ; EPILOG-BLOCK: outerLatch.1:
5084 ; EPILOG-BLOCK-NEXT: br label %outerloopHdr, !llvm.loop !15
5086 ; PROLOG-LABEL: @test9(
5088 ; PROLOG-NEXT: %0 = add i32 %n, -1
5089 ; PROLOG-NEXT: %1 = add i32 %n, -2
5090 ; PROLOG-NEXT: br label %outerloopHdr
5091 ; PROLOG: outerloopHdr:
5092 ; PROLOG-NEXT: %trip = add i32 %n, -1
5093 ; PROLOG-NEXT: %outercnd = icmp slt i32 0, %trip
5094 ; PROLOG-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
5095 ; PROLOG: preheader:
5096 ; PROLOG-NEXT: %i4 = zext i32 0 to i64
5097 ; PROLOG-NEXT: %xtraiter = and i32 %0, 7
5098 ; PROLOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
5099 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
5100 ; PROLOG: header.prol.preheader:
5101 ; PROLOG-NEXT: br label %header.prol
5102 ; PROLOG: header.prol:
5103 ; PROLOG-NEXT: %phi.prol = phi i64 [ %i4, %header.prol.preheader ], [ %iv.next.prol, %latch.prol ]
5104 ; PROLOG-NEXT: %prol.iter = phi i32 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
5105 ; PROLOG-NEXT: %i7.prol = trunc i64 %phi.prol to i32
5106 ; PROLOG-NEXT: br i1 true, label %latch.prol, label %innerexit.loopexit1
5107 ; PROLOG: latch.prol:
5108 ; PROLOG-NEXT: %i11.prol = add nsw i32 %i7.prol, 1
5109 ; PROLOG-NEXT: %innercnd.prol = icmp slt i32 %i11.prol, %trip
5110 ; PROLOG-NEXT: %iv.next.prol = add nuw nsw i64 %phi.prol, 1
5111 ; PROLOG-NEXT: %prol.iter.next = add i32 %prol.iter, 1
5112 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i32 %prol.iter.next, %xtraiter
5113 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !13
5114 ; PROLOG: header.prol.loopexit.unr-lcssa:
5115 ; PROLOG-NEXT: %phi.unr.ph = phi i64 [ %iv.next.prol, %latch.prol ]
5116 ; PROLOG-NEXT: br label %header.prol.loopexit
5117 ; PROLOG: header.prol.loopexit:
5118 ; PROLOG-NEXT: %phi.unr = phi i64 [ %i4, %preheader ], [ %phi.unr.ph, %header.prol.loopexit.unr-lcssa ]
5119 ; PROLOG-NEXT: %2 = icmp ult i32 %1, 7
5120 ; PROLOG-NEXT: br i1 %2, label %outerLatch.loopexit, label %preheader.new
5121 ; PROLOG: preheader.new:
5122 ; PROLOG-NEXT: br label %header
5124 ; PROLOG-NEXT: %phi = phi i64 [ %phi.unr, %preheader.new ], [ %iv.next.7, %latch.7 ]
5125 ; PROLOG-NEXT: br i1 true, label %latch, label %innerexit.loopexit
5126 ; PROLOG: innerexit.loopexit:
5127 ; PROLOG-NEXT: %trip.lcssa.ph = phi i32 [ %trip, %header ], [ %trip, %latch ], [ %trip, %latch.1 ], [ %trip, %latch.2 ], [ %trip, %latch.3 ], [ %trip, %latch.4 ], [ %trip, %latch.5 ], [ %trip, %latch.6 ]
5128 ; PROLOG-NEXT: br label %innerexit
5129 ; PROLOG: innerexit.loopexit1:
5130 ; PROLOG-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.prol ]
5131 ; PROLOG-NEXT: br label %innerexit
5132 ; PROLOG: innerexit:
5133 ; PROLOG-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
5134 ; PROLOG-NEXT: %i9 = call i8 addrspace(1)* @foo(i32 %trip.lcssa)
5135 ; PROLOG-NEXT: ret i8 addrspace(1)* %i9
5137 ; PROLOG-NEXT: %iv.next = add nuw nsw i64 %phi, 1
5138 ; PROLOG-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit
5140 ; PROLOG-NEXT: %iv.next.1 = add nuw nsw i64 %iv.next, 1
5141 ; PROLOG-NEXT: br i1 true, label %latch.2, label %innerexit.loopexit
5143 ; PROLOG-NEXT: %iv.next.2 = add nuw nsw i64 %iv.next.1, 1
5144 ; PROLOG-NEXT: br i1 true, label %latch.3, label %innerexit.loopexit
5146 ; PROLOG-NEXT: %iv.next.3 = add nuw nsw i64 %iv.next.2, 1
5147 ; PROLOG-NEXT: br i1 true, label %latch.4, label %innerexit.loopexit
5149 ; PROLOG-NEXT: %iv.next.4 = add nuw nsw i64 %iv.next.3, 1
5150 ; PROLOG-NEXT: br i1 true, label %latch.5, label %innerexit.loopexit
5152 ; PROLOG-NEXT: %iv.next.5 = add nuw nsw i64 %iv.next.4, 1
5153 ; PROLOG-NEXT: br i1 true, label %latch.6, label %innerexit.loopexit
5155 ; PROLOG-NEXT: %iv.next.6 = add nuw nsw i64 %iv.next.5, 1
5156 ; PROLOG-NEXT: %i7.7 = trunc i64 %iv.next.6 to i32
5157 ; PROLOG-NEXT: br i1 true, label %latch.7, label %innerexit.loopexit
5159 ; PROLOG-NEXT: %i11.7 = add nsw i32 %i7.7, 1
5160 ; PROLOG-NEXT: %innercnd.7 = icmp slt i32 %i11.7, %trip
5161 ; PROLOG-NEXT: %iv.next.7 = add nuw nsw i64 %iv.next.6, 1
5162 ; PROLOG-NEXT: br i1 %innercnd.7, label %header, label %outerLatch.loopexit.unr-lcssa
5163 ; PROLOG: outerLatch.loopexit.unr-lcssa:
5164 ; PROLOG-NEXT: br label %outerLatch.loopexit
5165 ; PROLOG: outerLatch.loopexit:
5166 ; PROLOG-NEXT: br label %outerLatch
5167 ; PROLOG: outerLatch:
5168 ; PROLOG-NEXT: br label %outerloopHdr
5170 ; PROLOG-BLOCK-LABEL: @test9(
5171 ; PROLOG-BLOCK-NEXT: bb:
5172 ; PROLOG-BLOCK-NEXT: %0 = add i32 %n, -1
5173 ; PROLOG-BLOCK-NEXT: %1 = add i32 %n, -2
5174 ; PROLOG-BLOCK-NEXT: br label %outerloopHdr
5175 ; PROLOG-BLOCK: outerloopHdr:
5176 ; PROLOG-BLOCK-NEXT: %trip = add i32 %n, -1
5177 ; PROLOG-BLOCK-NEXT: %outercnd = icmp slt i32 0, %trip
5178 ; PROLOG-BLOCK-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
5179 ; PROLOG-BLOCK: preheader:
5180 ; PROLOG-BLOCK-NEXT: %xtraiter = and i32 %0, 1
5181 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
5182 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
5183 ; PROLOG-BLOCK: header.prol.preheader:
5184 ; PROLOG-BLOCK-NEXT: br label %header.prol
5185 ; PROLOG-BLOCK: header.prol:
5186 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.prol, label %innerexit.loopexit1
5187 ; PROLOG-BLOCK: latch.prol:
5188 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
5189 ; PROLOG-BLOCK: header.prol.loopexit:
5190 ; PROLOG-BLOCK-NEXT: %phi.unr = phi i64 [ 0, %preheader ], [ 1, %latch.prol ]
5191 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i32 %1, 1
5192 ; PROLOG-BLOCK-NEXT: br i1 %2, label %outerLatch.loopexit, label %preheader.new
5193 ; PROLOG-BLOCK: preheader.new:
5194 ; PROLOG-BLOCK-NEXT: br label %header
5195 ; PROLOG-BLOCK: header:
5196 ; PROLOG-BLOCK-NEXT: %phi = phi i64 [ %phi.unr, %preheader.new ], [ %iv.next.1, %latch.1 ]
5197 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch, label %innerexit.loopexit.loopexit
5198 ; PROLOG-BLOCK: innerexit.loopexit.loopexit:
5199 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph.ph = phi i32 [ %trip, %latch ], [ %trip, %header ]
5200 ; PROLOG-BLOCK-NEXT: br label %innerexit.loopexit
5201 ; PROLOG-BLOCK: innerexit.loopexit.loopexit5:
5202 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph.ph6 = phi i32 [ %trip.1, %latch.14 ], [ %trip.1, %header.1 ]
5203 ; PROLOG-BLOCK-NEXT: br label %innerexit.loopexit
5204 ; PROLOG-BLOCK: innerexit.loopexit:
5205 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph = phi i32 [ %trip.lcssa.ph.ph, %innerexit.loopexit.loopexit ], [ %trip.lcssa.ph.ph6, %innerexit.loopexit.loopexit5 ]
5206 ; PROLOG-BLOCK-NEXT: br label %innerexit
5207 ; PROLOG-BLOCK: innerexit.loopexit1:
5208 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.prol ], [ %trip.1, %header.prol.1 ]
5209 ; PROLOG-BLOCK-NEXT: br label %innerexit
5210 ; PROLOG-BLOCK: innerexit:
5211 ; PROLOG-BLOCK-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
5212 ; PROLOG-BLOCK-NEXT: %i9 = call i8 addrspace(1)* @foo(i32 %trip.lcssa)
5213 ; PROLOG-BLOCK-NEXT: ret i8 addrspace(1)* %i9
5214 ; PROLOG-BLOCK: latch:
5215 ; PROLOG-BLOCK-NEXT: %iv.next = add nuw nsw i64 %phi, 1
5216 ; PROLOG-BLOCK-NEXT: %i7.1 = trunc i64 %iv.next to i32
5217 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit.loopexit
5218 ; PROLOG-BLOCK: latch.1:
5219 ; PROLOG-BLOCK-NEXT: %i11.1 = add nsw i32 %i7.1, 1
5220 ; PROLOG-BLOCK-NEXT: %innercnd.1 = icmp slt i32 %i11.1, %trip
5221 ; PROLOG-BLOCK-NEXT: %iv.next.1 = add nuw nsw i64 %iv.next, 1
5222 ; PROLOG-BLOCK-NEXT: br i1 %innercnd.1, label %header, label %outerLatch.loopexit.unr-lcssa, !llvm.loop !14
5223 ; PROLOG-BLOCK: outerLatch.loopexit.unr-lcssa:
5224 ; PROLOG-BLOCK-NEXT: br label %outerLatch.loopexit
5225 ; PROLOG-BLOCK: outerLatch.loopexit:
5226 ; PROLOG-BLOCK-NEXT: br label %outerLatch
5227 ; PROLOG-BLOCK: outerLatch:
5228 ; PROLOG-BLOCK-NEXT: %trip.1 = add i32 %n, -1
5229 ; PROLOG-BLOCK-NEXT: %outercnd.1 = icmp slt i32 0, %trip.1
5230 ; PROLOG-BLOCK-NEXT: br i1 %outercnd.1, label %preheader.1, label %outerLatch.1
5231 ; PROLOG-BLOCK: preheader.1:
5232 ; PROLOG-BLOCK-NEXT: %xtraiter.1 = and i32 %0, 1
5233 ; PROLOG-BLOCK-NEXT: %lcmp.mod.1 = icmp ne i32 %xtraiter.1, 0
5234 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod.1, label %header.prol.preheader.1, label %header.prol.loopexit.1
5235 ; PROLOG-BLOCK: header.prol.preheader.1:
5236 ; PROLOG-BLOCK-NEXT: br label %header.prol.1
5237 ; PROLOG-BLOCK: header.prol.1:
5238 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.prol.1, label %innerexit.loopexit1
5239 ; PROLOG-BLOCK: latch.prol.1:
5240 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit.1
5241 ; PROLOG-BLOCK: header.prol.loopexit.1:
5242 ; PROLOG-BLOCK-NEXT: %phi.unr.1 = phi i64 [ 0, %preheader.1 ], [ 1, %latch.prol.1 ]
5243 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i32 %1, 1
5244 ; PROLOG-BLOCK-NEXT: br i1 %3, label %outerLatch.loopexit.1, label %preheader.new.1
5245 ; PROLOG-BLOCK: preheader.new.1:
5246 ; PROLOG-BLOCK-NEXT: br label %header.1
5247 ; PROLOG-BLOCK: header.1:
5248 ; PROLOG-BLOCK-NEXT: %phi.1 = phi i64 [ %phi.unr.1, %preheader.new.1 ], [ %iv.next.1.1, %latch.1.1 ]
5249 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.14, label %innerexit.loopexit.loopexit5
5250 ; PROLOG-BLOCK: latch.14:
5251 ; PROLOG-BLOCK-NEXT: %iv.next.13 = add nuw nsw i64 %phi.1, 1
5252 ; PROLOG-BLOCK-NEXT: %i7.1.1 = trunc i64 %iv.next.13 to i32
5253 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.1.1, label %innerexit.loopexit.loopexit5
5254 ; PROLOG-BLOCK: latch.1.1:
5255 ; PROLOG-BLOCK-NEXT: %i11.1.1 = add nsw i32 %i7.1.1, 1
5256 ; PROLOG-BLOCK-NEXT: %innercnd.1.1 = icmp slt i32 %i11.1.1, %trip.1
5257 ; PROLOG-BLOCK-NEXT: %iv.next.1.1 = add nuw nsw i64 %iv.next.13, 1
5258 ; PROLOG-BLOCK-NEXT: br i1 %innercnd.1.1, label %header.1, label %outerLatch.loopexit.unr-lcssa.1, !llvm.loop !14
5259 ; PROLOG-BLOCK: outerLatch.loopexit.unr-lcssa.1:
5260 ; PROLOG-BLOCK-NEXT: br label %outerLatch.loopexit.1
5261 ; PROLOG-BLOCK: outerLatch.loopexit.1:
5262 ; PROLOG-BLOCK-NEXT: br label %outerLatch.1
5263 ; PROLOG-BLOCK: outerLatch.1:
5264 ; PROLOG-BLOCK-NEXT: br label %outerloopHdr, !llvm.loop !15
5267 br label %outerloopHdr
5269 outerloopHdr: ; preds = %outerLatch, %bb
5270 %trip = add i32 %n, -1
5271 %outercnd = icmp slt i32 0, %trip
5272 br i1 %outercnd, label %preheader, label %outerLatch
5274 preheader: ; preds = %outerloopHdr
5275 %i4 = zext i32 0 to i64
5278 header: ; preds = %latch, %preheader
5279 %phi = phi i64 [ %i4, %preheader ], [ %iv.next, %latch ]
5280 %i7 = trunc i64 %phi to i32
5281 br i1 true, label %latch, label %innerexit
5283 innerexit: ; preds = %header
5284 %i9 = call i8 addrspace(1)* @foo(i32 %trip)
5285 ret i8 addrspace(1)* %i9
5287 latch: ; preds = %header
5288 %i11 = add nsw i32 %i7, 1
5289 %innercnd = icmp slt i32 %i11, %trip
5290 %iv.next = add nuw nsw i64 %phi, 1
5291 br i1 %innercnd, label %header, label %outerLatch
5293 outerLatch: ; preds = %latch, %outerloopHdr
5294 br label %outerloopHdr
5299 ; This is a case where we should be able to eliminate N-1 copies
5300 ; of the early exit test in the main loop when runtime unrolling
5302 define void @test10(i64 %trip, i64 %trip2) {
5303 ; EPILOG-LABEL: @test10(
5304 ; EPILOG-NEXT: entry:
5305 ; EPILOG-NEXT: %0 = add i64 %trip, -1
5306 ; EPILOG-NEXT: %xtraiter = and i64 %trip, 7
5307 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
5308 ; EPILOG-NEXT: br i1 %1, label %exit2.unr-lcssa, label %entry.new
5309 ; EPILOG: entry.new:
5310 ; EPILOG-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
5311 ; EPILOG-NEXT: br label %loop_header
5312 ; EPILOG: loop_header:
5313 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5314 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
5315 ; EPILOG-NEXT: call void @bar()
5316 ; EPILOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5317 ; EPILOG-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5318 ; EPILOG: loop_latch:
5319 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5320 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5321 ; EPILOG-NEXT: call void @bar()
5322 ; EPILOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5323 ; EPILOG-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5324 ; EPILOG: loop_latch.1:
5325 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
5326 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
5327 ; EPILOG-NEXT: call void @bar()
5328 ; EPILOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5329 ; EPILOG-NEXT: br i1 %cmp_early.2, label %loop_latch.2, label %exit1.loopexit
5330 ; EPILOG: loop_latch.2:
5331 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
5332 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
5333 ; EPILOG-NEXT: call void @bar()
5334 ; EPILOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5335 ; EPILOG-NEXT: br i1 %cmp_early.3, label %loop_latch.3, label %exit1.loopexit
5336 ; EPILOG: loop_latch.3:
5337 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
5338 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
5339 ; EPILOG-NEXT: call void @bar()
5340 ; EPILOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5341 ; EPILOG-NEXT: br i1 %cmp_early.4, label %loop_latch.4, label %exit1.loopexit
5342 ; EPILOG: loop_latch.4:
5343 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
5344 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
5345 ; EPILOG-NEXT: call void @bar()
5346 ; EPILOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5347 ; EPILOG-NEXT: br i1 %cmp_early.5, label %loop_latch.5, label %exit1.loopexit
5348 ; EPILOG: loop_latch.5:
5349 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
5350 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
5351 ; EPILOG-NEXT: call void @bar()
5352 ; EPILOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5353 ; EPILOG-NEXT: br i1 %cmp_early.6, label %loop_latch.6, label %exit1.loopexit
5354 ; EPILOG: loop_latch.6:
5355 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
5356 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
5357 ; EPILOG-NEXT: call void @bar()
5358 ; EPILOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5359 ; EPILOG-NEXT: br i1 %cmp_early.7, label %loop_latch.7, label %exit1.loopexit
5360 ; EPILOG: loop_latch.7:
5361 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5362 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
5363 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
5364 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.unr-lcssa.loopexit
5365 ; EPILOG: exit1.loopexit:
5366 ; EPILOG-NEXT: br label %exit1
5367 ; EPILOG: exit1.loopexit1:
5368 ; EPILOG-NEXT: br label %exit1
5370 ; EPILOG-NEXT: ret void
5371 ; EPILOG: exit2.unr-lcssa.loopexit:
5372 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
5373 ; EPILOG-NEXT: br label %exit2.unr-lcssa
5374 ; EPILOG: exit2.unr-lcssa:
5375 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.unr-lcssa.loopexit ]
5376 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5377 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5378 ; EPILOG: loop_header.epil.preheader:
5379 ; EPILOG-NEXT: br label %loop_header.epil
5380 ; EPILOG: loop_header.epil:
5381 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
5382 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
5383 ; EPILOG-NEXT: call void @bar()
5384 ; EPILOG-NEXT: %cmp_early.epil = icmp ne i64 %iv.epil, %trip2
5385 ; EPILOG-NEXT: br i1 %cmp_early.epil, label %loop_latch.epil, label %exit1.loopexit1
5386 ; EPILOG: loop_latch.epil:
5387 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
5388 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
5389 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
5390 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
5391 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.epilog-lcssa, !llvm.loop !14
5392 ; EPILOG: exit2.epilog-lcssa:
5393 ; EPILOG-NEXT: br label %exit2
5395 ; EPILOG-NEXT: ret void
5397 ; EPILOG-BLOCK-LABEL: @test10(
5398 ; EPILOG-BLOCK-NEXT: entry:
5399 ; EPILOG-BLOCK-NEXT: %0 = add i64 %trip, -1
5400 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
5401 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
5402 ; EPILOG-BLOCK-NEXT: br i1 %1, label %exit2.unr-lcssa, label %entry.new
5403 ; EPILOG-BLOCK: entry.new:
5404 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
5405 ; EPILOG-BLOCK-NEXT: br label %loop_header
5406 ; EPILOG-BLOCK: loop_header:
5407 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5408 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
5409 ; EPILOG-BLOCK-NEXT: call void @bar()
5410 ; EPILOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5411 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5412 ; EPILOG-BLOCK: loop_latch:
5413 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5414 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5415 ; EPILOG-BLOCK-NEXT: call void @bar()
5416 ; EPILOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5417 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5418 ; EPILOG-BLOCK: loop_latch.1:
5419 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
5420 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
5421 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
5422 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.unr-lcssa.loopexit, !llvm.loop !16
5423 ; EPILOG-BLOCK: exit1.loopexit:
5424 ; EPILOG-BLOCK-NEXT: br label %exit1
5425 ; EPILOG-BLOCK: exit1:
5426 ; EPILOG-BLOCK-NEXT: ret void
5427 ; EPILOG-BLOCK: exit2.unr-lcssa.loopexit:
5428 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
5429 ; EPILOG-BLOCK-NEXT: br label %exit2.unr-lcssa
5430 ; EPILOG-BLOCK: exit2.unr-lcssa:
5431 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.unr-lcssa.loopexit ]
5432 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5433 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5434 ; EPILOG-BLOCK: loop_header.epil.preheader:
5435 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
5436 ; EPILOG-BLOCK: loop_header.epil:
5437 ; EPILOG-BLOCK-NEXT: call void @bar()
5438 ; EPILOG-BLOCK-NEXT: %cmp_early.epil = icmp ne i64 %iv.unr, %trip2
5439 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.epil, label %loop_latch.epil, label %exit1
5440 ; EPILOG-BLOCK: loop_latch.epil:
5441 ; EPILOG-BLOCK-NEXT: br label %exit2
5442 ; EPILOG-BLOCK: exit2:
5443 ; EPILOG-BLOCK-NEXT: ret void
5445 ; PROLOG-LABEL: @test10(
5446 ; PROLOG-NEXT: entry:
5447 ; PROLOG-NEXT: %0 = add i64 %trip, -1
5448 ; PROLOG-NEXT: %xtraiter = and i64 %trip, 7
5449 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5450 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5451 ; PROLOG: loop_header.prol.preheader:
5452 ; PROLOG-NEXT: br label %loop_header.prol
5453 ; PROLOG: loop_header.prol:
5454 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
5455 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
5456 ; PROLOG-NEXT: call void @bar()
5457 ; PROLOG-NEXT: %cmp_early.prol = icmp ne i64 %iv.prol, %trip2
5458 ; PROLOG-NEXT: br i1 %cmp_early.prol, label %loop_latch.prol, label %exit1.loopexit1
5459 ; PROLOG: loop_latch.prol:
5460 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
5461 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
5462 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
5463 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
5464 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !14
5465 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
5466 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
5467 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
5468 ; PROLOG: loop_header.prol.loopexit:
5469 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
5470 ; PROLOG-NEXT: %1 = icmp ult i64 %0, 7
5471 ; PROLOG-NEXT: br i1 %1, label %exit2, label %entry.new
5472 ; PROLOG: entry.new:
5473 ; PROLOG-NEXT: br label %loop_header
5474 ; PROLOG: loop_header:
5475 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5476 ; PROLOG-NEXT: call void @bar()
5477 ; PROLOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5478 ; PROLOG-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5479 ; PROLOG: loop_latch:
5480 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
5481 ; PROLOG-NEXT: call void @bar()
5482 ; PROLOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5483 ; PROLOG-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5484 ; PROLOG: loop_latch.1:
5485 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
5486 ; PROLOG-NEXT: call void @bar()
5487 ; PROLOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5488 ; PROLOG-NEXT: br i1 %cmp_early.2, label %loop_latch.2, label %exit1.loopexit
5489 ; PROLOG: loop_latch.2:
5490 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
5491 ; PROLOG-NEXT: call void @bar()
5492 ; PROLOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5493 ; PROLOG-NEXT: br i1 %cmp_early.3, label %loop_latch.3, label %exit1.loopexit
5494 ; PROLOG: loop_latch.3:
5495 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
5496 ; PROLOG-NEXT: call void @bar()
5497 ; PROLOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5498 ; PROLOG-NEXT: br i1 %cmp_early.4, label %loop_latch.4, label %exit1.loopexit
5499 ; PROLOG: loop_latch.4:
5500 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
5501 ; PROLOG-NEXT: call void @bar()
5502 ; PROLOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5503 ; PROLOG-NEXT: br i1 %cmp_early.5, label %loop_latch.5, label %exit1.loopexit
5504 ; PROLOG: loop_latch.5:
5505 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
5506 ; PROLOG-NEXT: call void @bar()
5507 ; PROLOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5508 ; PROLOG-NEXT: br i1 %cmp_early.6, label %loop_latch.6, label %exit1.loopexit
5509 ; PROLOG: loop_latch.6:
5510 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
5511 ; PROLOG-NEXT: call void @bar()
5512 ; PROLOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5513 ; PROLOG-NEXT: br i1 %cmp_early.7, label %loop_latch.7, label %exit1.loopexit
5514 ; PROLOG: loop_latch.7:
5515 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5516 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
5517 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.unr-lcssa
5518 ; PROLOG: exit1.loopexit:
5519 ; PROLOG-NEXT: br label %exit1
5520 ; PROLOG: exit1.loopexit1:
5521 ; PROLOG-NEXT: br label %exit1
5523 ; PROLOG-NEXT: ret void
5524 ; PROLOG: exit2.unr-lcssa:
5525 ; PROLOG-NEXT: br label %exit2
5527 ; PROLOG-NEXT: ret void
5529 ; PROLOG-BLOCK-LABEL: @test10(
5530 ; PROLOG-BLOCK-NEXT: entry:
5531 ; PROLOG-BLOCK-NEXT: %0 = add i64 %trip, -1
5532 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
5533 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5534 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5535 ; PROLOG-BLOCK: loop_header.prol.preheader:
5536 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
5537 ; PROLOG-BLOCK: loop_header.prol:
5538 ; PROLOG-BLOCK-NEXT: call void @bar()
5539 ; PROLOG-BLOCK-NEXT: %cmp_early.prol = icmp ne i64 0, %trip2
5540 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.prol, label %loop_latch.prol, label %exit1
5541 ; PROLOG-BLOCK: loop_latch.prol:
5542 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
5543 ; PROLOG-BLOCK: loop_header.prol.loopexit:
5544 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
5545 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
5546 ; PROLOG-BLOCK-NEXT: br i1 %1, label %exit2, label %entry.new
5547 ; PROLOG-BLOCK: entry.new:
5548 ; PROLOG-BLOCK-NEXT: br label %loop_header
5549 ; PROLOG-BLOCK: loop_header:
5550 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5551 ; PROLOG-BLOCK-NEXT: call void @bar()
5552 ; PROLOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5553 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5554 ; PROLOG-BLOCK: loop_latch:
5555 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
5556 ; PROLOG-BLOCK-NEXT: call void @bar()
5557 ; PROLOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5558 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5559 ; PROLOG-BLOCK: loop_latch.1:
5560 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
5561 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
5562 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.unr-lcssa, !llvm.loop !16
5563 ; PROLOG-BLOCK: exit1.loopexit:
5564 ; PROLOG-BLOCK-NEXT: br label %exit1
5565 ; PROLOG-BLOCK: exit1:
5566 ; PROLOG-BLOCK-NEXT: ret void
5567 ; PROLOG-BLOCK: exit2.unr-lcssa:
5568 ; PROLOG-BLOCK-NEXT: br label %exit2
5569 ; PROLOG-BLOCK: exit2:
5570 ; PROLOG-BLOCK-NEXT: ret void
5573 br label %loop_header
5576 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
5578 %cmp_early = icmp ne i64 %iv, %trip2
5579 br i1 %cmp_early, label %loop_latch, label %exit1
5582 %iv_next = add i64 %iv, 1
5583 %cmp = icmp ne i64 %iv_next, %trip
5584 br i1 %cmp, label %loop_header, label %exit2
5593 ; With a loop invariant, we can eliminate the last N-1
5594 ; copies of the exit test in the unrolled main loop body.
5595 define void @test11(i64 %trip, i1 %cond) {
5596 ; EPILOG-LABEL: @test11(
5597 ; EPILOG-NEXT: entry:
5598 ; EPILOG-NEXT: %0 = add i64 %trip, -1
5599 ; EPILOG-NEXT: %xtraiter = and i64 %trip, 7
5600 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
5601 ; EPILOG-NEXT: br i1 %1, label %exit2.unr-lcssa, label %entry.new
5602 ; EPILOG: entry.new:
5603 ; EPILOG-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
5604 ; EPILOG-NEXT: br label %loop_header
5605 ; EPILOG: loop_header:
5606 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5607 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
5608 ; EPILOG-NEXT: call void @bar()
5609 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5610 ; EPILOG: loop_latch:
5611 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5612 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5613 ; EPILOG-NEXT: call void @bar()
5614 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5615 ; EPILOG: loop_latch.1:
5616 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
5617 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
5618 ; EPILOG-NEXT: call void @bar()
5619 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.loopexit
5620 ; EPILOG: loop_latch.2:
5621 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
5622 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
5623 ; EPILOG-NEXT: call void @bar()
5624 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.loopexit
5625 ; EPILOG: loop_latch.3:
5626 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
5627 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
5628 ; EPILOG-NEXT: call void @bar()
5629 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.loopexit
5630 ; EPILOG: loop_latch.4:
5631 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
5632 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
5633 ; EPILOG-NEXT: call void @bar()
5634 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.loopexit
5635 ; EPILOG: loop_latch.5:
5636 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
5637 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
5638 ; EPILOG-NEXT: call void @bar()
5639 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.loopexit
5640 ; EPILOG: loop_latch.6:
5641 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
5642 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
5643 ; EPILOG-NEXT: call void @bar()
5644 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.loopexit
5645 ; EPILOG: loop_latch.7:
5646 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5647 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
5648 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
5649 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.unr-lcssa.loopexit
5650 ; EPILOG: exit1.loopexit:
5651 ; EPILOG-NEXT: br label %exit1
5652 ; EPILOG: exit1.loopexit1:
5653 ; EPILOG-NEXT: br label %exit1
5655 ; EPILOG-NEXT: ret void
5656 ; EPILOG: exit2.unr-lcssa.loopexit:
5657 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
5658 ; EPILOG-NEXT: br label %exit2.unr-lcssa
5659 ; EPILOG: exit2.unr-lcssa:
5660 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.unr-lcssa.loopexit ]
5661 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5662 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5663 ; EPILOG: loop_header.epil.preheader:
5664 ; EPILOG-NEXT: br label %loop_header.epil
5665 ; EPILOG: loop_header.epil:
5666 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
5667 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
5668 ; EPILOG-NEXT: call void @bar()
5669 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1.loopexit1
5670 ; EPILOG: loop_latch.epil:
5671 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
5672 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
5673 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
5674 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
5675 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.epilog-lcssa, !llvm.loop !15
5676 ; EPILOG: exit2.epilog-lcssa:
5677 ; EPILOG-NEXT: br label %exit2
5679 ; EPILOG-NEXT: ret void
5681 ; EPILOG-BLOCK-LABEL: @test11(
5682 ; EPILOG-BLOCK-NEXT: entry:
5683 ; EPILOG-BLOCK-NEXT: %0 = add i64 %trip, -1
5684 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
5685 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
5686 ; EPILOG-BLOCK-NEXT: br i1 %1, label %exit2.unr-lcssa, label %entry.new
5687 ; EPILOG-BLOCK: entry.new:
5688 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
5689 ; EPILOG-BLOCK-NEXT: br label %loop_header
5690 ; EPILOG-BLOCK: loop_header:
5691 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5692 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
5693 ; EPILOG-BLOCK-NEXT: call void @bar()
5694 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5695 ; EPILOG-BLOCK: loop_latch:
5696 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5697 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5698 ; EPILOG-BLOCK-NEXT: call void @bar()
5699 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5700 ; EPILOG-BLOCK: loop_latch.1:
5701 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
5702 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
5703 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
5704 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.unr-lcssa.loopexit, !llvm.loop !17
5705 ; EPILOG-BLOCK: exit1.loopexit:
5706 ; EPILOG-BLOCK-NEXT: br label %exit1
5707 ; EPILOG-BLOCK: exit1:
5708 ; EPILOG-BLOCK-NEXT: ret void
5709 ; EPILOG-BLOCK: exit2.unr-lcssa.loopexit:
5710 ; EPILOG-BLOCK-NEXT: br label %exit2.unr-lcssa
5711 ; EPILOG-BLOCK: exit2.unr-lcssa:
5712 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5713 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5714 ; EPILOG-BLOCK: loop_header.epil.preheader:
5715 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
5716 ; EPILOG-BLOCK: loop_header.epil:
5717 ; EPILOG-BLOCK-NEXT: call void @bar()
5718 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1
5719 ; EPILOG-BLOCK: loop_latch.epil:
5720 ; EPILOG-BLOCK-NEXT: br label %exit2
5721 ; EPILOG-BLOCK: exit2:
5722 ; EPILOG-BLOCK-NEXT: ret void
5724 ; PROLOG-LABEL: @test11(
5725 ; PROLOG-NEXT: entry:
5726 ; PROLOG-NEXT: %0 = add i64 %trip, -1
5727 ; PROLOG-NEXT: %xtraiter = and i64 %trip, 7
5728 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5729 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5730 ; PROLOG: loop_header.prol.preheader:
5731 ; PROLOG-NEXT: br label %loop_header.prol
5732 ; PROLOG: loop_header.prol:
5733 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
5734 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
5735 ; PROLOG-NEXT: call void @bar()
5736 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1.loopexit1
5737 ; PROLOG: loop_latch.prol:
5738 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
5739 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
5740 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
5741 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
5742 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !15
5743 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
5744 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
5745 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
5746 ; PROLOG: loop_header.prol.loopexit:
5747 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
5748 ; PROLOG-NEXT: %1 = icmp ult i64 %0, 7
5749 ; PROLOG-NEXT: br i1 %1, label %exit2, label %entry.new
5750 ; PROLOG: entry.new:
5751 ; PROLOG-NEXT: br label %loop_header
5752 ; PROLOG: loop_header:
5753 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5754 ; PROLOG-NEXT: call void @bar()
5755 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5756 ; PROLOG: loop_latch:
5757 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
5758 ; PROLOG-NEXT: call void @bar()
5759 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5760 ; PROLOG: loop_latch.1:
5761 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
5762 ; PROLOG-NEXT: call void @bar()
5763 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.loopexit
5764 ; PROLOG: loop_latch.2:
5765 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
5766 ; PROLOG-NEXT: call void @bar()
5767 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.loopexit
5768 ; PROLOG: loop_latch.3:
5769 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
5770 ; PROLOG-NEXT: call void @bar()
5771 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.loopexit
5772 ; PROLOG: loop_latch.4:
5773 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
5774 ; PROLOG-NEXT: call void @bar()
5775 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.loopexit
5776 ; PROLOG: loop_latch.5:
5777 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
5778 ; PROLOG-NEXT: call void @bar()
5779 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.loopexit
5780 ; PROLOG: loop_latch.6:
5781 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
5782 ; PROLOG-NEXT: call void @bar()
5783 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.loopexit
5784 ; PROLOG: loop_latch.7:
5785 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5786 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
5787 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.unr-lcssa
5788 ; PROLOG: exit1.loopexit:
5789 ; PROLOG-NEXT: br label %exit1
5790 ; PROLOG: exit1.loopexit1:
5791 ; PROLOG-NEXT: br label %exit1
5793 ; PROLOG-NEXT: ret void
5794 ; PROLOG: exit2.unr-lcssa:
5795 ; PROLOG-NEXT: br label %exit2
5797 ; PROLOG-NEXT: ret void
5799 ; PROLOG-BLOCK-LABEL: @test11(
5800 ; PROLOG-BLOCK-NEXT: entry:
5801 ; PROLOG-BLOCK-NEXT: %0 = add i64 %trip, -1
5802 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
5803 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5804 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5805 ; PROLOG-BLOCK: loop_header.prol.preheader:
5806 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
5807 ; PROLOG-BLOCK: loop_header.prol:
5808 ; PROLOG-BLOCK-NEXT: call void @bar()
5809 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1
5810 ; PROLOG-BLOCK: loop_latch.prol:
5811 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
5812 ; PROLOG-BLOCK: loop_header.prol.loopexit:
5813 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
5814 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
5815 ; PROLOG-BLOCK-NEXT: br i1 %1, label %exit2, label %entry.new
5816 ; PROLOG-BLOCK: entry.new:
5817 ; PROLOG-BLOCK-NEXT: br label %loop_header
5818 ; PROLOG-BLOCK: loop_header:
5819 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5820 ; PROLOG-BLOCK-NEXT: call void @bar()
5821 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5822 ; PROLOG-BLOCK: loop_latch:
5823 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
5824 ; PROLOG-BLOCK-NEXT: call void @bar()
5825 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5826 ; PROLOG-BLOCK: loop_latch.1:
5827 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
5828 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
5829 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.unr-lcssa, !llvm.loop !17
5830 ; PROLOG-BLOCK: exit1.loopexit:
5831 ; PROLOG-BLOCK-NEXT: br label %exit1
5832 ; PROLOG-BLOCK: exit1:
5833 ; PROLOG-BLOCK-NEXT: ret void
5834 ; PROLOG-BLOCK: exit2.unr-lcssa:
5835 ; PROLOG-BLOCK-NEXT: br label %exit2
5836 ; PROLOG-BLOCK: exit2:
5837 ; PROLOG-BLOCK-NEXT: ret void
5840 br label %loop_header
5843 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
5845 br i1 %cond, label %loop_latch, label %exit1
5848 %iv_next = add i64 %iv, 1
5849 %cmp = icmp ne i64 %iv_next, %trip
5850 br i1 %cmp, label %loop_header, label %exit2
5859 ; Combine a computeable and invariant test to make sure
5860 ; the interaction of both doesn't do anything weird
5861 define void @test12(i64 %trip, i64 %trip2, i1 %cond) {
5862 ; EPILOG-LABEL: @test12(
5863 ; EPILOG-NEXT: entry:
5864 ; EPILOG-NEXT: %0 = add i64 %trip, -1
5865 ; EPILOG-NEXT: %xtraiter = and i64 %trip, 7
5866 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
5867 ; EPILOG-NEXT: br i1 %1, label %exit1.unr-lcssa, label %entry.new
5868 ; EPILOG: entry.new:
5869 ; EPILOG-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
5870 ; EPILOG-NEXT: br label %loop_header
5871 ; EPILOG: loop_header:
5872 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5873 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
5874 ; EPILOG-NEXT: call void @bar()
5875 ; EPILOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5876 ; EPILOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
5877 ; EPILOG: loop_exiting_bb2:
5878 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.epilog-lcssa.loopexit
5879 ; EPILOG: loop_latch:
5880 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5881 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5882 ; EPILOG-NEXT: call void @bar()
5883 ; EPILOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5884 ; EPILOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
5885 ; EPILOG: loop_exiting_bb2.1:
5886 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
5887 ; EPILOG: loop_latch.1:
5888 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
5889 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
5890 ; EPILOG-NEXT: call void @bar()
5891 ; EPILOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5892 ; EPILOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.epilog-lcssa.loopexit
5893 ; EPILOG: loop_exiting_bb2.2:
5894 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.epilog-lcssa.loopexit
5895 ; EPILOG: loop_latch.2:
5896 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
5897 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
5898 ; EPILOG-NEXT: call void @bar()
5899 ; EPILOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5900 ; EPILOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.epilog-lcssa.loopexit
5901 ; EPILOG: loop_exiting_bb2.3:
5902 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.epilog-lcssa.loopexit
5903 ; EPILOG: loop_latch.3:
5904 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
5905 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
5906 ; EPILOG-NEXT: call void @bar()
5907 ; EPILOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5908 ; EPILOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.epilog-lcssa.loopexit
5909 ; EPILOG: loop_exiting_bb2.4:
5910 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.epilog-lcssa.loopexit
5911 ; EPILOG: loop_latch.4:
5912 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
5913 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
5914 ; EPILOG-NEXT: call void @bar()
5915 ; EPILOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5916 ; EPILOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.epilog-lcssa.loopexit
5917 ; EPILOG: loop_exiting_bb2.5:
5918 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.epilog-lcssa.loopexit
5919 ; EPILOG: loop_latch.5:
5920 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
5921 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
5922 ; EPILOG-NEXT: call void @bar()
5923 ; EPILOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5924 ; EPILOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.epilog-lcssa.loopexit
5925 ; EPILOG: loop_exiting_bb2.6:
5926 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.epilog-lcssa.loopexit
5927 ; EPILOG: loop_latch.6:
5928 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
5929 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
5930 ; EPILOG-NEXT: call void @bar()
5931 ; EPILOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5932 ; EPILOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.epilog-lcssa.loopexit
5933 ; EPILOG: loop_exiting_bb2.7:
5934 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.epilog-lcssa.loopexit
5935 ; EPILOG: loop_latch.7:
5936 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5937 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
5938 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
5939 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
5940 ; EPILOG: exit1.unr-lcssa.loopexit:
5941 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
5942 ; EPILOG-NEXT: br label %exit1.unr-lcssa
5943 ; EPILOG: exit1.unr-lcssa:
5944 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
5945 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5946 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
5947 ; EPILOG: loop_header.epil.preheader:
5948 ; EPILOG-NEXT: br label %loop_header.epil
5949 ; EPILOG: loop_header.epil:
5950 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
5951 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
5952 ; EPILOG-NEXT: call void @bar()
5953 ; EPILOG-NEXT: %cmp_early.epil = icmp ne i64 %iv.epil, %trip2
5954 ; EPILOG-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa.loopexit1
5955 ; EPILOG: loop_exiting_bb2.epil:
5956 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1.epilog-lcssa.loopexit1
5957 ; EPILOG: loop_latch.epil:
5958 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
5959 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
5960 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
5961 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
5962 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit1.epilog-lcssa.loopexit1, !llvm.loop !16
5963 ; EPILOG: exit1.epilog-lcssa.loopexit:
5964 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
5965 ; EPILOG: exit1.epilog-lcssa.loopexit1:
5966 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
5967 ; EPILOG: exit1.epilog-lcssa:
5968 ; EPILOG-NEXT: br label %exit1
5970 ; EPILOG-NEXT: ret void
5972 ; EPILOG-BLOCK-LABEL: @test12(
5973 ; EPILOG-BLOCK-NEXT: entry:
5974 ; EPILOG-BLOCK-NEXT: %0 = add i64 %trip, -1
5975 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
5976 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
5977 ; EPILOG-BLOCK-NEXT: br i1 %1, label %exit1.unr-lcssa, label %entry.new
5978 ; EPILOG-BLOCK: entry.new:
5979 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
5980 ; EPILOG-BLOCK-NEXT: br label %loop_header
5981 ; EPILOG-BLOCK: loop_header:
5982 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5983 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
5984 ; EPILOG-BLOCK-NEXT: call void @bar()
5985 ; EPILOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5986 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
5987 ; EPILOG-BLOCK: loop_exiting_bb2:
5988 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.epilog-lcssa.loopexit
5989 ; EPILOG-BLOCK: loop_latch:
5990 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5991 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5992 ; EPILOG-BLOCK-NEXT: call void @bar()
5993 ; EPILOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5994 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
5995 ; EPILOG-BLOCK: loop_exiting_bb2.1:
5996 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
5997 ; EPILOG-BLOCK: loop_latch.1:
5998 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
5999 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
6000 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
6001 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !18
6002 ; EPILOG-BLOCK: exit1.unr-lcssa.loopexit:
6003 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
6004 ; EPILOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6005 ; EPILOG-BLOCK: exit1.unr-lcssa:
6006 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6007 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6008 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6009 ; EPILOG-BLOCK: loop_header.epil.preheader:
6010 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
6011 ; EPILOG-BLOCK: loop_header.epil:
6012 ; EPILOG-BLOCK-NEXT: call void @bar()
6013 ; EPILOG-BLOCK-NEXT: %cmp_early.epil = icmp ne i64 %iv.unr, %trip2
6014 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa
6015 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
6016 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1.epilog-lcssa
6017 ; EPILOG-BLOCK: loop_latch.epil:
6018 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6019 ; EPILOG-BLOCK: exit1.epilog-lcssa.loopexit:
6020 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6021 ; EPILOG-BLOCK: exit1.epilog-lcssa:
6022 ; EPILOG-BLOCK-NEXT: br label %exit1
6023 ; EPILOG-BLOCK: exit1:
6024 ; EPILOG-BLOCK-NEXT: ret void
6026 ; PROLOG-LABEL: @test12(
6027 ; PROLOG-NEXT: entry:
6028 ; PROLOG-NEXT: %0 = add i64 %trip, -1
6029 ; PROLOG-NEXT: %xtraiter = and i64 %trip, 7
6030 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6031 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6032 ; PROLOG: loop_header.prol.preheader:
6033 ; PROLOG-NEXT: br label %loop_header.prol
6034 ; PROLOG: loop_header.prol:
6035 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
6036 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
6037 ; PROLOG-NEXT: call void @bar()
6038 ; PROLOG-NEXT: %cmp_early.prol = icmp ne i64 %iv.prol, %trip2
6039 ; PROLOG-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa.loopexit1
6040 ; PROLOG: loop_exiting_bb2.prol:
6041 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1.unr-lcssa.loopexit1
6042 ; PROLOG: loop_latch.prol:
6043 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
6044 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
6045 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
6046 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
6047 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !16
6048 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
6049 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
6050 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
6051 ; PROLOG: loop_header.prol.loopexit:
6052 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
6053 ; PROLOG-NEXT: %1 = icmp ult i64 %0, 7
6054 ; PROLOG-NEXT: br i1 %1, label %exit1, label %entry.new
6055 ; PROLOG: entry.new:
6056 ; PROLOG-NEXT: br label %loop_header
6057 ; PROLOG: loop_header:
6058 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6059 ; PROLOG-NEXT: call void @bar()
6060 ; PROLOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6061 ; PROLOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6062 ; PROLOG: loop_exiting_bb2:
6063 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.unr-lcssa.loopexit
6064 ; PROLOG: loop_latch:
6065 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
6066 ; PROLOG-NEXT: call void @bar()
6067 ; PROLOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6068 ; PROLOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6069 ; PROLOG: loop_exiting_bb2.1:
6070 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6071 ; PROLOG: loop_latch.1:
6072 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
6073 ; PROLOG-NEXT: call void @bar()
6074 ; PROLOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
6075 ; PROLOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.unr-lcssa.loopexit
6076 ; PROLOG: loop_exiting_bb2.2:
6077 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.unr-lcssa.loopexit
6078 ; PROLOG: loop_latch.2:
6079 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
6080 ; PROLOG-NEXT: call void @bar()
6081 ; PROLOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
6082 ; PROLOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.unr-lcssa.loopexit
6083 ; PROLOG: loop_exiting_bb2.3:
6084 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.unr-lcssa.loopexit
6085 ; PROLOG: loop_latch.3:
6086 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
6087 ; PROLOG-NEXT: call void @bar()
6088 ; PROLOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
6089 ; PROLOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.unr-lcssa.loopexit
6090 ; PROLOG: loop_exiting_bb2.4:
6091 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.unr-lcssa.loopexit
6092 ; PROLOG: loop_latch.4:
6093 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
6094 ; PROLOG-NEXT: call void @bar()
6095 ; PROLOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
6096 ; PROLOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.unr-lcssa.loopexit
6097 ; PROLOG: loop_exiting_bb2.5:
6098 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.unr-lcssa.loopexit
6099 ; PROLOG: loop_latch.5:
6100 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
6101 ; PROLOG-NEXT: call void @bar()
6102 ; PROLOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
6103 ; PROLOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.unr-lcssa.loopexit
6104 ; PROLOG: loop_exiting_bb2.6:
6105 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.unr-lcssa.loopexit
6106 ; PROLOG: loop_latch.6:
6107 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
6108 ; PROLOG-NEXT: call void @bar()
6109 ; PROLOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
6110 ; PROLOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.unr-lcssa.loopexit
6111 ; PROLOG: loop_exiting_bb2.7:
6112 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.unr-lcssa.loopexit
6113 ; PROLOG: loop_latch.7:
6114 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6115 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
6116 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6117 ; PROLOG: exit1.unr-lcssa.loopexit:
6118 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6119 ; PROLOG: exit1.unr-lcssa.loopexit1:
6120 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6121 ; PROLOG: exit1.unr-lcssa:
6122 ; PROLOG-NEXT: br label %exit1
6124 ; PROLOG-NEXT: ret void
6126 ; PROLOG-BLOCK-LABEL: @test12(
6127 ; PROLOG-BLOCK-NEXT: entry:
6128 ; PROLOG-BLOCK-NEXT: %0 = add i64 %trip, -1
6129 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
6130 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6131 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6132 ; PROLOG-BLOCK: loop_header.prol.preheader:
6133 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
6134 ; PROLOG-BLOCK: loop_header.prol:
6135 ; PROLOG-BLOCK-NEXT: call void @bar()
6136 ; PROLOG-BLOCK-NEXT: %cmp_early.prol = icmp ne i64 0, %trip2
6137 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa
6138 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
6139 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1.unr-lcssa
6140 ; PROLOG-BLOCK: loop_latch.prol:
6141 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
6142 ; PROLOG-BLOCK: loop_header.prol.loopexit:
6143 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
6144 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
6145 ; PROLOG-BLOCK-NEXT: br i1 %1, label %exit1, label %entry.new
6146 ; PROLOG-BLOCK: entry.new:
6147 ; PROLOG-BLOCK-NEXT: br label %loop_header
6148 ; PROLOG-BLOCK: loop_header:
6149 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6150 ; PROLOG-BLOCK-NEXT: call void @bar()
6151 ; PROLOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6152 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6153 ; PROLOG-BLOCK: loop_exiting_bb2:
6154 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.unr-lcssa.loopexit
6155 ; PROLOG-BLOCK: loop_latch:
6156 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
6157 ; PROLOG-BLOCK-NEXT: call void @bar()
6158 ; PROLOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6159 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6160 ; PROLOG-BLOCK: loop_exiting_bb2.1:
6161 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6162 ; PROLOG-BLOCK: loop_latch.1:
6163 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6164 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
6165 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !18
6166 ; PROLOG-BLOCK: exit1.unr-lcssa.loopexit:
6167 ; PROLOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6168 ; PROLOG-BLOCK: exit1.unr-lcssa:
6169 ; PROLOG-BLOCK-NEXT: br label %exit1
6170 ; PROLOG-BLOCK: exit1:
6171 ; PROLOG-BLOCK-NEXT: ret void
6174 br label %loop_header
6177 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
6179 %cmp_early = icmp ne i64 %iv, %trip2
6180 br i1 %cmp_early, label %loop_exiting_bb2, label %exit1
6183 br i1 %cond, label %loop_latch, label %exit1
6186 %iv_next = add i64 %iv, 1
6187 %cmp = icmp ne i64 %iv_next, %trip
6188 br i1 %cmp, label %loop_header, label %exit1
6194 declare i1 @unknown_cond()
6196 ; Mix of computable and uncompatable exits
6197 define void @test13(i64 %trip, i64 %trip2) {
6198 ; EPILOG-LABEL: @test13(
6199 ; EPILOG-NEXT: entry:
6200 ; EPILOG-NEXT: %0 = add i64 %trip, -1
6201 ; EPILOG-NEXT: %xtraiter = and i64 %trip, 7
6202 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
6203 ; EPILOG-NEXT: br i1 %1, label %exit1.unr-lcssa, label %entry.new
6204 ; EPILOG: entry.new:
6205 ; EPILOG-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
6206 ; EPILOG-NEXT: br label %loop_header
6207 ; EPILOG: loop_header:
6208 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6209 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
6210 ; EPILOG-NEXT: call void @bar()
6211 ; EPILOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6212 ; EPILOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6213 ; EPILOG: loop_exiting_bb2:
6214 ; EPILOG-NEXT: %unknown = call i1 @unknown_cond()
6215 ; EPILOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6216 ; EPILOG: loop_latch:
6217 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6218 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
6219 ; EPILOG-NEXT: call void @bar()
6220 ; EPILOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6221 ; EPILOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6222 ; EPILOG: loop_exiting_bb2.1:
6223 ; EPILOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6224 ; EPILOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6225 ; EPILOG: loop_latch.1:
6226 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
6227 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
6228 ; EPILOG-NEXT: call void @bar()
6229 ; EPILOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
6230 ; EPILOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.epilog-lcssa.loopexit
6231 ; EPILOG: loop_exiting_bb2.2:
6232 ; EPILOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6233 ; EPILOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.epilog-lcssa.loopexit
6234 ; EPILOG: loop_latch.2:
6235 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
6236 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
6237 ; EPILOG-NEXT: call void @bar()
6238 ; EPILOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
6239 ; EPILOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.epilog-lcssa.loopexit
6240 ; EPILOG: loop_exiting_bb2.3:
6241 ; EPILOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6242 ; EPILOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.epilog-lcssa.loopexit
6243 ; EPILOG: loop_latch.3:
6244 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
6245 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
6246 ; EPILOG-NEXT: call void @bar()
6247 ; EPILOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
6248 ; EPILOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.epilog-lcssa.loopexit
6249 ; EPILOG: loop_exiting_bb2.4:
6250 ; EPILOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6251 ; EPILOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.epilog-lcssa.loopexit
6252 ; EPILOG: loop_latch.4:
6253 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
6254 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
6255 ; EPILOG-NEXT: call void @bar()
6256 ; EPILOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
6257 ; EPILOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.epilog-lcssa.loopexit
6258 ; EPILOG: loop_exiting_bb2.5:
6259 ; EPILOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6260 ; EPILOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.epilog-lcssa.loopexit
6261 ; EPILOG: loop_latch.5:
6262 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
6263 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
6264 ; EPILOG-NEXT: call void @bar()
6265 ; EPILOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
6266 ; EPILOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.epilog-lcssa.loopexit
6267 ; EPILOG: loop_exiting_bb2.6:
6268 ; EPILOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6269 ; EPILOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.epilog-lcssa.loopexit
6270 ; EPILOG: loop_latch.6:
6271 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
6272 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
6273 ; EPILOG-NEXT: call void @bar()
6274 ; EPILOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
6275 ; EPILOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.epilog-lcssa.loopexit
6276 ; EPILOG: loop_exiting_bb2.7:
6277 ; EPILOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6278 ; EPILOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.epilog-lcssa.loopexit
6279 ; EPILOG: loop_latch.7:
6280 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6281 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
6282 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
6283 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6284 ; EPILOG: exit1.unr-lcssa.loopexit:
6285 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
6286 ; EPILOG-NEXT: br label %exit1.unr-lcssa
6287 ; EPILOG: exit1.unr-lcssa:
6288 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6289 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6290 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6291 ; EPILOG: loop_header.epil.preheader:
6292 ; EPILOG-NEXT: br label %loop_header.epil
6293 ; EPILOG: loop_header.epil:
6294 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
6295 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
6296 ; EPILOG-NEXT: call void @bar()
6297 ; EPILOG-NEXT: %cmp_early.epil = icmp ne i64 %iv.epil, %trip2
6298 ; EPILOG-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa.loopexit1
6299 ; EPILOG: loop_exiting_bb2.epil:
6300 ; EPILOG-NEXT: %unknown.epil = call i1 @unknown_cond()
6301 ; EPILOG-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa.loopexit1
6302 ; EPILOG: loop_latch.epil:
6303 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
6304 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
6305 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
6306 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
6307 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit1.epilog-lcssa.loopexit1, !llvm.loop !17
6308 ; EPILOG: exit1.epilog-lcssa.loopexit:
6309 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6310 ; EPILOG: exit1.epilog-lcssa.loopexit1:
6311 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6312 ; EPILOG: exit1.epilog-lcssa:
6313 ; EPILOG-NEXT: br label %exit1
6315 ; EPILOG-NEXT: ret void
6317 ; EPILOG-BLOCK-LABEL: @test13(
6318 ; EPILOG-BLOCK-NEXT: entry:
6319 ; EPILOG-BLOCK-NEXT: %0 = add i64 %trip, -1
6320 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
6321 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
6322 ; EPILOG-BLOCK-NEXT: br i1 %1, label %exit1.unr-lcssa, label %entry.new
6323 ; EPILOG-BLOCK: entry.new:
6324 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
6325 ; EPILOG-BLOCK-NEXT: br label %loop_header
6326 ; EPILOG-BLOCK: loop_header:
6327 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6328 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
6329 ; EPILOG-BLOCK-NEXT: call void @bar()
6330 ; EPILOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6331 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6332 ; EPILOG-BLOCK: loop_exiting_bb2:
6333 ; EPILOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6334 ; EPILOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6335 ; EPILOG-BLOCK: loop_latch:
6336 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6337 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
6338 ; EPILOG-BLOCK-NEXT: call void @bar()
6339 ; EPILOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6340 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6341 ; EPILOG-BLOCK: loop_exiting_bb2.1:
6342 ; EPILOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6343 ; EPILOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6344 ; EPILOG-BLOCK: loop_latch.1:
6345 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6346 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
6347 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
6348 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !19
6349 ; EPILOG-BLOCK: exit1.unr-lcssa.loopexit:
6350 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
6351 ; EPILOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6352 ; EPILOG-BLOCK: exit1.unr-lcssa:
6353 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6354 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6355 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6356 ; EPILOG-BLOCK: loop_header.epil.preheader:
6357 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
6358 ; EPILOG-BLOCK: loop_header.epil:
6359 ; EPILOG-BLOCK-NEXT: call void @bar()
6360 ; EPILOG-BLOCK-NEXT: %cmp_early.epil = icmp ne i64 %iv.unr, %trip2
6361 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa
6362 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
6363 ; EPILOG-BLOCK-NEXT: %unknown.epil = call i1 @unknown_cond()
6364 ; EPILOG-BLOCK-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa
6365 ; EPILOG-BLOCK: loop_latch.epil:
6366 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6367 ; EPILOG-BLOCK: exit1.epilog-lcssa.loopexit:
6368 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6369 ; EPILOG-BLOCK: exit1.epilog-lcssa:
6370 ; EPILOG-BLOCK-NEXT: br label %exit1
6371 ; EPILOG-BLOCK: exit1:
6372 ; EPILOG-BLOCK-NEXT: ret void
6374 ; PROLOG-LABEL: @test13(
6375 ; PROLOG-NEXT: entry:
6376 ; PROLOG-NEXT: %0 = add i64 %trip, -1
6377 ; PROLOG-NEXT: %xtraiter = and i64 %trip, 7
6378 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6379 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6380 ; PROLOG: loop_header.prol.preheader:
6381 ; PROLOG-NEXT: br label %loop_header.prol
6382 ; PROLOG: loop_header.prol:
6383 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
6384 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
6385 ; PROLOG-NEXT: call void @bar()
6386 ; PROLOG-NEXT: %cmp_early.prol = icmp ne i64 %iv.prol, %trip2
6387 ; PROLOG-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa.loopexit1
6388 ; PROLOG: loop_exiting_bb2.prol:
6389 ; PROLOG-NEXT: %unknown.prol = call i1 @unknown_cond()
6390 ; PROLOG-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa.loopexit1
6391 ; PROLOG: loop_latch.prol:
6392 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
6393 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
6394 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
6395 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
6396 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !17
6397 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
6398 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
6399 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
6400 ; PROLOG: loop_header.prol.loopexit:
6401 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
6402 ; PROLOG-NEXT: %1 = icmp ult i64 %0, 7
6403 ; PROLOG-NEXT: br i1 %1, label %exit1, label %entry.new
6404 ; PROLOG: entry.new:
6405 ; PROLOG-NEXT: br label %loop_header
6406 ; PROLOG: loop_header:
6407 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6408 ; PROLOG-NEXT: call void @bar()
6409 ; PROLOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6410 ; PROLOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6411 ; PROLOG: loop_exiting_bb2:
6412 ; PROLOG-NEXT: %unknown = call i1 @unknown_cond()
6413 ; PROLOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6414 ; PROLOG: loop_latch:
6415 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
6416 ; PROLOG-NEXT: call void @bar()
6417 ; PROLOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6418 ; PROLOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6419 ; PROLOG: loop_exiting_bb2.1:
6420 ; PROLOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6421 ; PROLOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6422 ; PROLOG: loop_latch.1:
6423 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
6424 ; PROLOG-NEXT: call void @bar()
6425 ; PROLOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
6426 ; PROLOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.unr-lcssa.loopexit
6427 ; PROLOG: loop_exiting_bb2.2:
6428 ; PROLOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6429 ; PROLOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.unr-lcssa.loopexit
6430 ; PROLOG: loop_latch.2:
6431 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
6432 ; PROLOG-NEXT: call void @bar()
6433 ; PROLOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
6434 ; PROLOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.unr-lcssa.loopexit
6435 ; PROLOG: loop_exiting_bb2.3:
6436 ; PROLOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6437 ; PROLOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.unr-lcssa.loopexit
6438 ; PROLOG: loop_latch.3:
6439 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
6440 ; PROLOG-NEXT: call void @bar()
6441 ; PROLOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
6442 ; PROLOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.unr-lcssa.loopexit
6443 ; PROLOG: loop_exiting_bb2.4:
6444 ; PROLOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6445 ; PROLOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.unr-lcssa.loopexit
6446 ; PROLOG: loop_latch.4:
6447 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
6448 ; PROLOG-NEXT: call void @bar()
6449 ; PROLOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
6450 ; PROLOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.unr-lcssa.loopexit
6451 ; PROLOG: loop_exiting_bb2.5:
6452 ; PROLOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6453 ; PROLOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.unr-lcssa.loopexit
6454 ; PROLOG: loop_latch.5:
6455 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
6456 ; PROLOG-NEXT: call void @bar()
6457 ; PROLOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
6458 ; PROLOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.unr-lcssa.loopexit
6459 ; PROLOG: loop_exiting_bb2.6:
6460 ; PROLOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6461 ; PROLOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.unr-lcssa.loopexit
6462 ; PROLOG: loop_latch.6:
6463 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
6464 ; PROLOG-NEXT: call void @bar()
6465 ; PROLOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
6466 ; PROLOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.unr-lcssa.loopexit
6467 ; PROLOG: loop_exiting_bb2.7:
6468 ; PROLOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6469 ; PROLOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.unr-lcssa.loopexit
6470 ; PROLOG: loop_latch.7:
6471 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6472 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
6473 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6474 ; PROLOG: exit1.unr-lcssa.loopexit:
6475 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6476 ; PROLOG: exit1.unr-lcssa.loopexit1:
6477 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6478 ; PROLOG: exit1.unr-lcssa:
6479 ; PROLOG-NEXT: br label %exit1
6481 ; PROLOG-NEXT: ret void
6483 ; PROLOG-BLOCK-LABEL: @test13(
6484 ; PROLOG-BLOCK-NEXT: entry:
6485 ; PROLOG-BLOCK-NEXT: %0 = add i64 %trip, -1
6486 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
6487 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6488 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6489 ; PROLOG-BLOCK: loop_header.prol.preheader:
6490 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
6491 ; PROLOG-BLOCK: loop_header.prol:
6492 ; PROLOG-BLOCK-NEXT: call void @bar()
6493 ; PROLOG-BLOCK-NEXT: %cmp_early.prol = icmp ne i64 0, %trip2
6494 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa
6495 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
6496 ; PROLOG-BLOCK-NEXT: %unknown.prol = call i1 @unknown_cond()
6497 ; PROLOG-BLOCK-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa
6498 ; PROLOG-BLOCK: loop_latch.prol:
6499 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
6500 ; PROLOG-BLOCK: loop_header.prol.loopexit:
6501 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
6502 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
6503 ; PROLOG-BLOCK-NEXT: br i1 %1, label %exit1, label %entry.new
6504 ; PROLOG-BLOCK: entry.new:
6505 ; PROLOG-BLOCK-NEXT: br label %loop_header
6506 ; PROLOG-BLOCK: loop_header:
6507 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6508 ; PROLOG-BLOCK-NEXT: call void @bar()
6509 ; PROLOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6510 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6511 ; PROLOG-BLOCK: loop_exiting_bb2:
6512 ; PROLOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6513 ; PROLOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6514 ; PROLOG-BLOCK: loop_latch:
6515 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
6516 ; PROLOG-BLOCK-NEXT: call void @bar()
6517 ; PROLOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6518 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6519 ; PROLOG-BLOCK: loop_exiting_bb2.1:
6520 ; PROLOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6521 ; PROLOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6522 ; PROLOG-BLOCK: loop_latch.1:
6523 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6524 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
6525 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !19
6526 ; PROLOG-BLOCK: exit1.unr-lcssa.loopexit:
6527 ; PROLOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6528 ; PROLOG-BLOCK: exit1.unr-lcssa:
6529 ; PROLOG-BLOCK-NEXT: br label %exit1
6530 ; PROLOG-BLOCK: exit1:
6531 ; PROLOG-BLOCK-NEXT: ret void
6534 br label %loop_header
6537 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
6539 %cmp_early = icmp ne i64 %iv, %trip2
6540 br i1 %cmp_early, label %loop_exiting_bb2, label %exit1
6543 %unknown = call i1 @unknown_cond()
6544 br i1 %unknown, label %loop_latch, label %exit1
6547 %iv_next = add i64 %iv, 1
6548 %cmp = icmp ne i64 %iv_next, %trip
6549 br i1 %cmp, label %loop_header, label %exit1
6555 ; Mix of invariant and (even in theory) uncomputable exits
6556 define void @test14(i64 %trip, i1 %cond) {
6557 ; EPILOG-LABEL: @test14(
6558 ; EPILOG-NEXT: entry:
6559 ; EPILOG-NEXT: %0 = add i64 %trip, -1
6560 ; EPILOG-NEXT: %xtraiter = and i64 %trip, 7
6561 ; EPILOG-NEXT: %1 = icmp ult i64 %0, 7
6562 ; EPILOG-NEXT: br i1 %1, label %exit1.unr-lcssa, label %entry.new
6563 ; EPILOG: entry.new:
6564 ; EPILOG-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
6565 ; EPILOG-NEXT: br label %loop_header
6566 ; EPILOG: loop_header:
6567 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6568 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
6569 ; EPILOG-NEXT: call void @bar()
6570 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6571 ; EPILOG: loop_exiting_bb2:
6572 ; EPILOG-NEXT: %unknown = call i1 @unknown_cond()
6573 ; EPILOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6574 ; EPILOG: loop_latch:
6575 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6576 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
6577 ; EPILOG-NEXT: call void @bar()
6578 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6579 ; EPILOG: loop_exiting_bb2.1:
6580 ; EPILOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6581 ; EPILOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6582 ; EPILOG: loop_latch.1:
6583 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
6584 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
6585 ; EPILOG-NEXT: call void @bar()
6586 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.2, label %exit1.epilog-lcssa.loopexit
6587 ; EPILOG: loop_exiting_bb2.2:
6588 ; EPILOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6589 ; EPILOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.epilog-lcssa.loopexit
6590 ; EPILOG: loop_latch.2:
6591 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
6592 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
6593 ; EPILOG-NEXT: call void @bar()
6594 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.3, label %exit1.epilog-lcssa.loopexit
6595 ; EPILOG: loop_exiting_bb2.3:
6596 ; EPILOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6597 ; EPILOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.epilog-lcssa.loopexit
6598 ; EPILOG: loop_latch.3:
6599 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
6600 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
6601 ; EPILOG-NEXT: call void @bar()
6602 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.4, label %exit1.epilog-lcssa.loopexit
6603 ; EPILOG: loop_exiting_bb2.4:
6604 ; EPILOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6605 ; EPILOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.epilog-lcssa.loopexit
6606 ; EPILOG: loop_latch.4:
6607 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
6608 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
6609 ; EPILOG-NEXT: call void @bar()
6610 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.5, label %exit1.epilog-lcssa.loopexit
6611 ; EPILOG: loop_exiting_bb2.5:
6612 ; EPILOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6613 ; EPILOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.epilog-lcssa.loopexit
6614 ; EPILOG: loop_latch.5:
6615 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
6616 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
6617 ; EPILOG-NEXT: call void @bar()
6618 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.6, label %exit1.epilog-lcssa.loopexit
6619 ; EPILOG: loop_exiting_bb2.6:
6620 ; EPILOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6621 ; EPILOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.epilog-lcssa.loopexit
6622 ; EPILOG: loop_latch.6:
6623 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
6624 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
6625 ; EPILOG-NEXT: call void @bar()
6626 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.7, label %exit1.epilog-lcssa.loopexit
6627 ; EPILOG: loop_exiting_bb2.7:
6628 ; EPILOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6629 ; EPILOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.epilog-lcssa.loopexit
6630 ; EPILOG: loop_latch.7:
6631 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6632 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
6633 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
6634 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6635 ; EPILOG: exit1.unr-lcssa.loopexit:
6636 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
6637 ; EPILOG-NEXT: br label %exit1.unr-lcssa
6638 ; EPILOG: exit1.unr-lcssa:
6639 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6640 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6641 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6642 ; EPILOG: loop_header.epil.preheader:
6643 ; EPILOG-NEXT: br label %loop_header.epil
6644 ; EPILOG: loop_header.epil:
6645 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
6646 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
6647 ; EPILOG-NEXT: call void @bar()
6648 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa.loopexit1
6649 ; EPILOG: loop_exiting_bb2.epil:
6650 ; EPILOG-NEXT: %unknown.epil = call i1 @unknown_cond()
6651 ; EPILOG-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa.loopexit1
6652 ; EPILOG: loop_latch.epil:
6653 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
6654 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
6655 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
6656 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
6657 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit1.epilog-lcssa.loopexit1, !llvm.loop !18
6658 ; EPILOG: exit1.epilog-lcssa.loopexit:
6659 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6660 ; EPILOG: exit1.epilog-lcssa.loopexit1:
6661 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6662 ; EPILOG: exit1.epilog-lcssa:
6663 ; EPILOG-NEXT: br label %exit1
6665 ; EPILOG-NEXT: ret void
6667 ; EPILOG-BLOCK-LABEL: @test14(
6668 ; EPILOG-BLOCK-NEXT: entry:
6669 ; EPILOG-BLOCK-NEXT: %0 = add i64 %trip, -1
6670 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
6671 ; EPILOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
6672 ; EPILOG-BLOCK-NEXT: br i1 %1, label %exit1.unr-lcssa, label %entry.new
6673 ; EPILOG-BLOCK: entry.new:
6674 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %trip, %xtraiter
6675 ; EPILOG-BLOCK-NEXT: br label %loop_header
6676 ; EPILOG-BLOCK: loop_header:
6677 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6678 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
6679 ; EPILOG-BLOCK-NEXT: call void @bar()
6680 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6681 ; EPILOG-BLOCK: loop_exiting_bb2:
6682 ; EPILOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6683 ; EPILOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6684 ; EPILOG-BLOCK: loop_latch:
6685 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6686 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
6687 ; EPILOG-BLOCK-NEXT: call void @bar()
6688 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6689 ; EPILOG-BLOCK: loop_exiting_bb2.1:
6690 ; EPILOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6691 ; EPILOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6692 ; EPILOG-BLOCK: loop_latch.1:
6693 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6694 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
6695 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
6696 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !20
6697 ; EPILOG-BLOCK: exit1.unr-lcssa.loopexit:
6698 ; EPILOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6699 ; EPILOG-BLOCK: exit1.unr-lcssa:
6700 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6701 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6702 ; EPILOG-BLOCK: loop_header.epil.preheader:
6703 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
6704 ; EPILOG-BLOCK: loop_header.epil:
6705 ; EPILOG-BLOCK-NEXT: call void @bar()
6706 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa
6707 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
6708 ; EPILOG-BLOCK-NEXT: %unknown.epil = call i1 @unknown_cond()
6709 ; EPILOG-BLOCK-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa
6710 ; EPILOG-BLOCK: loop_latch.epil:
6711 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6712 ; EPILOG-BLOCK: exit1.epilog-lcssa.loopexit:
6713 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6714 ; EPILOG-BLOCK: exit1.epilog-lcssa:
6715 ; EPILOG-BLOCK-NEXT: br label %exit1
6716 ; EPILOG-BLOCK: exit1:
6717 ; EPILOG-BLOCK-NEXT: ret void
6719 ; PROLOG-LABEL: @test14(
6720 ; PROLOG-NEXT: entry:
6721 ; PROLOG-NEXT: %0 = add i64 %trip, -1
6722 ; PROLOG-NEXT: %xtraiter = and i64 %trip, 7
6723 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6724 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6725 ; PROLOG: loop_header.prol.preheader:
6726 ; PROLOG-NEXT: br label %loop_header.prol
6727 ; PROLOG: loop_header.prol:
6728 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
6729 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
6730 ; PROLOG-NEXT: call void @bar()
6731 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa.loopexit1
6732 ; PROLOG: loop_exiting_bb2.prol:
6733 ; PROLOG-NEXT: %unknown.prol = call i1 @unknown_cond()
6734 ; PROLOG-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa.loopexit1
6735 ; PROLOG: loop_latch.prol:
6736 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
6737 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
6738 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
6739 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
6740 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !18
6741 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
6742 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
6743 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
6744 ; PROLOG: loop_header.prol.loopexit:
6745 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
6746 ; PROLOG-NEXT: %1 = icmp ult i64 %0, 7
6747 ; PROLOG-NEXT: br i1 %1, label %exit1, label %entry.new
6748 ; PROLOG: entry.new:
6749 ; PROLOG-NEXT: br label %loop_header
6750 ; PROLOG: loop_header:
6751 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6752 ; PROLOG-NEXT: call void @bar()
6753 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6754 ; PROLOG: loop_exiting_bb2:
6755 ; PROLOG-NEXT: %unknown = call i1 @unknown_cond()
6756 ; PROLOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6757 ; PROLOG: loop_latch:
6758 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
6759 ; PROLOG-NEXT: call void @bar()
6760 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6761 ; PROLOG: loop_exiting_bb2.1:
6762 ; PROLOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6763 ; PROLOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6764 ; PROLOG: loop_latch.1:
6765 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
6766 ; PROLOG-NEXT: call void @bar()
6767 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.2, label %exit1.unr-lcssa.loopexit
6768 ; PROLOG: loop_exiting_bb2.2:
6769 ; PROLOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6770 ; PROLOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.unr-lcssa.loopexit
6771 ; PROLOG: loop_latch.2:
6772 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
6773 ; PROLOG-NEXT: call void @bar()
6774 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.3, label %exit1.unr-lcssa.loopexit
6775 ; PROLOG: loop_exiting_bb2.3:
6776 ; PROLOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6777 ; PROLOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.unr-lcssa.loopexit
6778 ; PROLOG: loop_latch.3:
6779 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
6780 ; PROLOG-NEXT: call void @bar()
6781 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.4, label %exit1.unr-lcssa.loopexit
6782 ; PROLOG: loop_exiting_bb2.4:
6783 ; PROLOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6784 ; PROLOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.unr-lcssa.loopexit
6785 ; PROLOG: loop_latch.4:
6786 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
6787 ; PROLOG-NEXT: call void @bar()
6788 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.5, label %exit1.unr-lcssa.loopexit
6789 ; PROLOG: loop_exiting_bb2.5:
6790 ; PROLOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6791 ; PROLOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.unr-lcssa.loopexit
6792 ; PROLOG: loop_latch.5:
6793 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
6794 ; PROLOG-NEXT: call void @bar()
6795 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.6, label %exit1.unr-lcssa.loopexit
6796 ; PROLOG: loop_exiting_bb2.6:
6797 ; PROLOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6798 ; PROLOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.unr-lcssa.loopexit
6799 ; PROLOG: loop_latch.6:
6800 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
6801 ; PROLOG-NEXT: call void @bar()
6802 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.7, label %exit1.unr-lcssa.loopexit
6803 ; PROLOG: loop_exiting_bb2.7:
6804 ; PROLOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6805 ; PROLOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.unr-lcssa.loopexit
6806 ; PROLOG: loop_latch.7:
6807 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6808 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
6809 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6810 ; PROLOG: exit1.unr-lcssa.loopexit:
6811 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6812 ; PROLOG: exit1.unr-lcssa.loopexit1:
6813 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6814 ; PROLOG: exit1.unr-lcssa:
6815 ; PROLOG-NEXT: br label %exit1
6817 ; PROLOG-NEXT: ret void
6819 ; PROLOG-BLOCK-LABEL: @test14(
6820 ; PROLOG-BLOCK-NEXT: entry:
6821 ; PROLOG-BLOCK-NEXT: %0 = add i64 %trip, -1
6822 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %trip, 1
6823 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6824 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6825 ; PROLOG-BLOCK: loop_header.prol.preheader:
6826 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
6827 ; PROLOG-BLOCK: loop_header.prol:
6828 ; PROLOG-BLOCK-NEXT: call void @bar()
6829 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa
6830 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
6831 ; PROLOG-BLOCK-NEXT: %unknown.prol = call i1 @unknown_cond()
6832 ; PROLOG-BLOCK-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa
6833 ; PROLOG-BLOCK: loop_latch.prol:
6834 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
6835 ; PROLOG-BLOCK: loop_header.prol.loopexit:
6836 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
6837 ; PROLOG-BLOCK-NEXT: %1 = icmp ult i64 %0, 1
6838 ; PROLOG-BLOCK-NEXT: br i1 %1, label %exit1, label %entry.new
6839 ; PROLOG-BLOCK: entry.new:
6840 ; PROLOG-BLOCK-NEXT: br label %loop_header
6841 ; PROLOG-BLOCK: loop_header:
6842 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6843 ; PROLOG-BLOCK-NEXT: call void @bar()
6844 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6845 ; PROLOG-BLOCK: loop_exiting_bb2:
6846 ; PROLOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6847 ; PROLOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6848 ; PROLOG-BLOCK: loop_latch:
6849 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
6850 ; PROLOG-BLOCK-NEXT: call void @bar()
6851 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6852 ; PROLOG-BLOCK: loop_exiting_bb2.1:
6853 ; PROLOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6854 ; PROLOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6855 ; PROLOG-BLOCK: loop_latch.1:
6856 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6857 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
6858 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !20
6859 ; PROLOG-BLOCK: exit1.unr-lcssa.loopexit:
6860 ; PROLOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6861 ; PROLOG-BLOCK: exit1.unr-lcssa:
6862 ; PROLOG-BLOCK-NEXT: br label %exit1
6863 ; PROLOG-BLOCK: exit1:
6864 ; PROLOG-BLOCK-NEXT: ret void
6867 br label %loop_header
6870 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
6872 br i1 %cond, label %loop_exiting_bb2, label %exit1
6875 %unknown = call i1 @unknown_cond()
6876 br i1 %unknown, label %loop_latch, label %exit1
6879 %iv_next = add i64 %iv, 1
6880 %cmp = icmp ne i64 %iv_next, %trip
6881 br i1 %cmp, label %loop_header, label %exit1