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 = freeze i64 %trip
15 ; EPILOG-NEXT: %1 = add i64 %0, -1
16 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
17 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
18 ; EPILOG-NEXT: br i1 %2, label %exit2.loopexit.unr-lcssa, label %entry.new
20 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
21 ; EPILOG-NEXT: br label %loop_header
22 ; EPILOG: loop_header:
23 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
24 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
25 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
26 ; EPILOG: loop_exiting_bb1:
27 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
28 ; EPILOG: loop_exiting_bb2:
29 ; EPILOG-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
30 ; EPILOG: exit3.loopexit:
31 ; EPILOG-NEXT: br label %exit3
32 ; EPILOG: exit3.loopexit2:
33 ; EPILOG-NEXT: br label %exit3
35 ; EPILOG-NEXT: ret void
37 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
38 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
39 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
40 ; EPILOG: loop_exiting_bb1.1:
41 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
42 ; EPILOG: loop_exiting_bb2.1:
43 ; EPILOG-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
44 ; EPILOG: loop_latch.1:
45 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
46 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
47 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting_bb1.2
48 ; EPILOG: loop_exiting_bb1.2:
49 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.2, label %exit1.loopexit
50 ; EPILOG: loop_exiting_bb2.2:
51 ; EPILOG-NEXT: br i1 false, label %loop_latch.2, label %exit3.loopexit
52 ; EPILOG: loop_latch.2:
53 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
54 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
55 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting_bb1.3
56 ; EPILOG: loop_exiting_bb1.3:
57 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.3, label %exit1.loopexit
58 ; EPILOG: loop_exiting_bb2.3:
59 ; EPILOG-NEXT: br i1 false, label %loop_latch.3, label %exit3.loopexit
60 ; EPILOG: loop_latch.3:
61 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
62 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
63 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting_bb1.4
64 ; EPILOG: loop_exiting_bb1.4:
65 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.4, label %exit1.loopexit
66 ; EPILOG: loop_exiting_bb2.4:
67 ; EPILOG-NEXT: br i1 false, label %loop_latch.4, label %exit3.loopexit
68 ; EPILOG: loop_latch.4:
69 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
70 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
71 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting_bb1.5
72 ; EPILOG: loop_exiting_bb1.5:
73 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.5, label %exit1.loopexit
74 ; EPILOG: loop_exiting_bb2.5:
75 ; EPILOG-NEXT: br i1 false, label %loop_latch.5, label %exit3.loopexit
76 ; EPILOG: loop_latch.5:
77 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
78 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
79 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting_bb1.6
80 ; EPILOG: loop_exiting_bb1.6:
81 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.6, label %exit1.loopexit
82 ; EPILOG: loop_exiting_bb2.6:
83 ; EPILOG-NEXT: br i1 false, label %loop_latch.6, label %exit3.loopexit
84 ; EPILOG: loop_latch.6:
85 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
86 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
87 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting_bb1.7
88 ; EPILOG: loop_exiting_bb1.7:
89 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.7, label %exit1.loopexit
90 ; EPILOG: loop_exiting_bb2.7:
91 ; EPILOG-NEXT: br i1 false, label %loop_latch.7, label %exit3.loopexit
92 ; EPILOG: loop_latch.7:
93 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
94 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
95 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
96 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit
97 ; EPILOG: exit1.loopexit:
98 ; EPILOG-NEXT: br label %exit1
99 ; EPILOG: exit1.loopexit1:
100 ; EPILOG-NEXT: br label %exit1
102 ; EPILOG-NEXT: ret void
103 ; EPILOG: exit2.loopexit.unr-lcssa.loopexit:
104 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
105 ; EPILOG-NEXT: br label %exit2.loopexit.unr-lcssa
106 ; EPILOG: exit2.loopexit.unr-lcssa:
107 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
108 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
109 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
110 ; EPILOG: loop_header.epil.preheader:
111 ; EPILOG-NEXT: br label %loop_header.epil
112 ; EPILOG: loop_header.epil:
113 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
114 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
115 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting_bb1.epil
116 ; EPILOG: loop_exiting_bb1.epil:
117 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.epil, label %exit1.loopexit1
118 ; EPILOG: loop_exiting_bb2.epil:
119 ; EPILOG-NEXT: br i1 false, label %loop_latch.epil, label %exit3.loopexit2
120 ; EPILOG: loop_latch.epil:
121 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
122 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
123 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
124 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
125 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.loopexit.epilog-lcssa, !llvm.loop !0
126 ; EPILOG: exit2.loopexit.epilog-lcssa:
127 ; EPILOG-NEXT: br label %exit2.loopexit
128 ; EPILOG: exit2.loopexit:
129 ; EPILOG-NEXT: ret void
131 ; EPILOG-BLOCK-LABEL: @test1(
132 ; EPILOG-BLOCK-NEXT: entry:
133 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
134 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
135 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
136 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
137 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit2.loopexit.unr-lcssa, label %entry.new
138 ; EPILOG-BLOCK: entry.new:
139 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
140 ; EPILOG-BLOCK-NEXT: br label %loop_header
141 ; EPILOG-BLOCK: loop_header:
142 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
143 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
144 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
145 ; EPILOG-BLOCK: loop_exiting_bb1:
146 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
147 ; EPILOG-BLOCK: loop_exiting_bb2:
148 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
149 ; EPILOG-BLOCK: exit3.loopexit:
150 ; EPILOG-BLOCK-NEXT: br label %exit3
151 ; EPILOG-BLOCK: exit3:
152 ; EPILOG-BLOCK-NEXT: ret void
153 ; EPILOG-BLOCK: loop_latch:
154 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
155 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
156 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
157 ; EPILOG-BLOCK: loop_exiting_bb1.1:
158 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
159 ; EPILOG-BLOCK: loop_exiting_bb2.1:
160 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
161 ; EPILOG-BLOCK: loop_latch.1:
162 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
163 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
164 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
165 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit, !llvm.loop !0
166 ; EPILOG-BLOCK: exit1.loopexit:
167 ; EPILOG-BLOCK-NEXT: br label %exit1
168 ; EPILOG-BLOCK: exit1:
169 ; EPILOG-BLOCK-NEXT: ret void
170 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa.loopexit:
171 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit.unr-lcssa
172 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa:
173 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
174 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
175 ; EPILOG-BLOCK: loop_header.epil.preheader:
176 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
177 ; EPILOG-BLOCK: loop_header.epil:
178 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting_bb1.epil
179 ; EPILOG-BLOCK: loop_exiting_bb1.epil:
180 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.epil, label %exit1
181 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
182 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_latch.epil, label %exit3
183 ; EPILOG-BLOCK: loop_latch.epil:
184 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit
185 ; EPILOG-BLOCK: exit2.loopexit:
186 ; EPILOG-BLOCK-NEXT: ret void
188 ; PROLOG-LABEL: @test1(
189 ; PROLOG-NEXT: entry:
190 ; PROLOG-NEXT: %0 = freeze i64 %trip
191 ; PROLOG-NEXT: %1 = add i64 %0, -1
192 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
193 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
194 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
195 ; PROLOG: loop_header.prol.preheader:
196 ; PROLOG-NEXT: br label %loop_header.prol
197 ; PROLOG: loop_header.prol:
198 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
199 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
200 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting_bb1.prol
201 ; PROLOG: loop_exiting_bb1.prol:
202 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.prol, label %exit1.loopexit1
203 ; PROLOG: loop_exiting_bb2.prol:
204 ; PROLOG-NEXT: br i1 false, label %loop_latch.prol, label %exit3.loopexit2
205 ; PROLOG: loop_latch.prol:
206 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
207 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
208 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
209 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
210 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !0
211 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
212 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
213 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
214 ; PROLOG: loop_header.prol.loopexit:
215 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
216 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
217 ; PROLOG-NEXT: br i1 %2, label %exit2.loopexit, label %entry.new
219 ; PROLOG-NEXT: br label %loop_header
220 ; PROLOG: loop_header:
221 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
222 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
223 ; PROLOG: loop_exiting_bb1:
224 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
225 ; PROLOG: loop_exiting_bb2:
226 ; PROLOG-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
227 ; PROLOG: exit3.loopexit:
228 ; PROLOG-NEXT: br label %exit3
229 ; PROLOG: exit3.loopexit2:
230 ; PROLOG-NEXT: br label %exit3
232 ; PROLOG-NEXT: ret void
233 ; PROLOG: loop_latch:
234 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
235 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
236 ; PROLOG: loop_exiting_bb1.1:
237 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
238 ; PROLOG: loop_exiting_bb2.1:
239 ; PROLOG-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
240 ; PROLOG: loop_latch.1:
241 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
242 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting_bb1.2
243 ; PROLOG: loop_exiting_bb1.2:
244 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.2, label %exit1.loopexit
245 ; PROLOG: loop_exiting_bb2.2:
246 ; PROLOG-NEXT: br i1 false, label %loop_latch.2, label %exit3.loopexit
247 ; PROLOG: loop_latch.2:
248 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
249 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting_bb1.3
250 ; PROLOG: loop_exiting_bb1.3:
251 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.3, label %exit1.loopexit
252 ; PROLOG: loop_exiting_bb2.3:
253 ; PROLOG-NEXT: br i1 false, label %loop_latch.3, label %exit3.loopexit
254 ; PROLOG: loop_latch.3:
255 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
256 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting_bb1.4
257 ; PROLOG: loop_exiting_bb1.4:
258 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.4, label %exit1.loopexit
259 ; PROLOG: loop_exiting_bb2.4:
260 ; PROLOG-NEXT: br i1 false, label %loop_latch.4, label %exit3.loopexit
261 ; PROLOG: loop_latch.4:
262 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
263 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting_bb1.5
264 ; PROLOG: loop_exiting_bb1.5:
265 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.5, label %exit1.loopexit
266 ; PROLOG: loop_exiting_bb2.5:
267 ; PROLOG-NEXT: br i1 false, label %loop_latch.5, label %exit3.loopexit
268 ; PROLOG: loop_latch.5:
269 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
270 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting_bb1.6
271 ; PROLOG: loop_exiting_bb1.6:
272 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.6, label %exit1.loopexit
273 ; PROLOG: loop_exiting_bb2.6:
274 ; PROLOG-NEXT: br i1 false, label %loop_latch.6, label %exit3.loopexit
275 ; PROLOG: loop_latch.6:
276 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
277 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting_bb1.7
278 ; PROLOG: loop_exiting_bb1.7:
279 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.7, label %exit1.loopexit
280 ; PROLOG: loop_exiting_bb2.7:
281 ; PROLOG-NEXT: br i1 false, label %loop_latch.7, label %exit3.loopexit
282 ; PROLOG: loop_latch.7:
283 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
284 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
285 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa
286 ; PROLOG: exit1.loopexit:
287 ; PROLOG-NEXT: br label %exit1
288 ; PROLOG: exit1.loopexit1:
289 ; PROLOG-NEXT: br label %exit1
291 ; PROLOG-NEXT: ret void
292 ; PROLOG: exit2.loopexit.unr-lcssa:
293 ; PROLOG-NEXT: br label %exit2.loopexit
294 ; PROLOG: exit2.loopexit:
295 ; PROLOG-NEXT: ret void
297 ; PROLOG-BLOCK-LABEL: @test1(
298 ; PROLOG-BLOCK-NEXT: entry:
299 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
300 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
301 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
302 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
303 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
304 ; PROLOG-BLOCK: loop_header.prol.preheader:
305 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
306 ; PROLOG-BLOCK: loop_header.prol:
307 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting_bb1.prol
308 ; PROLOG-BLOCK: loop_exiting_bb1.prol:
309 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.prol, label %exit1
310 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
311 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_latch.prol, label %exit3
312 ; PROLOG-BLOCK: loop_latch.prol:
313 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
314 ; PROLOG-BLOCK: loop_header.prol.loopexit:
315 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
316 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
317 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit2.loopexit, label %entry.new
318 ; PROLOG-BLOCK: entry.new:
319 ; PROLOG-BLOCK-NEXT: br label %loop_header
320 ; PROLOG-BLOCK: loop_header:
321 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
322 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
323 ; PROLOG-BLOCK: loop_exiting_bb1:
324 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
325 ; PROLOG-BLOCK: loop_exiting_bb2:
326 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
327 ; PROLOG-BLOCK: exit3.loopexit:
328 ; PROLOG-BLOCK-NEXT: br label %exit3
329 ; PROLOG-BLOCK: exit3:
330 ; PROLOG-BLOCK-NEXT: ret void
331 ; PROLOG-BLOCK: loop_latch:
332 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
333 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
334 ; PROLOG-BLOCK: loop_exiting_bb1.1:
335 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
336 ; PROLOG-BLOCK: loop_exiting_bb2.1:
337 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
338 ; PROLOG-BLOCK: loop_latch.1:
339 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
340 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
341 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa, !llvm.loop !0
342 ; PROLOG-BLOCK: exit1.loopexit:
343 ; PROLOG-BLOCK-NEXT: br label %exit1
344 ; PROLOG-BLOCK: exit1:
345 ; PROLOG-BLOCK-NEXT: ret void
346 ; PROLOG-BLOCK: exit2.loopexit.unr-lcssa:
347 ; PROLOG-BLOCK-NEXT: br label %exit2.loopexit
348 ; PROLOG-BLOCK: exit2.loopexit:
349 ; PROLOG-BLOCK-NEXT: ret void
353 br label %loop_header
356 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
357 br i1 %cond, label %loop_latch, label %loop_exiting_bb1
360 br i1 false, label %loop_exiting_bb2, label %exit1
363 br i1 false, label %loop_latch, label %exit3
369 %iv_next = add i64 %iv, 1
370 %cmp = icmp ne i64 %iv_next, %trip
371 br i1 %cmp, label %loop_header, label %exit2.loopexit
381 ; test with three exiting and two exit blocks.
382 ; The non-latch exit block has 2 unique predecessors.
383 ; There are 2 values passed to the exit blocks that are calculated at every iteration.
384 ; %sum.02 and %add. Both of these are incoming values for phi from every exiting
386 define i32 @test2(i32* nocapture %a, i64 %n) {
387 ; EPILOG-LABEL: @test2(
388 ; EPILOG-NEXT: entry:
389 ; EPILOG-NEXT: %0 = freeze i64 %n
390 ; EPILOG-NEXT: %1 = add i64 %0, -1
391 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
392 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
393 ; EPILOG-NEXT: br i1 %2, label %for.end.unr-lcssa, label %entry.new
395 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
396 ; EPILOG-NEXT: br label %header
398 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %for.body.7 ]
399 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %for.body.7 ]
400 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %for.body.7 ]
401 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
402 ; EPILOG: for.exiting_block:
403 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
404 ; EPILOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
406 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
407 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
408 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
409 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
410 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
411 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
412 ; EPILOG: for.exiting_block.1:
413 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
414 ; EPILOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
415 ; EPILOG: for.body.1:
416 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
417 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
418 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
419 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
420 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
421 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
422 ; EPILOG: for.exiting_block.2:
423 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
424 ; EPILOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %for.body.2
425 ; EPILOG: for.body.2:
426 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
427 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
428 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
429 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
430 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
431 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
432 ; EPILOG: for.exiting_block.3:
433 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
434 ; EPILOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %for.body.3
435 ; EPILOG: for.body.3:
436 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
437 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
438 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
439 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
440 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
441 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
442 ; EPILOG: for.exiting_block.4:
443 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
444 ; EPILOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %for.body.4
445 ; EPILOG: for.body.4:
446 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
447 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
448 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
449 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
450 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
451 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
452 ; EPILOG: for.exiting_block.5:
453 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
454 ; EPILOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %for.body.5
455 ; EPILOG: for.body.5:
456 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
457 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
458 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
459 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
460 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
461 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
462 ; EPILOG: for.exiting_block.6:
463 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
464 ; EPILOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %for.body.6
465 ; EPILOG: for.body.6:
466 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
467 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
468 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
469 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
470 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
471 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
472 ; EPILOG: for.exiting_block.7:
473 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
474 ; EPILOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %for.body.7
475 ; EPILOG: for.body.7:
476 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
477 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
478 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
479 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
480 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
481 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
482 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %for.end.unr-lcssa.loopexit, label %header
483 ; EPILOG: for.end.unr-lcssa.loopexit:
484 ; EPILOG-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.7, %for.body.7 ]
485 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %for.body.7 ]
486 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %for.body.7 ]
487 ; EPILOG-NEXT: br label %for.end.unr-lcssa
488 ; EPILOG: for.end.unr-lcssa:
489 ; EPILOG-NEXT: %sum.0.lcssa.ph = phi i32 [ undef, %entry ], [ %sum.0.lcssa.ph.ph, %for.end.unr-lcssa.loopexit ]
490 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %for.end.unr-lcssa.loopexit ]
491 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %for.end.unr-lcssa.loopexit ]
492 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
493 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %for.end
494 ; EPILOG: header.epil.preheader:
495 ; EPILOG-NEXT: br label %header.epil
496 ; EPILOG: header.epil:
497 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %for.body.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
498 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %for.body.epil ], [ %sum.02.unr, %header.epil.preheader ]
499 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %for.body.epil ]
500 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit2, label %for.exiting_block.epil
501 ; EPILOG: for.exiting_block.epil:
502 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
503 ; EPILOG-NEXT: br i1 %cmp.epil, label %for.exit2.loopexit2, label %for.body.epil
504 ; EPILOG: for.body.epil:
505 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
506 ; EPILOG-NEXT: %11 = load i32, i32* %arrayidx.epil, align 4
507 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
508 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
509 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
510 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
511 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
512 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %for.end.epilog-lcssa, !llvm.loop !2
513 ; EPILOG: for.end.epilog-lcssa:
514 ; EPILOG-NEXT: %sum.0.lcssa.ph1 = phi i32 [ %add.epil, %for.body.epil ]
515 ; EPILOG-NEXT: br label %for.end
517 ; EPILOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %for.end.unr-lcssa ], [ %sum.0.lcssa.ph1, %for.end.epilog-lcssa ]
518 ; EPILOG-NEXT: ret i32 %sum.0.lcssa
519 ; EPILOG: for.exit2.loopexit:
520 ; 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 ]
521 ; EPILOG-NEXT: br label %for.exit2
522 ; EPILOG: for.exit2.loopexit2:
523 ; EPILOG-NEXT: %retval.ph3 = phi i32 [ 42, %for.exiting_block.epil ], [ %sum.02.epil, %header.epil ]
524 ; EPILOG-NEXT: br label %for.exit2
526 ; EPILOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph3, %for.exit2.loopexit2 ]
527 ; EPILOG-NEXT: ret i32 %retval
529 ; EPILOG-BLOCK-LABEL: @test2(
530 ; EPILOG-BLOCK-NEXT: entry:
531 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
532 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
533 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
534 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
535 ; EPILOG-BLOCK-NEXT: br i1 %2, label %for.end.unr-lcssa, label %entry.new
536 ; EPILOG-BLOCK: entry.new:
537 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
538 ; EPILOG-BLOCK-NEXT: br label %header
539 ; EPILOG-BLOCK: header:
540 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %for.body.1 ]
541 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %for.body.1 ]
542 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %for.body.1 ]
543 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
544 ; EPILOG-BLOCK: for.exiting_block:
545 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
546 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
547 ; EPILOG-BLOCK: for.body:
548 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
549 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
550 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
551 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
552 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
553 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
554 ; EPILOG-BLOCK: for.exiting_block.1:
555 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
556 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
557 ; EPILOG-BLOCK: for.body.1:
558 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
559 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
560 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
561 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
562 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
563 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
564 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %for.end.unr-lcssa.loopexit, label %header, !llvm.loop !2
565 ; EPILOG-BLOCK: for.end.unr-lcssa.loopexit:
566 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.1, %for.body.1 ]
567 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %for.body.1 ]
568 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %for.body.1 ]
569 ; EPILOG-BLOCK-NEXT: br label %for.end.unr-lcssa
570 ; EPILOG-BLOCK: for.end.unr-lcssa:
571 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ undef, %entry ], [ %sum.0.lcssa.ph.ph, %for.end.unr-lcssa.loopexit ]
572 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %for.end.unr-lcssa.loopexit ]
573 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %for.end.unr-lcssa.loopexit ]
574 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
575 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %for.end
576 ; EPILOG-BLOCK: header.epil.preheader:
577 ; EPILOG-BLOCK-NEXT: br label %header.epil
578 ; EPILOG-BLOCK: header.epil:
579 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.epil
580 ; EPILOG-BLOCK: for.exiting_block.epil:
581 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
582 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %for.exit2, label %for.body.epil
583 ; EPILOG-BLOCK: for.body.epil:
584 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
585 ; EPILOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.epil, align 4
586 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
587 ; EPILOG-BLOCK-NEXT: br label %for.end
588 ; EPILOG-BLOCK: for.end:
589 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %for.end.unr-lcssa ], [ %add.epil, %for.body.epil ]
590 ; EPILOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
591 ; EPILOG-BLOCK: for.exit2.loopexit:
592 ; EPILOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %for.body ], [ 42, %for.exiting_block.1 ]
593 ; EPILOG-BLOCK-NEXT: br label %for.exit2
594 ; EPILOG-BLOCK: for.exit2:
595 ; EPILOG-BLOCK-NEXT: %retval = phi i32 [ %sum.02.unr, %header.epil ], [ 42, %for.exiting_block.epil ], [ %retval.ph, %for.exit2.loopexit ]
596 ; EPILOG-BLOCK-NEXT: ret i32 %retval
598 ; PROLOG-LABEL: @test2(
599 ; PROLOG-NEXT: entry:
600 ; PROLOG-NEXT: %0 = freeze i64 %n
601 ; PROLOG-NEXT: %1 = add i64 %0, -1
602 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
603 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
604 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
605 ; PROLOG: header.prol.preheader:
606 ; PROLOG-NEXT: br label %header.prol
607 ; PROLOG: header.prol:
608 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %for.body.prol ], [ 0, %header.prol.preheader ]
609 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %for.body.prol ], [ 0, %header.prol.preheader ]
610 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %for.body.prol ]
611 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit1, label %for.exiting_block.prol
612 ; PROLOG: for.exiting_block.prol:
613 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
614 ; PROLOG-NEXT: br i1 %cmp.prol, label %for.exit2.loopexit1, label %for.body.prol
615 ; PROLOG: for.body.prol:
616 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
617 ; PROLOG-NEXT: %2 = load i32, i32* %arrayidx.prol, align 4
618 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
619 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
620 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
621 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
622 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
623 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !2
624 ; PROLOG: header.prol.loopexit.unr-lcssa:
625 ; PROLOG-NEXT: %sum.0.lcssa.unr.ph = phi i32 [ %add.prol, %for.body.prol ]
626 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %for.body.prol ]
627 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %for.body.prol ]
628 ; PROLOG-NEXT: br label %header.prol.loopexit
629 ; PROLOG: header.prol.loopexit:
630 ; PROLOG-NEXT: %sum.0.lcssa.unr = phi i32 [ undef, %entry ], [ %sum.0.lcssa.unr.ph, %header.prol.loopexit.unr-lcssa ]
631 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
632 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
633 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
634 ; PROLOG-NEXT: br i1 %3, label %for.end, label %entry.new
636 ; PROLOG-NEXT: br label %header
638 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %for.body.7 ]
639 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %for.body.7 ]
640 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
641 ; PROLOG: for.exiting_block:
642 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
643 ; PROLOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
645 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
646 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx, align 4
647 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
648 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
649 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
650 ; PROLOG: for.exiting_block.1:
651 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
652 ; PROLOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
653 ; PROLOG: for.body.1:
654 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
655 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
656 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
657 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
658 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
659 ; PROLOG: for.exiting_block.2:
660 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
661 ; PROLOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %for.body.2
662 ; PROLOG: for.body.2:
663 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
664 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.2, align 4
665 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
666 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
667 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
668 ; PROLOG: for.exiting_block.3:
669 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
670 ; PROLOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %for.body.3
671 ; PROLOG: for.body.3:
672 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
673 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.3, align 4
674 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
675 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
676 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
677 ; PROLOG: for.exiting_block.4:
678 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
679 ; PROLOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %for.body.4
680 ; PROLOG: for.body.4:
681 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
682 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.4, align 4
683 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
684 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
685 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
686 ; PROLOG: for.exiting_block.5:
687 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
688 ; PROLOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %for.body.5
689 ; PROLOG: for.body.5:
690 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
691 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.5, align 4
692 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
693 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
694 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
695 ; PROLOG: for.exiting_block.6:
696 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
697 ; PROLOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %for.body.6
698 ; PROLOG: for.body.6:
699 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
700 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.6, align 4
701 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
702 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
703 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
704 ; PROLOG: for.exiting_block.7:
705 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
706 ; PROLOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %for.body.7
707 ; PROLOG: for.body.7:
708 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
709 ; PROLOG-NEXT: %11 = load i32, i32* %arrayidx.7, align 4
710 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
711 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
712 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
713 ; PROLOG-NEXT: br i1 %exitcond.7, label %for.end.unr-lcssa, label %header
714 ; PROLOG: for.end.unr-lcssa:
715 ; PROLOG-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.7, %for.body.7 ]
716 ; PROLOG-NEXT: br label %for.end
718 ; PROLOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %for.end.unr-lcssa ]
719 ; PROLOG-NEXT: ret i32 %sum.0.lcssa
720 ; PROLOG: for.exit2.loopexit:
721 ; 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 ]
722 ; PROLOG-NEXT: br label %for.exit2
723 ; PROLOG: for.exit2.loopexit1:
724 ; PROLOG-NEXT: %retval.ph2 = phi i32 [ 42, %for.exiting_block.prol ], [ %sum.02.prol, %header.prol ]
725 ; PROLOG-NEXT: br label %for.exit2
727 ; PROLOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph2, %for.exit2.loopexit1 ]
728 ; PROLOG-NEXT: ret i32 %retval
730 ; PROLOG-BLOCK-LABEL: @test2(
731 ; PROLOG-BLOCK-NEXT: entry:
732 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
733 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
734 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
735 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
736 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
737 ; PROLOG-BLOCK: header.prol.preheader:
738 ; PROLOG-BLOCK-NEXT: br label %header.prol
739 ; PROLOG-BLOCK: header.prol:
740 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.prol
741 ; PROLOG-BLOCK: for.exiting_block.prol:
742 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
743 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %for.exit2, label %for.body.prol
744 ; PROLOG-BLOCK: for.body.prol:
745 ; PROLOG-BLOCK-NEXT: %2 = load i32, i32* %a, align 4
746 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
747 ; PROLOG-BLOCK: header.prol.loopexit:
748 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.unr = phi i32 [ undef, %entry ], [ %2, %for.body.prol ]
749 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %for.body.prol ]
750 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %for.body.prol ]
751 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
752 ; PROLOG-BLOCK-NEXT: br i1 %3, label %for.end, label %entry.new
753 ; PROLOG-BLOCK: entry.new:
754 ; PROLOG-BLOCK-NEXT: br label %header
755 ; PROLOG-BLOCK: header:
756 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %for.body.1 ]
757 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %for.body.1 ]
758 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
759 ; PROLOG-BLOCK: for.exiting_block:
760 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
761 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
762 ; PROLOG-BLOCK: for.body:
763 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
764 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx, align 4
765 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
766 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
767 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
768 ; PROLOG-BLOCK: for.exiting_block.1:
769 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
770 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
771 ; PROLOG-BLOCK: for.body.1:
772 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
773 ; PROLOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
774 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
775 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
776 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
777 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %for.end.unr-lcssa, label %header, !llvm.loop !2
778 ; PROLOG-BLOCK: for.end.unr-lcssa:
779 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.1, %for.body.1 ]
780 ; PROLOG-BLOCK-NEXT: br label %for.end
781 ; PROLOG-BLOCK: for.end:
782 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %for.end.unr-lcssa ]
783 ; PROLOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
784 ; PROLOG-BLOCK: for.exit2.loopexit:
785 ; PROLOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %for.body ], [ 42, %for.exiting_block.1 ]
786 ; PROLOG-BLOCK-NEXT: br label %for.exit2
787 ; PROLOG-BLOCK: for.exit2:
788 ; PROLOG-BLOCK-NEXT: %retval = phi i32 [ 0, %header.prol ], [ 42, %for.exiting_block.prol ], [ %retval.ph, %for.exit2.loopexit ]
789 ; PROLOG-BLOCK-NEXT: ret i32 %retval
797 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
798 %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
799 br i1 false, label %for.exit2, label %for.exiting_block
802 %cmp = icmp eq i64 %n, 42
803 br i1 %cmp, label %for.exit2, label %for.body
806 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
807 %0 = load i32, i32* %arrayidx, align 4
808 %add = add nsw i32 %0, %sum.02
809 %indvars.iv.next = add i64 %indvars.iv, 1
810 %exitcond = icmp eq i64 %indvars.iv.next, %n
811 br i1 %exitcond, label %for.end, label %header
813 for.end: ; preds = %for.body
814 %sum.0.lcssa = phi i32 [ %add, %for.body ]
818 %retval = phi i32 [ %sum.02, %header ], [ 42, %for.exiting_block ]
822 ; test with two exiting and three exit blocks.
823 ; the non-latch exiting block has a switch.
824 define void @test3(i64 %trip, i64 %add) {
825 ; EPILOG-LABEL: @test3(
826 ; EPILOG-NEXT: entry:
827 ; EPILOG-NEXT: %0 = freeze i64 %trip
828 ; EPILOG-NEXT: %1 = add i64 %0, -1
829 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
830 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
831 ; EPILOG-NEXT: br i1 %2, label %exit2.loopexit.unr-lcssa, label %entry.new
833 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
834 ; EPILOG-NEXT: br label %loop_header
835 ; EPILOG: loop_header:
836 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
837 ; EPILOG-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
838 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
839 ; EPILOG-NEXT: br i1 undef, label %loop_latch, label %loop_exiting_bb1
840 ; EPILOG: loop_exiting_bb1:
841 ; EPILOG-NEXT: switch i64 %sum, label %loop_latch [
842 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
843 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
845 ; EPILOG: exit3.loopexit:
846 ; EPILOG-NEXT: br label %exit3
847 ; EPILOG: exit3.loopexit2:
848 ; EPILOG-NEXT: br label %exit3
850 ; EPILOG-NEXT: ret void
851 ; EPILOG: loop_latch:
852 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
853 ; EPILOG-NEXT: %sum.next = add i64 %sum, %add
854 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
855 ; EPILOG-NEXT: br i1 undef, label %loop_latch.1, label %loop_exiting_bb1.1
856 ; EPILOG: loop_exiting_bb1.1:
857 ; EPILOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
858 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
859 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
861 ; EPILOG: loop_latch.1:
862 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
863 ; EPILOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
864 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
865 ; EPILOG-NEXT: br i1 undef, label %loop_latch.2, label %loop_exiting_bb1.2
866 ; EPILOG: loop_exiting_bb1.2:
867 ; EPILOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
868 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
869 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
871 ; EPILOG: loop_latch.2:
872 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
873 ; EPILOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
874 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
875 ; EPILOG-NEXT: br i1 undef, label %loop_latch.3, label %loop_exiting_bb1.3
876 ; EPILOG: loop_exiting_bb1.3:
877 ; EPILOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
878 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
879 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
881 ; EPILOG: loop_latch.3:
882 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
883 ; EPILOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
884 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
885 ; EPILOG-NEXT: br i1 undef, label %loop_latch.4, label %loop_exiting_bb1.4
886 ; EPILOG: loop_exiting_bb1.4:
887 ; EPILOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
888 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
889 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
891 ; EPILOG: loop_latch.4:
892 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
893 ; EPILOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
894 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
895 ; EPILOG-NEXT: br i1 undef, label %loop_latch.5, label %loop_exiting_bb1.5
896 ; EPILOG: loop_exiting_bb1.5:
897 ; EPILOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
898 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
899 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
901 ; EPILOG: loop_latch.5:
902 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
903 ; EPILOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
904 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
905 ; EPILOG-NEXT: br i1 undef, label %loop_latch.6, label %loop_exiting_bb1.6
906 ; EPILOG: loop_exiting_bb1.6:
907 ; EPILOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
908 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
909 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
911 ; EPILOG: loop_latch.6:
912 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
913 ; EPILOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
914 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
915 ; EPILOG-NEXT: br i1 undef, label %loop_latch.7, label %loop_exiting_bb1.7
916 ; EPILOG: loop_exiting_bb1.7:
917 ; EPILOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
918 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
919 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
921 ; EPILOG: loop_latch.7:
922 ; EPILOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv_next.6, 1
923 ; EPILOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
924 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
925 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
926 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit
927 ; EPILOG: exit1.loopexit:
928 ; EPILOG-NEXT: br label %exit1
929 ; EPILOG: exit1.loopexit1:
930 ; EPILOG-NEXT: br label %exit1
932 ; EPILOG-NEXT: ret void
933 ; EPILOG: exit2.loopexit.unr-lcssa.loopexit:
934 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
935 ; EPILOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
936 ; EPILOG-NEXT: br label %exit2.loopexit.unr-lcssa
937 ; EPILOG: exit2.loopexit.unr-lcssa:
938 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
939 ; EPILOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
940 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
941 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
942 ; EPILOG: loop_header.epil.preheader:
943 ; EPILOG-NEXT: br label %loop_header.epil
944 ; EPILOG: loop_header.epil:
945 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
946 ; EPILOG-NEXT: %sum.epil = phi i64 [ %sum.unr, %loop_header.epil.preheader ], [ %sum.next.epil, %loop_latch.epil ]
947 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
948 ; EPILOG-NEXT: br i1 undef, label %loop_latch.epil, label %loop_exiting_bb1.epil
949 ; EPILOG: loop_exiting_bb1.epil:
950 ; EPILOG-NEXT: switch i64 %sum.epil, label %loop_latch.epil [
951 ; EPILOG-NEXT: i64 24, label %exit1.loopexit1
952 ; EPILOG-NEXT: i64 42, label %exit3.loopexit2
954 ; EPILOG: loop_latch.epil:
955 ; EPILOG-NEXT: %iv_next.epil = add nuw nsw i64 %iv.epil, 1
956 ; EPILOG-NEXT: %sum.next.epil = add i64 %sum.epil, %add
957 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
958 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
959 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
960 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.loopexit.epilog-lcssa, !llvm.loop !3
961 ; EPILOG: exit2.loopexit.epilog-lcssa:
962 ; EPILOG-NEXT: br label %exit2.loopexit
963 ; EPILOG: exit2.loopexit:
964 ; EPILOG-NEXT: ret void
966 ; EPILOG-BLOCK-LABEL: @test3(
967 ; EPILOG-BLOCK-NEXT: entry:
968 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
969 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
970 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
971 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
972 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit2.loopexit.unr-lcssa, label %entry.new
973 ; EPILOG-BLOCK: entry.new:
974 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
975 ; EPILOG-BLOCK-NEXT: br label %loop_header
976 ; EPILOG-BLOCK: loop_header:
977 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
978 ; EPILOG-BLOCK-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
979 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
980 ; EPILOG-BLOCK-NEXT: br i1 undef, label %loop_latch, label %loop_exiting_bb1
981 ; EPILOG-BLOCK: loop_exiting_bb1:
982 ; EPILOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
983 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
984 ; EPILOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
985 ; EPILOG-BLOCK-NEXT: ]
986 ; EPILOG-BLOCK: exit3.loopexit:
987 ; EPILOG-BLOCK-NEXT: br label %exit3
988 ; EPILOG-BLOCK: exit3:
989 ; EPILOG-BLOCK-NEXT: ret void
990 ; EPILOG-BLOCK: loop_latch:
991 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
992 ; EPILOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
993 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
994 ; EPILOG-BLOCK-NEXT: br i1 undef, label %loop_latch.1, label %loop_exiting_bb1.1
995 ; EPILOG-BLOCK: loop_exiting_bb1.1:
996 ; EPILOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
997 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
998 ; EPILOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
999 ; EPILOG-BLOCK-NEXT: ]
1000 ; EPILOG-BLOCK: loop_latch.1:
1001 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
1002 ; EPILOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
1003 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
1004 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
1005 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit, !llvm.loop !3
1006 ; EPILOG-BLOCK: exit1.loopexit:
1007 ; EPILOG-BLOCK-NEXT: br label %exit1
1008 ; EPILOG-BLOCK: exit1:
1009 ; EPILOG-BLOCK-NEXT: ret void
1010 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa.loopexit:
1011 ; EPILOG-BLOCK-NEXT: %sum.unr.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
1012 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit.unr-lcssa
1013 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa:
1014 ; EPILOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
1015 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1016 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
1017 ; EPILOG-BLOCK: loop_header.epil.preheader:
1018 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
1019 ; EPILOG-BLOCK: loop_header.epil:
1020 ; EPILOG-BLOCK-NEXT: br i1 undef, label %loop_latch.epil, label %loop_exiting_bb1.epil
1021 ; EPILOG-BLOCK: loop_exiting_bb1.epil:
1022 ; EPILOG-BLOCK-NEXT: switch i64 %sum.unr, label %loop_latch.epil [
1023 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1
1024 ; EPILOG-BLOCK-NEXT: i64 42, label %exit3
1025 ; EPILOG-BLOCK-NEXT: ]
1026 ; EPILOG-BLOCK: loop_latch.epil:
1027 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit
1028 ; EPILOG-BLOCK: exit2.loopexit:
1029 ; EPILOG-BLOCK-NEXT: ret void
1031 ; PROLOG-LABEL: @test3(
1032 ; PROLOG-NEXT: entry:
1033 ; PROLOG-NEXT: %0 = freeze i64 %trip
1034 ; PROLOG-NEXT: %1 = add i64 %0, -1
1035 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
1036 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1037 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
1038 ; PROLOG: loop_header.prol.preheader:
1039 ; PROLOG-NEXT: br label %loop_header.prol
1040 ; PROLOG: loop_header.prol:
1041 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
1042 ; PROLOG-NEXT: %sum.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %sum.next.prol, %loop_latch.prol ]
1043 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
1044 ; PROLOG-NEXT: br i1 undef, label %loop_latch.prol, label %loop_exiting_bb1.prol
1045 ; PROLOG: loop_exiting_bb1.prol:
1046 ; PROLOG-NEXT: switch i64 %sum.prol, label %loop_latch.prol [
1047 ; PROLOG-NEXT: i64 24, label %exit1.loopexit1
1048 ; PROLOG-NEXT: i64 42, label %exit3.loopexit2
1050 ; PROLOG: loop_latch.prol:
1051 ; PROLOG-NEXT: %iv_next.prol = add nuw nsw i64 %iv.prol, 1
1052 ; PROLOG-NEXT: %sum.next.prol = add i64 %sum.prol, %add
1053 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
1054 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
1055 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
1056 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !3
1057 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
1058 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
1059 ; PROLOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.prol, %loop_latch.prol ]
1060 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
1061 ; PROLOG: loop_header.prol.loopexit:
1062 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
1063 ; PROLOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
1064 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
1065 ; PROLOG-NEXT: br i1 %2, label %exit2.loopexit, label %entry.new
1066 ; PROLOG: entry.new:
1067 ; PROLOG-NEXT: br label %loop_header
1068 ; PROLOG: loop_header:
1069 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
1070 ; PROLOG-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
1071 ; PROLOG-NEXT: br i1 undef, label %loop_latch, label %loop_exiting_bb1
1072 ; PROLOG: loop_exiting_bb1:
1073 ; PROLOG-NEXT: switch i64 %sum, label %loop_latch [
1074 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1075 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1077 ; PROLOG: exit3.loopexit:
1078 ; PROLOG-NEXT: br label %exit3
1079 ; PROLOG: exit3.loopexit2:
1080 ; PROLOG-NEXT: br label %exit3
1082 ; PROLOG-NEXT: ret void
1083 ; PROLOG: loop_latch:
1084 ; PROLOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
1085 ; PROLOG-NEXT: %sum.next = add i64 %sum, %add
1086 ; PROLOG-NEXT: br i1 undef, label %loop_latch.1, label %loop_exiting_bb1.1
1087 ; PROLOG: loop_exiting_bb1.1:
1088 ; PROLOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
1089 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1090 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1092 ; PROLOG: loop_latch.1:
1093 ; PROLOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
1094 ; PROLOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
1095 ; PROLOG-NEXT: br i1 undef, label %loop_latch.2, label %loop_exiting_bb1.2
1096 ; PROLOG: loop_exiting_bb1.2:
1097 ; PROLOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
1098 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1099 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1101 ; PROLOG: loop_latch.2:
1102 ; PROLOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
1103 ; PROLOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
1104 ; PROLOG-NEXT: br i1 undef, label %loop_latch.3, label %loop_exiting_bb1.3
1105 ; PROLOG: loop_exiting_bb1.3:
1106 ; PROLOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
1107 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1108 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1110 ; PROLOG: loop_latch.3:
1111 ; PROLOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
1112 ; PROLOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
1113 ; PROLOG-NEXT: br i1 undef, label %loop_latch.4, label %loop_exiting_bb1.4
1114 ; PROLOG: loop_exiting_bb1.4:
1115 ; PROLOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
1116 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1117 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1119 ; PROLOG: loop_latch.4:
1120 ; PROLOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
1121 ; PROLOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
1122 ; PROLOG-NEXT: br i1 undef, label %loop_latch.5, label %loop_exiting_bb1.5
1123 ; PROLOG: loop_exiting_bb1.5:
1124 ; PROLOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
1125 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1126 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1128 ; PROLOG: loop_latch.5:
1129 ; PROLOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
1130 ; PROLOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
1131 ; PROLOG-NEXT: br i1 undef, label %loop_latch.6, label %loop_exiting_bb1.6
1132 ; PROLOG: loop_exiting_bb1.6:
1133 ; PROLOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
1134 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1135 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1137 ; PROLOG: loop_latch.6:
1138 ; PROLOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
1139 ; PROLOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
1140 ; PROLOG-NEXT: br i1 undef, label %loop_latch.7, label %loop_exiting_bb1.7
1141 ; PROLOG: loop_exiting_bb1.7:
1142 ; PROLOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
1143 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1144 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1146 ; PROLOG: loop_latch.7:
1147 ; PROLOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv_next.6, 1
1148 ; PROLOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
1149 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
1150 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa
1151 ; PROLOG: exit1.loopexit:
1152 ; PROLOG-NEXT: br label %exit1
1153 ; PROLOG: exit1.loopexit1:
1154 ; PROLOG-NEXT: br label %exit1
1156 ; PROLOG-NEXT: ret void
1157 ; PROLOG: exit2.loopexit.unr-lcssa:
1158 ; PROLOG-NEXT: br label %exit2.loopexit
1159 ; PROLOG: exit2.loopexit:
1160 ; PROLOG-NEXT: ret void
1162 ; PROLOG-BLOCK-LABEL: @test3(
1163 ; PROLOG-BLOCK-NEXT: entry:
1164 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
1165 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
1166 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
1167 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1168 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
1169 ; PROLOG-BLOCK: loop_header.prol.preheader:
1170 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
1171 ; PROLOG-BLOCK: loop_header.prol:
1172 ; PROLOG-BLOCK-NEXT: br i1 undef, label %loop_latch.prol, label %loop_exiting_bb1.prol
1173 ; PROLOG-BLOCK: loop_exiting_bb1.prol:
1174 ; PROLOG-BLOCK-NEXT: switch i64 0, label %loop_latch.prol [
1175 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1
1176 ; PROLOG-BLOCK-NEXT: i64 42, label %exit3
1177 ; PROLOG-BLOCK-NEXT: ]
1178 ; PROLOG-BLOCK: loop_latch.prol:
1179 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
1180 ; PROLOG-BLOCK: loop_header.prol.loopexit:
1181 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
1182 ; PROLOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %add, %loop_latch.prol ]
1183 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
1184 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit2.loopexit, label %entry.new
1185 ; PROLOG-BLOCK: entry.new:
1186 ; PROLOG-BLOCK-NEXT: br label %loop_header
1187 ; PROLOG-BLOCK: loop_header:
1188 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
1189 ; PROLOG-BLOCK-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
1190 ; PROLOG-BLOCK-NEXT: br i1 undef, label %loop_latch, label %loop_exiting_bb1
1191 ; PROLOG-BLOCK: loop_exiting_bb1:
1192 ; PROLOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
1193 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
1194 ; PROLOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
1195 ; PROLOG-BLOCK-NEXT: ]
1196 ; PROLOG-BLOCK: exit3.loopexit:
1197 ; PROLOG-BLOCK-NEXT: br label %exit3
1198 ; PROLOG-BLOCK: exit3:
1199 ; PROLOG-BLOCK-NEXT: ret void
1200 ; PROLOG-BLOCK: loop_latch:
1201 ; PROLOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
1202 ; PROLOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
1203 ; PROLOG-BLOCK-NEXT: br i1 undef, label %loop_latch.1, label %loop_exiting_bb1.1
1204 ; PROLOG-BLOCK: loop_exiting_bb1.1:
1205 ; PROLOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
1206 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
1207 ; PROLOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
1208 ; PROLOG-BLOCK-NEXT: ]
1209 ; PROLOG-BLOCK: loop_latch.1:
1210 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
1211 ; PROLOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
1212 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
1213 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa, !llvm.loop !3
1214 ; PROLOG-BLOCK: exit1.loopexit:
1215 ; PROLOG-BLOCK-NEXT: br label %exit1
1216 ; PROLOG-BLOCK: exit1:
1217 ; PROLOG-BLOCK-NEXT: ret void
1218 ; PROLOG-BLOCK: exit2.loopexit.unr-lcssa:
1219 ; PROLOG-BLOCK-NEXT: br label %exit2.loopexit
1220 ; PROLOG-BLOCK: exit2.loopexit:
1221 ; PROLOG-BLOCK-NEXT: ret void
1225 br label %loop_header
1228 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
1229 %sum = phi i64 [ 0, %entry ], [ %sum.next, %loop_latch ]
1230 br i1 undef, label %loop_latch, label %loop_exiting_bb1
1233 switch i64 %sum, label %loop_latch [
1234 i64 24, label %exit1
1235 i64 42, label %exit3
1242 %iv_next = add nuw nsw i64 %iv, 1
1243 %sum.next = add i64 %sum, %add
1244 %cmp = icmp ne i64 %iv_next, %trip
1245 br i1 %cmp, label %loop_header, label %exit2.loopexit
1254 ; FIXME: Support multiple exiting blocks to the same latch exit block.
1255 ; Three exiting blocks where header and latch exit to same LatchExit.
1256 define i32 @hdr_latch_same_exit(i32* nocapture %a, i64 %n, i1 %cond) {
1257 ; EPILOG-LABEL: @hdr_latch_same_exit(
1258 ; EPILOG-NEXT: entry:
1259 ; EPILOG-NEXT: %0 = freeze i64 %n
1260 ; EPILOG-NEXT: %1 = add i64 %0, -1
1261 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
1262 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
1263 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
1264 ; EPILOG: entry.new:
1265 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
1266 ; EPILOG-NEXT: br label %header
1268 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1269 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
1270 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
1271 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block
1272 ; EPILOG: for.exiting_block:
1273 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
1274 ; EPILOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1276 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1277 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
1278 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
1279 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1280 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
1281 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.1
1282 ; EPILOG: for.exiting_block.1:
1283 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1284 ; EPILOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1286 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1287 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
1288 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
1289 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
1290 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
1291 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.2
1292 ; EPILOG: for.exiting_block.2:
1293 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1294 ; EPILOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
1296 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
1297 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
1298 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
1299 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
1300 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
1301 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.3
1302 ; EPILOG: for.exiting_block.3:
1303 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1304 ; EPILOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
1306 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
1307 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
1308 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
1309 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
1310 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
1311 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.4
1312 ; EPILOG: for.exiting_block.4:
1313 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1314 ; EPILOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
1316 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
1317 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
1318 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
1319 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
1320 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
1321 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.5
1322 ; EPILOG: for.exiting_block.5:
1323 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1324 ; EPILOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
1326 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
1327 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
1328 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
1329 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
1330 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
1331 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.6
1332 ; EPILOG: for.exiting_block.6:
1333 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1334 ; EPILOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
1336 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
1337 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
1338 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
1339 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
1340 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
1341 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.7
1342 ; EPILOG: for.exiting_block.7:
1343 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1344 ; EPILOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
1346 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
1347 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
1348 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
1349 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
1350 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
1351 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
1352 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
1353 ; EPILOG: latchExit.unr-lcssa.loopexit:
1354 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
1355 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
1356 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
1357 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
1358 ; EPILOG: latchExit.unr-lcssa:
1359 ; EPILOG-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1360 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1361 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1362 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1363 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1364 ; EPILOG: header.epil.preheader:
1365 ; EPILOG-NEXT: br label %header.epil
1366 ; EPILOG: header.epil:
1367 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
1368 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
1369 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
1370 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit2, label %for.exiting_block.epil
1371 ; EPILOG: for.exiting_block.epil:
1372 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
1373 ; EPILOG-NEXT: br i1 %cmp.epil, label %for.exit2.loopexit4, label %latch.epil
1374 ; EPILOG: latch.epil:
1375 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
1376 ; EPILOG-NEXT: %11 = load i32, i32* %arrayidx.epil, align 4
1377 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
1378 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
1379 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
1380 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
1381 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
1382 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit2, !llvm.loop !4
1383 ; EPILOG: latchExit.epilog-lcssa.loopexit:
1384 ; 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 ]
1385 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1386 ; EPILOG: latchExit.epilog-lcssa.loopexit2:
1387 ; EPILOG-NEXT: %result.ph1.ph3 = phi i32 [ 0, %header.epil ], [ %add.epil, %latch.epil ]
1388 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1389 ; EPILOG: latchExit.epilog-lcssa:
1390 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph3, %latchExit.epilog-lcssa.loopexit2 ]
1391 ; EPILOG-NEXT: br label %latchExit
1392 ; EPILOG: latchExit:
1393 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1394 ; EPILOG-NEXT: ret i32 %result
1395 ; EPILOG: for.exit2.loopexit:
1396 ; EPILOG-NEXT: br label %for.exit2
1397 ; EPILOG: for.exit2.loopexit4:
1398 ; EPILOG-NEXT: br label %for.exit2
1399 ; EPILOG: for.exit2:
1400 ; EPILOG-NEXT: ret i32 42
1402 ; EPILOG-BLOCK-LABEL: @hdr_latch_same_exit(
1403 ; EPILOG-BLOCK-NEXT: entry:
1404 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
1405 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
1406 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
1407 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
1408 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
1409 ; EPILOG-BLOCK: entry.new:
1410 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
1411 ; EPILOG-BLOCK-NEXT: br label %header
1412 ; EPILOG-BLOCK: header:
1413 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
1414 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
1415 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
1416 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block
1417 ; EPILOG-BLOCK: for.exiting_block:
1418 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
1419 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1420 ; EPILOG-BLOCK: latch:
1421 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1422 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
1423 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
1424 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1425 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
1426 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.1
1427 ; EPILOG-BLOCK: for.exiting_block.1:
1428 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
1429 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1430 ; EPILOG-BLOCK: latch.1:
1431 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1432 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
1433 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
1434 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1435 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
1436 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
1437 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !4
1438 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
1439 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
1440 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
1441 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
1442 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
1443 ; EPILOG-BLOCK: latchExit.unr-lcssa:
1444 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1445 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1446 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1447 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1448 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1449 ; EPILOG-BLOCK: header.epil.preheader:
1450 ; EPILOG-BLOCK-NEXT: br label %header.epil
1451 ; EPILOG-BLOCK: header.epil:
1452 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %latchExit.epilog-lcssa, label %for.exiting_block.epil
1453 ; EPILOG-BLOCK: for.exiting_block.epil:
1454 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
1455 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %for.exit2, label %latch.epil
1456 ; EPILOG-BLOCK: latch.epil:
1457 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
1458 ; EPILOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.epil, align 4
1459 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
1460 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1461 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
1462 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ 0, %header ], [ 0, %latch ]
1463 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1464 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
1465 ; EPILOG-BLOCK-NEXT: %result.ph1 = phi i32 [ %add.epil, %latch.epil ], [ 0, %header.epil ], [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
1466 ; EPILOG-BLOCK-NEXT: br label %latchExit
1467 ; EPILOG-BLOCK: latchExit:
1468 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1469 ; EPILOG-BLOCK-NEXT: ret i32 %result
1470 ; EPILOG-BLOCK: for.exit2.loopexit:
1471 ; EPILOG-BLOCK-NEXT: br label %for.exit2
1472 ; EPILOG-BLOCK: for.exit2:
1473 ; EPILOG-BLOCK-NEXT: ret i32 42
1475 ; PROLOG-LABEL: @hdr_latch_same_exit(
1476 ; PROLOG-NEXT: entry:
1477 ; PROLOG-NEXT: %0 = freeze i64 %n
1478 ; PROLOG-NEXT: %1 = add i64 %0, -1
1479 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
1480 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1481 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1482 ; PROLOG: header.prol.preheader:
1483 ; PROLOG-NEXT: br label %header.prol
1484 ; PROLOG: header.prol:
1485 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1486 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1487 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
1488 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit1, label %for.exiting_block.prol
1489 ; PROLOG: for.exiting_block.prol:
1490 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
1491 ; PROLOG-NEXT: br i1 %cmp.prol, label %for.exit2.loopexit3, label %latch.prol
1492 ; PROLOG: latch.prol:
1493 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
1494 ; PROLOG-NEXT: %2 = load i32, i32* %arrayidx.prol, align 4
1495 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
1496 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
1497 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
1498 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
1499 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
1500 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !4
1501 ; PROLOG: header.prol.loopexit.unr-lcssa:
1502 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1503 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
1504 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1505 ; PROLOG-NEXT: br label %header.prol.loopexit
1506 ; PROLOG: header.prol.loopexit:
1507 ; PROLOG-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
1508 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
1509 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
1510 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
1511 ; PROLOG-NEXT: br i1 %3, label %latchExit, label %entry.new
1512 ; PROLOG: entry.new:
1513 ; PROLOG-NEXT: br label %header
1515 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1516 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
1517 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block
1518 ; PROLOG: for.exiting_block:
1519 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
1520 ; PROLOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1522 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1523 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx, align 4
1524 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
1525 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
1526 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.1
1527 ; PROLOG: for.exiting_block.1:
1528 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1529 ; PROLOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1531 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1532 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
1533 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
1534 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1535 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.2
1536 ; PROLOG: for.exiting_block.2:
1537 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1538 ; PROLOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
1540 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
1541 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.2, align 4
1542 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
1543 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
1544 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.3
1545 ; PROLOG: for.exiting_block.3:
1546 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1547 ; PROLOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
1549 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
1550 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.3, align 4
1551 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
1552 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
1553 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.4
1554 ; PROLOG: for.exiting_block.4:
1555 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1556 ; PROLOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
1558 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
1559 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.4, align 4
1560 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
1561 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
1562 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.5
1563 ; PROLOG: for.exiting_block.5:
1564 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1565 ; PROLOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
1567 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
1568 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.5, align 4
1569 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
1570 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
1571 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.6
1572 ; PROLOG: for.exiting_block.6:
1573 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1574 ; PROLOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
1576 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
1577 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.6, align 4
1578 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
1579 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
1580 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.7
1581 ; PROLOG: for.exiting_block.7:
1582 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1583 ; PROLOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
1585 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
1586 ; PROLOG-NEXT: %11 = load i32, i32* %arrayidx.7, align 4
1587 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
1588 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
1589 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
1590 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
1591 ; PROLOG: latchExit.unr-lcssa.loopexit:
1592 ; 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 ]
1593 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
1594 ; PROLOG: latchExit.unr-lcssa.loopexit1:
1595 ; PROLOG-NEXT: %result.ph.ph2 = phi i32 [ 0, %header.prol ]
1596 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
1597 ; PROLOG: latchExit.unr-lcssa:
1598 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph2, %latchExit.unr-lcssa.loopexit1 ]
1599 ; PROLOG-NEXT: br label %latchExit
1600 ; PROLOG: latchExit:
1601 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
1602 ; PROLOG-NEXT: ret i32 %result
1603 ; PROLOG: for.exit2.loopexit:
1604 ; PROLOG-NEXT: br label %for.exit2
1605 ; PROLOG: for.exit2.loopexit3:
1606 ; PROLOG-NEXT: br label %for.exit2
1607 ; PROLOG: for.exit2:
1608 ; PROLOG-NEXT: ret i32 42
1610 ; PROLOG-BLOCK-LABEL: @hdr_latch_same_exit(
1611 ; PROLOG-BLOCK-NEXT: entry:
1612 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
1613 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
1614 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
1615 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1616 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1617 ; PROLOG-BLOCK: header.prol.preheader:
1618 ; PROLOG-BLOCK-NEXT: br label %header.prol
1619 ; PROLOG-BLOCK: header.prol:
1620 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %latchExit.unr-lcssa, label %for.exiting_block.prol
1621 ; PROLOG-BLOCK: for.exiting_block.prol:
1622 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
1623 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %for.exit2, label %latch.prol
1624 ; PROLOG-BLOCK: latch.prol:
1625 ; PROLOG-BLOCK-NEXT: %2 = load i32, i32* %a, align 4
1626 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
1627 ; PROLOG-BLOCK: header.prol.loopexit:
1628 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %2, %latch.prol ]
1629 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
1630 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %latch.prol ]
1631 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
1632 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchExit, label %entry.new
1633 ; PROLOG-BLOCK: entry.new:
1634 ; PROLOG-BLOCK-NEXT: br label %header
1635 ; PROLOG-BLOCK: header:
1636 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
1637 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
1638 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block
1639 ; PROLOG-BLOCK: for.exiting_block:
1640 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
1641 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1642 ; PROLOG-BLOCK: latch:
1643 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1644 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx, align 4
1645 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
1646 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
1647 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.1
1648 ; PROLOG-BLOCK: for.exiting_block.1:
1649 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
1650 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1651 ; PROLOG-BLOCK: latch.1:
1652 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1653 ; PROLOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
1654 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
1655 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1656 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
1657 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !4
1658 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
1659 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ 0, %header ], [ 0, %latch ], [ %add.1, %latch.1 ]
1660 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
1661 ; PROLOG-BLOCK: latchExit.unr-lcssa:
1662 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 0, %header.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1663 ; PROLOG-BLOCK-NEXT: br label %latchExit
1664 ; PROLOG-BLOCK: latchExit:
1665 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
1666 ; PROLOG-BLOCK-NEXT: ret i32 %result
1667 ; PROLOG-BLOCK: for.exit2.loopexit:
1668 ; PROLOG-BLOCK-NEXT: br label %for.exit2
1669 ; PROLOG-BLOCK: for.exit2:
1670 ; PROLOG-BLOCK-NEXT: ret i32 42
1677 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
1678 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
1679 br i1 %cond, label %latchExit, label %for.exiting_block
1682 %cmp = icmp eq i64 %n, 42
1683 br i1 %cmp, label %for.exit2, label %latch
1685 latch: ; preds = %latch, %entry
1686 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1687 %0 = load i32, i32* %arrayidx, align 4
1688 %add = add nsw i32 %0, %sum.02
1689 %indvars.iv.next = add i64 %indvars.iv, 1
1690 %exitcond = icmp eq i64 %indvars.iv.next, %n
1691 br i1 %exitcond, label %latchExit, label %header
1693 latchExit: ; preds = %latch, %entry
1694 %result = phi i32 [ 0, %header ], [ %add, %latch ]
1701 ; Two exiting blocks to latch where the exiting blocks are Latch and a
1703 ; FIXME: We should unroll this loop.
1704 define i32 @otherblock_latch_same_exit(i32* nocapture %a, i64 %n, i1 %cond) {
1705 ; EPILOG-LABEL: @otherblock_latch_same_exit(
1706 ; EPILOG-NEXT: entry:
1707 ; EPILOG-NEXT: %0 = freeze i64 %n
1708 ; EPILOG-NEXT: %1 = add i64 %0, -1
1709 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
1710 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
1711 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
1712 ; EPILOG: entry.new:
1713 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
1714 ; EPILOG-NEXT: br label %header
1716 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1717 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
1718 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
1719 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
1720 ; EPILOG: for.exiting_block:
1721 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
1722 ; EPILOG-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
1724 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1725 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
1726 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
1727 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1728 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
1729 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
1730 ; EPILOG: for.exiting_block.1:
1731 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1732 ; EPILOG-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
1734 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1735 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
1736 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
1737 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
1738 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
1739 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
1740 ; EPILOG: for.exiting_block.2:
1741 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1742 ; EPILOG-NEXT: br i1 %cmp.2, label %latchExit.epilog-lcssa.loopexit, label %latch.2
1744 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
1745 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
1746 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
1747 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
1748 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
1749 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
1750 ; EPILOG: for.exiting_block.3:
1751 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1752 ; EPILOG-NEXT: br i1 %cmp.3, label %latchExit.epilog-lcssa.loopexit, label %latch.3
1754 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
1755 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
1756 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
1757 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
1758 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
1759 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
1760 ; EPILOG: for.exiting_block.4:
1761 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1762 ; EPILOG-NEXT: br i1 %cmp.4, label %latchExit.epilog-lcssa.loopexit, label %latch.4
1764 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
1765 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
1766 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
1767 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
1768 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
1769 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
1770 ; EPILOG: for.exiting_block.5:
1771 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1772 ; EPILOG-NEXT: br i1 %cmp.5, label %latchExit.epilog-lcssa.loopexit, label %latch.5
1774 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
1775 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
1776 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
1777 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
1778 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
1779 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
1780 ; EPILOG: for.exiting_block.6:
1781 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1782 ; EPILOG-NEXT: br i1 %cmp.6, label %latchExit.epilog-lcssa.loopexit, label %latch.6
1784 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
1785 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
1786 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
1787 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
1788 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
1789 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
1790 ; EPILOG: for.exiting_block.7:
1791 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1792 ; EPILOG-NEXT: br i1 %cmp.7, label %latchExit.epilog-lcssa.loopexit, label %latch.7
1794 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
1795 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
1796 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
1797 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
1798 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
1799 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
1800 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
1801 ; EPILOG: latchExit.unr-lcssa.loopexit:
1802 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
1803 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
1804 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
1805 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
1806 ; EPILOG: latchExit.unr-lcssa:
1807 ; EPILOG-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1808 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1809 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1810 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1811 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1812 ; EPILOG: header.epil.preheader:
1813 ; EPILOG-NEXT: br label %header.epil
1814 ; EPILOG: header.epil:
1815 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
1816 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
1817 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
1818 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit2, label %for.exiting_block.epil
1819 ; EPILOG: for.exiting_block.epil:
1820 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
1821 ; EPILOG-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa.loopexit3, label %latch.epil
1822 ; EPILOG: latch.epil:
1823 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
1824 ; EPILOG-NEXT: %11 = load i32, i32* %arrayidx.epil, align 4
1825 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
1826 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
1827 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
1828 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
1829 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
1830 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit3, !llvm.loop !5
1831 ; EPILOG: latchExit.epilog-lcssa.loopexit:
1832 ; 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 ]
1833 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1834 ; EPILOG: latchExit.epilog-lcssa.loopexit3:
1835 ; EPILOG-NEXT: %result.ph1.ph4 = phi i32 [ 2, %for.exiting_block.epil ], [ %add.epil, %latch.epil ]
1836 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1837 ; EPILOG: latchExit.epilog-lcssa:
1838 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph4, %latchExit.epilog-lcssa.loopexit3 ]
1839 ; EPILOG-NEXT: br label %latchExit
1840 ; EPILOG: latchExit:
1841 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1842 ; EPILOG-NEXT: ret i32 %result
1843 ; EPILOG: for.exit2.loopexit:
1844 ; EPILOG-NEXT: br label %for.exit2
1845 ; EPILOG: for.exit2.loopexit2:
1846 ; EPILOG-NEXT: br label %for.exit2
1847 ; EPILOG: for.exit2:
1848 ; EPILOG-NEXT: ret i32 42
1850 ; EPILOG-BLOCK-LABEL: @otherblock_latch_same_exit(
1851 ; EPILOG-BLOCK-NEXT: entry:
1852 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
1853 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
1854 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
1855 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
1856 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
1857 ; EPILOG-BLOCK: entry.new:
1858 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
1859 ; EPILOG-BLOCK-NEXT: br label %header
1860 ; EPILOG-BLOCK: header:
1861 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
1862 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
1863 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
1864 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
1865 ; EPILOG-BLOCK: for.exiting_block:
1866 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
1867 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
1868 ; EPILOG-BLOCK: latch:
1869 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1870 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
1871 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
1872 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1873 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
1874 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
1875 ; EPILOG-BLOCK: for.exiting_block.1:
1876 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
1877 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
1878 ; EPILOG-BLOCK: latch.1:
1879 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1880 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
1881 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
1882 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1883 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
1884 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
1885 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !5
1886 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
1887 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
1888 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
1889 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
1890 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
1891 ; EPILOG-BLOCK: latchExit.unr-lcssa:
1892 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1893 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1894 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1895 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1896 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1897 ; EPILOG-BLOCK: header.epil.preheader:
1898 ; EPILOG-BLOCK-NEXT: br label %header.epil
1899 ; EPILOG-BLOCK: header.epil:
1900 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.epil
1901 ; EPILOG-BLOCK: for.exiting_block.epil:
1902 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
1903 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa, label %latch.epil
1904 ; EPILOG-BLOCK: latch.epil:
1905 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
1906 ; EPILOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.epil, align 4
1907 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
1908 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1909 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
1910 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ 2, %for.exiting_block ], [ 2, %for.exiting_block.1 ]
1911 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1912 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
1913 ; EPILOG-BLOCK-NEXT: %result.ph1 = phi i32 [ %add.epil, %latch.epil ], [ 2, %for.exiting_block.epil ], [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
1914 ; EPILOG-BLOCK-NEXT: br label %latchExit
1915 ; EPILOG-BLOCK: latchExit:
1916 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1917 ; EPILOG-BLOCK-NEXT: ret i32 %result
1918 ; EPILOG-BLOCK: for.exit2.loopexit:
1919 ; EPILOG-BLOCK-NEXT: br label %for.exit2
1920 ; EPILOG-BLOCK: for.exit2:
1921 ; EPILOG-BLOCK-NEXT: ret i32 42
1923 ; PROLOG-LABEL: @otherblock_latch_same_exit(
1924 ; PROLOG-NEXT: entry:
1925 ; PROLOG-NEXT: %0 = freeze i64 %n
1926 ; PROLOG-NEXT: %1 = add i64 %0, -1
1927 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
1928 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1929 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1930 ; PROLOG: header.prol.preheader:
1931 ; PROLOG-NEXT: br label %header.prol
1932 ; PROLOG: header.prol:
1933 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1934 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1935 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
1936 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit1, label %for.exiting_block.prol
1937 ; PROLOG: for.exiting_block.prol:
1938 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
1939 ; PROLOG-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa.loopexit2, label %latch.prol
1940 ; PROLOG: latch.prol:
1941 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
1942 ; PROLOG-NEXT: %2 = load i32, i32* %arrayidx.prol, align 4
1943 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
1944 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
1945 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
1946 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
1947 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
1948 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !5
1949 ; PROLOG: header.prol.loopexit.unr-lcssa:
1950 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1951 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
1952 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1953 ; PROLOG-NEXT: br label %header.prol.loopexit
1954 ; PROLOG: header.prol.loopexit:
1955 ; PROLOG-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
1956 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
1957 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
1958 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
1959 ; PROLOG-NEXT: br i1 %3, label %latchExit, label %entry.new
1960 ; PROLOG: entry.new:
1961 ; PROLOG-NEXT: br label %header
1963 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1964 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
1965 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
1966 ; PROLOG: for.exiting_block:
1967 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
1968 ; PROLOG-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
1970 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
1971 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx, align 4
1972 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
1973 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
1974 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
1975 ; PROLOG: for.exiting_block.1:
1976 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1977 ; PROLOG-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
1979 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
1980 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
1981 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
1982 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
1983 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
1984 ; PROLOG: for.exiting_block.2:
1985 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1986 ; PROLOG-NEXT: br i1 %cmp.2, label %latchExit.unr-lcssa.loopexit, label %latch.2
1988 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
1989 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.2, align 4
1990 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
1991 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
1992 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
1993 ; PROLOG: for.exiting_block.3:
1994 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1995 ; PROLOG-NEXT: br i1 %cmp.3, label %latchExit.unr-lcssa.loopexit, label %latch.3
1997 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
1998 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.3, align 4
1999 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
2000 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
2001 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2002 ; PROLOG: for.exiting_block.4:
2003 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2004 ; PROLOG-NEXT: br i1 %cmp.4, label %latchExit.unr-lcssa.loopexit, label %latch.4
2006 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
2007 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.4, align 4
2008 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
2009 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
2010 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2011 ; PROLOG: for.exiting_block.5:
2012 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2013 ; PROLOG-NEXT: br i1 %cmp.5, label %latchExit.unr-lcssa.loopexit, label %latch.5
2015 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
2016 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.5, align 4
2017 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
2018 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
2019 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2020 ; PROLOG: for.exiting_block.6:
2021 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2022 ; PROLOG-NEXT: br i1 %cmp.6, label %latchExit.unr-lcssa.loopexit, label %latch.6
2024 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2025 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.6, align 4
2026 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
2027 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
2028 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2029 ; PROLOG: for.exiting_block.7:
2030 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2031 ; PROLOG-NEXT: br i1 %cmp.7, label %latchExit.unr-lcssa.loopexit, label %latch.7
2033 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2034 ; PROLOG-NEXT: %11 = load i32, i32* %arrayidx.7, align 4
2035 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
2036 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2037 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
2038 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
2039 ; PROLOG: latchExit.unr-lcssa.loopexit:
2040 ; 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 ]
2041 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2042 ; PROLOG: latchExit.unr-lcssa.loopexit2:
2043 ; PROLOG-NEXT: %result.ph.ph3 = phi i32 [ 2, %for.exiting_block.prol ]
2044 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2045 ; PROLOG: latchExit.unr-lcssa:
2046 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph3, %latchExit.unr-lcssa.loopexit2 ]
2047 ; PROLOG-NEXT: br label %latchExit
2048 ; PROLOG: latchExit:
2049 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2050 ; PROLOG-NEXT: ret i32 %result
2051 ; PROLOG: for.exit2.loopexit:
2052 ; PROLOG-NEXT: br label %for.exit2
2053 ; PROLOG: for.exit2.loopexit1:
2054 ; PROLOG-NEXT: br label %for.exit2
2055 ; PROLOG: for.exit2:
2056 ; PROLOG-NEXT: ret i32 42
2058 ; PROLOG-BLOCK-LABEL: @otherblock_latch_same_exit(
2059 ; PROLOG-BLOCK-NEXT: entry:
2060 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
2061 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
2062 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
2063 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2064 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2065 ; PROLOG-BLOCK: header.prol.preheader:
2066 ; PROLOG-BLOCK-NEXT: br label %header.prol
2067 ; PROLOG-BLOCK: header.prol:
2068 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.prol
2069 ; PROLOG-BLOCK: for.exiting_block.prol:
2070 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
2071 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa, label %latch.prol
2072 ; PROLOG-BLOCK: latch.prol:
2073 ; PROLOG-BLOCK-NEXT: %2 = load i32, i32* %a, align 4
2074 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
2075 ; PROLOG-BLOCK: header.prol.loopexit:
2076 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %2, %latch.prol ]
2077 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
2078 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %latch.prol ]
2079 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
2080 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchExit, label %entry.new
2081 ; PROLOG-BLOCK: entry.new:
2082 ; PROLOG-BLOCK-NEXT: br label %header
2083 ; PROLOG-BLOCK: header:
2084 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2085 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
2086 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2087 ; PROLOG-BLOCK: for.exiting_block:
2088 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2089 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2090 ; PROLOG-BLOCK: latch:
2091 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2092 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx, align 4
2093 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
2094 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2095 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2096 ; PROLOG-BLOCK: for.exiting_block.1:
2097 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2098 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2099 ; PROLOG-BLOCK: latch.1:
2100 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2101 ; PROLOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
2102 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
2103 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2104 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
2105 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !5
2106 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
2107 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ 2, %for.exiting_block ], [ 2, %for.exiting_block.1 ], [ %add.1, %latch.1 ]
2108 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2109 ; PROLOG-BLOCK: latchExit.unr-lcssa:
2110 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 2, %for.exiting_block.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2111 ; PROLOG-BLOCK-NEXT: br label %latchExit
2112 ; PROLOG-BLOCK: latchExit:
2113 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2114 ; PROLOG-BLOCK-NEXT: ret i32 %result
2115 ; PROLOG-BLOCK: for.exit2.loopexit:
2116 ; PROLOG-BLOCK-NEXT: br label %for.exit2
2117 ; PROLOG-BLOCK: for.exit2:
2118 ; PROLOG-BLOCK-NEXT: ret i32 42
2125 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
2126 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
2127 br i1 %cond, label %for.exit2, label %for.exiting_block
2130 %cmp = icmp eq i64 %n, 42
2131 br i1 %cmp, label %latchExit, label %latch
2133 latch: ; preds = %latch, %entry
2134 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2135 %0 = load i32, i32* %arrayidx, align 4
2136 %add = add nsw i32 %0, %sum.02
2137 %indvars.iv.next = add i64 %indvars.iv, 1
2138 %exitcond = icmp eq i64 %indvars.iv.next, %n
2139 br i1 %exitcond, label %latchExit, label %header
2141 latchExit: ; preds = %latch, %entry
2142 %result = phi i32 [ 2, %for.exiting_block ], [ %add, %latch ]
2149 ; Two exiting blocks to latch where the exiting blocks are Latch and a
2151 ; Same as above test except the incoming value for latch Phi is from the header
2152 ; FIXME: We should be able to runtime unroll.
2153 define i32 @otherblock_latch_same_exit2(i32* nocapture %a, i64 %n, i1 %cond) {
2154 ; EPILOG-LABEL: @otherblock_latch_same_exit2(
2155 ; EPILOG-NEXT: entry:
2156 ; EPILOG-NEXT: %0 = freeze i64 %n
2157 ; EPILOG-NEXT: %1 = add i64 %0, -1
2158 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
2159 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
2160 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
2161 ; EPILOG: entry.new:
2162 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
2163 ; EPILOG-NEXT: br label %header
2165 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2166 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
2167 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
2168 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2169 ; EPILOG: for.exiting_block:
2170 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
2171 ; EPILOG-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2173 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2174 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
2175 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
2176 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2177 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
2178 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2179 ; EPILOG: for.exiting_block.1:
2180 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2181 ; EPILOG-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2183 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2184 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
2185 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
2186 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
2187 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
2188 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2189 ; EPILOG: for.exiting_block.2:
2190 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2191 ; EPILOG-NEXT: br i1 %cmp.2, label %latchExit.epilog-lcssa.loopexit, label %latch.2
2193 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
2194 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
2195 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
2196 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
2197 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
2198 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2199 ; EPILOG: for.exiting_block.3:
2200 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2201 ; EPILOG-NEXT: br i1 %cmp.3, label %latchExit.epilog-lcssa.loopexit, label %latch.3
2203 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
2204 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
2205 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
2206 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
2207 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
2208 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2209 ; EPILOG: for.exiting_block.4:
2210 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2211 ; EPILOG-NEXT: br i1 %cmp.4, label %latchExit.epilog-lcssa.loopexit, label %latch.4
2213 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
2214 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
2215 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
2216 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
2217 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
2218 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2219 ; EPILOG: for.exiting_block.5:
2220 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2221 ; EPILOG-NEXT: br i1 %cmp.5, label %latchExit.epilog-lcssa.loopexit, label %latch.5
2223 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
2224 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
2225 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
2226 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
2227 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
2228 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2229 ; EPILOG: for.exiting_block.6:
2230 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2231 ; EPILOG-NEXT: br i1 %cmp.6, label %latchExit.epilog-lcssa.loopexit, label %latch.6
2233 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2234 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
2235 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
2236 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
2237 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
2238 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2239 ; EPILOG: for.exiting_block.7:
2240 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2241 ; EPILOG-NEXT: br i1 %cmp.7, label %latchExit.epilog-lcssa.loopexit, label %latch.7
2243 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2244 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
2245 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
2246 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2247 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
2248 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
2249 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
2250 ; EPILOG: latchExit.unr-lcssa.loopexit:
2251 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
2252 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
2253 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
2254 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
2255 ; EPILOG: latchExit.unr-lcssa:
2256 ; EPILOG-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2257 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2258 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2259 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2260 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2261 ; EPILOG: header.epil.preheader:
2262 ; EPILOG-NEXT: br label %header.epil
2263 ; EPILOG: header.epil:
2264 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
2265 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
2266 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
2267 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit2, label %for.exiting_block.epil
2268 ; EPILOG: for.exiting_block.epil:
2269 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
2270 ; EPILOG-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa.loopexit3, label %latch.epil
2271 ; EPILOG: latch.epil:
2272 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
2273 ; EPILOG-NEXT: %11 = load i32, i32* %arrayidx.epil, align 4
2274 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
2275 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
2276 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
2277 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
2278 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
2279 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit3, !llvm.loop !6
2280 ; EPILOG: latchExit.epilog-lcssa.loopexit:
2281 ; 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 ]
2282 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2283 ; EPILOG: latchExit.epilog-lcssa.loopexit3:
2284 ; EPILOG-NEXT: %result.ph1.ph4 = phi i32 [ %sum.02.epil, %for.exiting_block.epil ], [ %add.epil, %latch.epil ]
2285 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2286 ; EPILOG: latchExit.epilog-lcssa:
2287 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph4, %latchExit.epilog-lcssa.loopexit3 ]
2288 ; EPILOG-NEXT: br label %latchExit
2289 ; EPILOG: latchExit:
2290 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2291 ; EPILOG-NEXT: ret i32 %result
2292 ; EPILOG: for.exit2.loopexit:
2293 ; EPILOG-NEXT: br label %for.exit2
2294 ; EPILOG: for.exit2.loopexit2:
2295 ; EPILOG-NEXT: br label %for.exit2
2296 ; EPILOG: for.exit2:
2297 ; EPILOG-NEXT: ret i32 42
2299 ; EPILOG-BLOCK-LABEL: @otherblock_latch_same_exit2(
2300 ; EPILOG-BLOCK-NEXT: entry:
2301 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
2302 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
2303 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
2304 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
2305 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
2306 ; EPILOG-BLOCK: entry.new:
2307 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
2308 ; EPILOG-BLOCK-NEXT: br label %header
2309 ; EPILOG-BLOCK: header:
2310 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2311 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
2312 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
2313 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2314 ; EPILOG-BLOCK: for.exiting_block:
2315 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2316 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2317 ; EPILOG-BLOCK: latch:
2318 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2319 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
2320 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
2321 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2322 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
2323 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2324 ; EPILOG-BLOCK: for.exiting_block.1:
2325 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2326 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2327 ; EPILOG-BLOCK: latch.1:
2328 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2329 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
2330 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
2331 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2332 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
2333 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
2334 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !6
2335 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
2336 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
2337 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
2338 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
2339 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2340 ; EPILOG-BLOCK: latchExit.unr-lcssa:
2341 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2342 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2343 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2344 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2345 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2346 ; EPILOG-BLOCK: header.epil.preheader:
2347 ; EPILOG-BLOCK-NEXT: br label %header.epil
2348 ; EPILOG-BLOCK: header.epil:
2349 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.epil
2350 ; EPILOG-BLOCK: for.exiting_block.epil:
2351 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
2352 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa, label %latch.epil
2353 ; EPILOG-BLOCK: latch.epil:
2354 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
2355 ; EPILOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.epil, align 4
2356 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
2357 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2358 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
2359 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ]
2360 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2361 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
2362 ; 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 ]
2363 ; EPILOG-BLOCK-NEXT: br label %latchExit
2364 ; EPILOG-BLOCK: latchExit:
2365 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2366 ; EPILOG-BLOCK-NEXT: ret i32 %result
2367 ; EPILOG-BLOCK: for.exit2.loopexit:
2368 ; EPILOG-BLOCK-NEXT: br label %for.exit2
2369 ; EPILOG-BLOCK: for.exit2:
2370 ; EPILOG-BLOCK-NEXT: ret i32 42
2372 ; PROLOG-LABEL: @otherblock_latch_same_exit2(
2373 ; PROLOG-NEXT: entry:
2374 ; PROLOG-NEXT: %0 = freeze i64 %n
2375 ; PROLOG-NEXT: %1 = add i64 %0, -1
2376 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
2377 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2378 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2379 ; PROLOG: header.prol.preheader:
2380 ; PROLOG-NEXT: br label %header.prol
2381 ; PROLOG: header.prol:
2382 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2383 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2384 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
2385 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit1, label %for.exiting_block.prol
2386 ; PROLOG: for.exiting_block.prol:
2387 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
2388 ; PROLOG-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa.loopexit2, label %latch.prol
2389 ; PROLOG: latch.prol:
2390 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
2391 ; PROLOG-NEXT: %2 = load i32, i32* %arrayidx.prol, align 4
2392 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
2393 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
2394 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
2395 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
2396 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
2397 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !6
2398 ; PROLOG: header.prol.loopexit.unr-lcssa:
2399 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2400 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
2401 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2402 ; PROLOG-NEXT: br label %header.prol.loopexit
2403 ; PROLOG: header.prol.loopexit:
2404 ; PROLOG-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
2405 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
2406 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
2407 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
2408 ; PROLOG-NEXT: br i1 %3, label %latchExit, label %entry.new
2409 ; PROLOG: entry.new:
2410 ; PROLOG-NEXT: br label %header
2412 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2413 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
2414 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2415 ; PROLOG: for.exiting_block:
2416 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
2417 ; PROLOG-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2419 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2420 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx, align 4
2421 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
2422 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2423 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2424 ; PROLOG: for.exiting_block.1:
2425 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2426 ; PROLOG-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2428 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2429 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
2430 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
2431 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2432 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2433 ; PROLOG: for.exiting_block.2:
2434 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2435 ; PROLOG-NEXT: br i1 %cmp.2, label %latchExit.unr-lcssa.loopexit, label %latch.2
2437 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
2438 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.2, align 4
2439 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
2440 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
2441 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2442 ; PROLOG: for.exiting_block.3:
2443 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2444 ; PROLOG-NEXT: br i1 %cmp.3, label %latchExit.unr-lcssa.loopexit, label %latch.3
2446 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
2447 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.3, align 4
2448 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
2449 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
2450 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2451 ; PROLOG: for.exiting_block.4:
2452 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2453 ; PROLOG-NEXT: br i1 %cmp.4, label %latchExit.unr-lcssa.loopexit, label %latch.4
2455 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
2456 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.4, align 4
2457 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
2458 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
2459 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2460 ; PROLOG: for.exiting_block.5:
2461 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2462 ; PROLOG-NEXT: br i1 %cmp.5, label %latchExit.unr-lcssa.loopexit, label %latch.5
2464 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
2465 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.5, align 4
2466 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
2467 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
2468 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2469 ; PROLOG: for.exiting_block.6:
2470 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2471 ; PROLOG-NEXT: br i1 %cmp.6, label %latchExit.unr-lcssa.loopexit, label %latch.6
2473 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2474 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.6, align 4
2475 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
2476 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
2477 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2478 ; PROLOG: for.exiting_block.7:
2479 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2480 ; PROLOG-NEXT: br i1 %cmp.7, label %latchExit.unr-lcssa.loopexit, label %latch.7
2482 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2483 ; PROLOG-NEXT: %11 = load i32, i32* %arrayidx.7, align 4
2484 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
2485 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2486 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
2487 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
2488 ; PROLOG: latchExit.unr-lcssa.loopexit:
2489 ; 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 ]
2490 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2491 ; PROLOG: latchExit.unr-lcssa.loopexit2:
2492 ; PROLOG-NEXT: %result.ph.ph3 = phi i32 [ %sum.02.prol, %for.exiting_block.prol ]
2493 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2494 ; PROLOG: latchExit.unr-lcssa:
2495 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph3, %latchExit.unr-lcssa.loopexit2 ]
2496 ; PROLOG-NEXT: br label %latchExit
2497 ; PROLOG: latchExit:
2498 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2499 ; PROLOG-NEXT: ret i32 %result
2500 ; PROLOG: for.exit2.loopexit:
2501 ; PROLOG-NEXT: br label %for.exit2
2502 ; PROLOG: for.exit2.loopexit1:
2503 ; PROLOG-NEXT: br label %for.exit2
2504 ; PROLOG: for.exit2:
2505 ; PROLOG-NEXT: ret i32 42
2507 ; PROLOG-BLOCK-LABEL: @otherblock_latch_same_exit2(
2508 ; PROLOG-BLOCK-NEXT: entry:
2509 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
2510 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
2511 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
2512 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2513 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2514 ; PROLOG-BLOCK: header.prol.preheader:
2515 ; PROLOG-BLOCK-NEXT: br label %header.prol
2516 ; PROLOG-BLOCK: header.prol:
2517 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.prol
2518 ; PROLOG-BLOCK: for.exiting_block.prol:
2519 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
2520 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa, label %latch.prol
2521 ; PROLOG-BLOCK: latch.prol:
2522 ; PROLOG-BLOCK-NEXT: %2 = load i32, i32* %a, align 4
2523 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
2524 ; PROLOG-BLOCK: header.prol.loopexit:
2525 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %2, %latch.prol ]
2526 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
2527 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %latch.prol ]
2528 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
2529 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchExit, label %entry.new
2530 ; PROLOG-BLOCK: entry.new:
2531 ; PROLOG-BLOCK-NEXT: br label %header
2532 ; PROLOG-BLOCK: header:
2533 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2534 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
2535 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2536 ; PROLOG-BLOCK: for.exiting_block:
2537 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2538 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2539 ; PROLOG-BLOCK: latch:
2540 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2541 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx, align 4
2542 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
2543 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2544 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2545 ; PROLOG-BLOCK: for.exiting_block.1:
2546 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2547 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2548 ; PROLOG-BLOCK: latch.1:
2549 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2550 ; PROLOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
2551 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
2552 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2553 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
2554 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !6
2555 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
2556 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %latch.1 ]
2557 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2558 ; PROLOG-BLOCK: latchExit.unr-lcssa:
2559 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 0, %for.exiting_block.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2560 ; PROLOG-BLOCK-NEXT: br label %latchExit
2561 ; PROLOG-BLOCK: latchExit:
2562 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2563 ; PROLOG-BLOCK-NEXT: ret i32 %result
2564 ; PROLOG-BLOCK: for.exit2.loopexit:
2565 ; PROLOG-BLOCK-NEXT: br label %for.exit2
2566 ; PROLOG-BLOCK: for.exit2:
2567 ; PROLOG-BLOCK-NEXT: ret i32 42
2574 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
2575 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
2576 br i1 %cond, label %for.exit2, label %for.exiting_block
2579 %cmp = icmp eq i64 %n, 42
2580 br i1 %cmp, label %latchExit, label %latch
2582 latch: ; preds = %latch, %entry
2583 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2584 %0 = load i32, i32* %arrayidx, align 4
2585 %add = add nsw i32 %0, %sum.02
2586 %indvars.iv.next = add i64 %indvars.iv, 1
2587 %exitcond = icmp eq i64 %indvars.iv.next, %n
2588 br i1 %exitcond, label %latchExit, label %header
2590 latchExit: ; preds = %latch, %entry
2591 %result = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %latch ]
2598 ; Two exiting blocks to latch where the exiting blocks are Latch and a
2600 ; Same as above test except the incoming value for cloned latch Phi is from the
2601 ; for.exiting_block.
2602 ; FIXME: We should be able to runtime unroll.
2603 define i32 @otherblock_latch_same_exit3(i32* nocapture %a, i64 %n, i1 %cond) {
2604 ; EPILOG-LABEL: @otherblock_latch_same_exit3(
2605 ; EPILOG-NEXT: entry:
2606 ; EPILOG-NEXT: %0 = freeze i64 %n
2607 ; EPILOG-NEXT: %1 = add i64 %0, -1
2608 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
2609 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
2610 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
2611 ; EPILOG: entry.new:
2612 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
2613 ; EPILOG-NEXT: br label %header
2615 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2616 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
2617 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
2618 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2619 ; EPILOG: for.exiting_block:
2620 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2621 ; EPILOG-NEXT: %3 = load i32, i32* %arrayidx, align 4
2622 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
2623 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
2624 ; EPILOG-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2626 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2627 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
2628 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2629 ; EPILOG: for.exiting_block.1:
2630 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2631 ; EPILOG-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
2632 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
2633 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2634 ; EPILOG-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2636 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
2637 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
2638 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2639 ; EPILOG: for.exiting_block.2:
2640 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
2641 ; EPILOG-NEXT: %5 = load i32, i32* %arrayidx.2, align 4
2642 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
2643 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2644 ; EPILOG-NEXT: br i1 %cmp.2, label %latchExit.epilog-lcssa.loopexit, label %latch.2
2646 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
2647 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
2648 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2649 ; EPILOG: for.exiting_block.3:
2650 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
2651 ; EPILOG-NEXT: %6 = load i32, i32* %arrayidx.3, align 4
2652 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
2653 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2654 ; EPILOG-NEXT: br i1 %cmp.3, label %latchExit.epilog-lcssa.loopexit, label %latch.3
2656 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
2657 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
2658 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2659 ; EPILOG: for.exiting_block.4:
2660 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
2661 ; EPILOG-NEXT: %7 = load i32, i32* %arrayidx.4, align 4
2662 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
2663 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2664 ; EPILOG-NEXT: br i1 %cmp.4, label %latchExit.epilog-lcssa.loopexit, label %latch.4
2666 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
2667 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
2668 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2669 ; EPILOG: for.exiting_block.5:
2670 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
2671 ; EPILOG-NEXT: %8 = load i32, i32* %arrayidx.5, align 4
2672 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
2673 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2674 ; EPILOG-NEXT: br i1 %cmp.5, label %latchExit.epilog-lcssa.loopexit, label %latch.5
2676 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
2677 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
2678 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2679 ; EPILOG: for.exiting_block.6:
2680 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2681 ; EPILOG-NEXT: %9 = load i32, i32* %arrayidx.6, align 4
2682 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
2683 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2684 ; EPILOG-NEXT: br i1 %cmp.6, label %latchExit.epilog-lcssa.loopexit, label %latch.6
2686 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
2687 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
2688 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2689 ; EPILOG: for.exiting_block.7:
2690 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2691 ; EPILOG-NEXT: %10 = load i32, i32* %arrayidx.7, align 4
2692 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
2693 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2694 ; EPILOG-NEXT: br i1 %cmp.7, label %latchExit.epilog-lcssa.loopexit, label %latch.7
2696 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2697 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
2698 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
2699 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
2700 ; EPILOG: latchExit.unr-lcssa.loopexit:
2701 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
2702 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
2703 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
2704 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
2705 ; EPILOG: latchExit.unr-lcssa:
2706 ; EPILOG-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2707 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2708 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2709 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2710 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2711 ; EPILOG: header.epil.preheader:
2712 ; EPILOG-NEXT: br label %header.epil
2713 ; EPILOG: header.epil:
2714 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
2715 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
2716 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
2717 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit2, label %for.exiting_block.epil
2718 ; EPILOG: for.exiting_block.epil:
2719 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
2720 ; EPILOG-NEXT: %11 = load i32, i32* %arrayidx.epil, align 4
2721 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
2722 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
2723 ; EPILOG-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa.loopexit3, label %latch.epil
2724 ; EPILOG: latch.epil:
2725 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
2726 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
2727 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
2728 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
2729 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit3, !llvm.loop !7
2730 ; EPILOG: latchExit.epilog-lcssa.loopexit:
2731 ; 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 ]
2732 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2733 ; EPILOG: latchExit.epilog-lcssa.loopexit3:
2734 ; EPILOG-NEXT: %result.ph1.ph4 = phi i32 [ %sum.02.epil, %for.exiting_block.epil ], [ %add.epil, %latch.epil ]
2735 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2736 ; EPILOG: latchExit.epilog-lcssa:
2737 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph4, %latchExit.epilog-lcssa.loopexit3 ]
2738 ; EPILOG-NEXT: br label %latchExit
2739 ; EPILOG: latchExit:
2740 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2741 ; EPILOG-NEXT: ret i32 %result
2742 ; EPILOG: for.exit2.loopexit:
2743 ; EPILOG-NEXT: br label %for.exit2
2744 ; EPILOG: for.exit2.loopexit2:
2745 ; EPILOG-NEXT: br label %for.exit2
2746 ; EPILOG: for.exit2:
2747 ; EPILOG-NEXT: ret i32 42
2749 ; EPILOG-BLOCK-LABEL: @otherblock_latch_same_exit3(
2750 ; EPILOG-BLOCK-NEXT: entry:
2751 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
2752 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
2753 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
2754 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
2755 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
2756 ; EPILOG-BLOCK: entry.new:
2757 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
2758 ; EPILOG-BLOCK-NEXT: br label %header
2759 ; EPILOG-BLOCK: header:
2760 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2761 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
2762 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
2763 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2764 ; EPILOG-BLOCK: for.exiting_block:
2765 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2766 ; EPILOG-BLOCK-NEXT: %3 = load i32, i32* %arrayidx, align 4
2767 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
2768 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2769 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2770 ; EPILOG-BLOCK: latch:
2771 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2772 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
2773 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2774 ; EPILOG-BLOCK: for.exiting_block.1:
2775 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2776 ; EPILOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx.1, align 4
2777 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
2778 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2779 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2780 ; EPILOG-BLOCK: latch.1:
2781 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2782 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
2783 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
2784 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !7
2785 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
2786 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
2787 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
2788 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
2789 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2790 ; EPILOG-BLOCK: latchExit.unr-lcssa:
2791 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ undef, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2792 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2793 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2794 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2795 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2796 ; EPILOG-BLOCK: header.epil.preheader:
2797 ; EPILOG-BLOCK-NEXT: br label %header.epil
2798 ; EPILOG-BLOCK: header.epil:
2799 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.epil
2800 ; EPILOG-BLOCK: for.exiting_block.epil:
2801 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
2802 ; EPILOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.epil, align 4
2803 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
2804 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
2805 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa, label %latch.epil
2806 ; EPILOG-BLOCK: latch.epil:
2807 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2808 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
2809 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ]
2810 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2811 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
2812 ; 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 ]
2813 ; EPILOG-BLOCK-NEXT: br label %latchExit
2814 ; EPILOG-BLOCK: latchExit:
2815 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2816 ; EPILOG-BLOCK-NEXT: ret i32 %result
2817 ; EPILOG-BLOCK: for.exit2.loopexit:
2818 ; EPILOG-BLOCK-NEXT: br label %for.exit2
2819 ; EPILOG-BLOCK: for.exit2:
2820 ; EPILOG-BLOCK-NEXT: ret i32 42
2822 ; PROLOG-LABEL: @otherblock_latch_same_exit3(
2823 ; PROLOG-NEXT: entry:
2824 ; PROLOG-NEXT: %0 = freeze i64 %n
2825 ; PROLOG-NEXT: %1 = add i64 %0, -1
2826 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
2827 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2828 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2829 ; PROLOG: header.prol.preheader:
2830 ; PROLOG-NEXT: br label %header.prol
2831 ; PROLOG: header.prol:
2832 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2833 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2834 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
2835 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit1, label %for.exiting_block.prol
2836 ; PROLOG: for.exiting_block.prol:
2837 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
2838 ; PROLOG-NEXT: %2 = load i32, i32* %arrayidx.prol, align 4
2839 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
2840 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
2841 ; PROLOG-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa.loopexit2, label %latch.prol
2842 ; PROLOG: latch.prol:
2843 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
2844 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
2845 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
2846 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
2847 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !7
2848 ; PROLOG: header.prol.loopexit.unr-lcssa:
2849 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2850 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
2851 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2852 ; PROLOG-NEXT: br label %header.prol.loopexit
2853 ; PROLOG: header.prol.loopexit:
2854 ; PROLOG-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
2855 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
2856 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
2857 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
2858 ; PROLOG-NEXT: br i1 %3, label %latchExit, label %entry.new
2859 ; PROLOG: entry.new:
2860 ; PROLOG-NEXT: br label %header
2862 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2863 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
2864 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2865 ; PROLOG: for.exiting_block:
2866 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2867 ; PROLOG-NEXT: %4 = load i32, i32* %arrayidx, align 4
2868 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
2869 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
2870 ; PROLOG-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2872 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2873 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2874 ; PROLOG: for.exiting_block.1:
2875 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2876 ; PROLOG-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
2877 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
2878 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2879 ; PROLOG-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2881 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
2882 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2883 ; PROLOG: for.exiting_block.2:
2884 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
2885 ; PROLOG-NEXT: %6 = load i32, i32* %arrayidx.2, align 4
2886 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
2887 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2888 ; PROLOG-NEXT: br i1 %cmp.2, label %latchExit.unr-lcssa.loopexit, label %latch.2
2890 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
2891 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2892 ; PROLOG: for.exiting_block.3:
2893 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
2894 ; PROLOG-NEXT: %7 = load i32, i32* %arrayidx.3, align 4
2895 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
2896 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2897 ; PROLOG-NEXT: br i1 %cmp.3, label %latchExit.unr-lcssa.loopexit, label %latch.3
2899 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
2900 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2901 ; PROLOG: for.exiting_block.4:
2902 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
2903 ; PROLOG-NEXT: %8 = load i32, i32* %arrayidx.4, align 4
2904 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
2905 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2906 ; PROLOG-NEXT: br i1 %cmp.4, label %latchExit.unr-lcssa.loopexit, label %latch.4
2908 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
2909 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2910 ; PROLOG: for.exiting_block.5:
2911 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
2912 ; PROLOG-NEXT: %9 = load i32, i32* %arrayidx.5, align 4
2913 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
2914 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2915 ; PROLOG-NEXT: br i1 %cmp.5, label %latchExit.unr-lcssa.loopexit, label %latch.5
2917 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
2918 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2919 ; PROLOG: for.exiting_block.6:
2920 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
2921 ; PROLOG-NEXT: %10 = load i32, i32* %arrayidx.6, align 4
2922 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
2923 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2924 ; PROLOG-NEXT: br i1 %cmp.6, label %latchExit.unr-lcssa.loopexit, label %latch.6
2926 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
2927 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2928 ; PROLOG: for.exiting_block.7:
2929 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
2930 ; PROLOG-NEXT: %11 = load i32, i32* %arrayidx.7, align 4
2931 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
2932 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2933 ; PROLOG-NEXT: br i1 %cmp.7, label %latchExit.unr-lcssa.loopexit, label %latch.7
2935 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
2936 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
2937 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
2938 ; PROLOG: latchExit.unr-lcssa.loopexit:
2939 ; 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 ]
2940 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2941 ; PROLOG: latchExit.unr-lcssa.loopexit2:
2942 ; PROLOG-NEXT: %result.ph.ph3 = phi i32 [ %sum.02.prol, %for.exiting_block.prol ]
2943 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2944 ; PROLOG: latchExit.unr-lcssa:
2945 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph3, %latchExit.unr-lcssa.loopexit2 ]
2946 ; PROLOG-NEXT: br label %latchExit
2947 ; PROLOG: latchExit:
2948 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2949 ; PROLOG-NEXT: ret i32 %result
2950 ; PROLOG: for.exit2.loopexit:
2951 ; PROLOG-NEXT: br label %for.exit2
2952 ; PROLOG: for.exit2.loopexit1:
2953 ; PROLOG-NEXT: br label %for.exit2
2954 ; PROLOG: for.exit2:
2955 ; PROLOG-NEXT: ret i32 42
2957 ; PROLOG-BLOCK-LABEL: @otherblock_latch_same_exit3(
2958 ; PROLOG-BLOCK-NEXT: entry:
2959 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
2960 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
2961 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
2962 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2963 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2964 ; PROLOG-BLOCK: header.prol.preheader:
2965 ; PROLOG-BLOCK-NEXT: br label %header.prol
2966 ; PROLOG-BLOCK: header.prol:
2967 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.prol
2968 ; PROLOG-BLOCK: for.exiting_block.prol:
2969 ; PROLOG-BLOCK-NEXT: %2 = load i32, i32* %a, align 4
2970 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
2971 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa, label %latch.prol
2972 ; PROLOG-BLOCK: latch.prol:
2973 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
2974 ; PROLOG-BLOCK: header.prol.loopexit:
2975 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ undef, %entry ], [ %2, %latch.prol ]
2976 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
2977 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %latch.prol ]
2978 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
2979 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchExit, label %entry.new
2980 ; PROLOG-BLOCK: entry.new:
2981 ; PROLOG-BLOCK-NEXT: br label %header
2982 ; PROLOG-BLOCK: header:
2983 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2984 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
2985 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2986 ; PROLOG-BLOCK: for.exiting_block:
2987 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
2988 ; PROLOG-BLOCK-NEXT: %4 = load i32, i32* %arrayidx, align 4
2989 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
2990 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2991 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2992 ; PROLOG-BLOCK: latch:
2993 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2994 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2995 ; PROLOG-BLOCK: for.exiting_block.1:
2996 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
2997 ; PROLOG-BLOCK-NEXT: %5 = load i32, i32* %arrayidx.1, align 4
2998 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
2999 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
3000 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
3001 ; PROLOG-BLOCK: latch.1:
3002 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
3003 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
3004 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !7
3005 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
3006 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %latch.1 ]
3007 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
3008 ; PROLOG-BLOCK: latchExit.unr-lcssa:
3009 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 0, %for.exiting_block.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
3010 ; PROLOG-BLOCK-NEXT: br label %latchExit
3011 ; PROLOG-BLOCK: latchExit:
3012 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
3013 ; PROLOG-BLOCK-NEXT: ret i32 %result
3014 ; PROLOG-BLOCK: for.exit2.loopexit:
3015 ; PROLOG-BLOCK-NEXT: br label %for.exit2
3016 ; PROLOG-BLOCK: for.exit2:
3017 ; PROLOG-BLOCK-NEXT: ret i32 42
3024 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
3025 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
3026 br i1 %cond, label %for.exit2, label %for.exiting_block
3029 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
3030 %0 = load i32, i32* %arrayidx, align 4
3031 %add = add nsw i32 %0, %sum.02
3032 %cmp = icmp eq i64 %n, 42
3033 br i1 %cmp, label %latchExit, label %latch
3035 latch: ; preds = %latch, %entry
3036 %indvars.iv.next = add i64 %indvars.iv, 1
3037 %exitcond = icmp eq i64 %indvars.iv.next, %n
3038 br i1 %exitcond, label %latchExit, label %header
3040 latchExit: ; preds = %latch, %entry
3041 %result = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %latch ]
3048 ; Show a case where we have multiple exits, but (provably) exit on the
3049 ; first iteration and thus have nothing to unroll
3050 define void @non_loop(i32 %arg) {
3051 ; CHECK-LABEL: @non_loop(
3052 ; CHECK-NEXT: entry:
3053 ; CHECK-NEXT: %i = icmp sgt i32 undef, %arg
3054 ; CHECK-NEXT: br i1 %i, label %preheader, label %returnblock
3056 ; CHECK-NEXT: br label %header
3058 ; CHECK-NEXT: br i1 true, label %latchExit, label %latch
3060 ; CHECK-NEXT: br label %latchExit
3062 ; CHECK-NEXT: %i2.ph = phi i32 [ %arg, %header ], [ -1, %latch ]
3063 ; CHECK-NEXT: br label %returnblock
3064 ; CHECK: returnblock:
3065 ; CHECK-NEXT: %i2 = phi i32 [ -1, %entry ], [ %i2.ph, %latchExit ]
3066 ; CHECK-NEXT: ret void
3070 %i = icmp sgt i32 undef, %arg
3071 br i1 %i, label %preheader, label %returnblock
3073 preheader: ; preds = %entry
3076 header: ; preds = %preheader, %latch
3077 %i4 = phi i32 [ %inc, %latch ], [ %arg, %preheader ]
3078 %inc = add nsw i32 %i4, 1
3079 br i1 true, label %latchExit, label %latch
3081 latch: ; preds = %header
3082 %cmp = icmp slt i32 %inc, undef
3083 br i1 %cmp, label %header, label %latchExit
3085 latchExit: ; preds = %header, %latch
3086 %i2.ph = phi i32 [ %i4, %header ], [ -1, %latch ]
3087 br label %returnblock
3089 returnblock: ; preds = %latchExit, %entry
3090 %i2 = phi i32 [ -1, %entry ], [ %i2.ph, %latchExit ]
3094 ; Latch exit is shared by all exiting blocks
3095 define void @unique_exit(i32 %N, i32 %M) {
3096 ; EPILOG-LABEL: @unique_exit(
3097 ; EPILOG-NEXT: preheader:
3098 ; EPILOG-NEXT: %M.shifted = shl i32 %M, 3
3099 ; EPILOG-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3100 ; EPILOG-NEXT: %0 = freeze i32 %umax
3101 ; EPILOG-NEXT: %1 = add i32 %0, -1
3102 ; EPILOG-NEXT: %xtraiter = and i32 %0, 7
3103 ; EPILOG-NEXT: %2 = icmp ult i32 %1, 7
3104 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %preheader.new
3105 ; EPILOG: preheader.new:
3106 ; EPILOG-NEXT: %unroll_iter = sub i32 %0, %xtraiter
3107 ; EPILOG-NEXT: br label %header
3109 ; EPILOG-NEXT: %i4 = phi i32 [ 0, %preheader.new ], [ %inc.7, %latch.7 ]
3110 ; EPILOG-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.7, %latch.7 ]
3111 ; EPILOG-NEXT: %inc = add nuw nsw i32 %i4, 1
3112 ; EPILOG-NEXT: %cmp1 = icmp ult i32 %inc, %N
3113 ; EPILOG-NEXT: br i1 %cmp1, label %latch, label %latchExit.epilog-lcssa.loopexit
3115 ; EPILOG-NEXT: %niter.next = add nuw nsw i32 %niter, 1
3116 ; EPILOG-NEXT: %inc.1 = add nuw nsw i32 %inc, 1
3117 ; EPILOG-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3118 ; EPILOG-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.epilog-lcssa.loopexit
3120 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i32 %niter.next, 1
3121 ; EPILOG-NEXT: %inc.2 = add nuw nsw i32 %inc.1, 1
3122 ; EPILOG-NEXT: %cmp1.2 = icmp ult i32 %inc.2, %N
3123 ; EPILOG-NEXT: br i1 %cmp1.2, label %latch.2, label %latchExit.epilog-lcssa.loopexit
3125 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i32 %niter.next.1, 1
3126 ; EPILOG-NEXT: %inc.3 = add nuw nsw i32 %inc.2, 1
3127 ; EPILOG-NEXT: %cmp1.3 = icmp ult i32 %inc.3, %N
3128 ; EPILOG-NEXT: br i1 %cmp1.3, label %latch.3, label %latchExit.epilog-lcssa.loopexit
3130 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i32 %niter.next.2, 1
3131 ; EPILOG-NEXT: %inc.4 = add nuw nsw i32 %inc.3, 1
3132 ; EPILOG-NEXT: %cmp1.4 = icmp ult i32 %inc.4, %N
3133 ; EPILOG-NEXT: br i1 %cmp1.4, label %latch.4, label %latchExit.epilog-lcssa.loopexit
3135 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i32 %niter.next.3, 1
3136 ; EPILOG-NEXT: %inc.5 = add nuw nsw i32 %inc.4, 1
3137 ; EPILOG-NEXT: %cmp1.5 = icmp ult i32 %inc.5, %N
3138 ; EPILOG-NEXT: br i1 %cmp1.5, label %latch.5, label %latchExit.epilog-lcssa.loopexit
3140 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i32 %niter.next.4, 1
3141 ; EPILOG-NEXT: %inc.6 = add nuw nsw i32 %inc.5, 1
3142 ; EPILOG-NEXT: %cmp1.6 = icmp ult i32 %inc.6, %N
3143 ; EPILOG-NEXT: br i1 %cmp1.6, label %latch.6, label %latchExit.epilog-lcssa.loopexit
3145 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i32 %niter.next.5, 1
3146 ; EPILOG-NEXT: %inc.7 = add nuw i32 %inc.6, 1
3147 ; EPILOG-NEXT: %cmp1.7 = icmp ult i32 %inc.7, %N
3148 ; EPILOG-NEXT: br i1 %cmp1.7, label %latch.7, label %latchExit.epilog-lcssa.loopexit
3150 ; EPILOG-NEXT: %niter.next.7 = add nuw i32 %niter.next.6, 1
3151 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i32 %niter.next.7, %unroll_iter
3152 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %header, label %latchExit.unr-lcssa.loopexit
3153 ; EPILOG: latchExit.unr-lcssa.loopexit:
3154 ; EPILOG-NEXT: %i2.ph.ph.ph = phi i32 [ -1, %latch.7 ]
3155 ; EPILOG-NEXT: %i4.unr.ph = phi i32 [ %inc.7, %latch.7 ]
3156 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
3157 ; EPILOG: latchExit.unr-lcssa:
3158 ; EPILOG-NEXT: %i2.ph.ph = phi i32 [ undef, %preheader ], [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ]
3159 ; EPILOG-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ %i4.unr.ph, %latchExit.unr-lcssa.loopexit ]
3160 ; EPILOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3161 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
3162 ; EPILOG: header.epil.preheader:
3163 ; EPILOG-NEXT: br label %header.epil
3164 ; EPILOG: header.epil:
3165 ; EPILOG-NEXT: %i4.epil = phi i32 [ %inc.epil, %latch.epil ], [ %i4.unr, %header.epil.preheader ]
3166 ; EPILOG-NEXT: %epil.iter = phi i32 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
3167 ; EPILOG-NEXT: %inc.epil = add nuw i32 %i4.epil, 1
3168 ; EPILOG-NEXT: %cmp1.epil = icmp ult i32 %inc.epil, %N
3169 ; EPILOG-NEXT: br i1 %cmp1.epil, label %latch.epil, label %latchExit.epilog-lcssa.loopexit2
3170 ; EPILOG: latch.epil:
3171 ; EPILOG-NEXT: %cmp.epil = icmp ult i32 %inc.epil, %M.shifted
3172 ; EPILOG-NEXT: %epil.iter.next = add i32 %epil.iter, 1
3173 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i32 %epil.iter.next, %xtraiter
3174 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit2, !llvm.loop !8
3175 ; EPILOG: latchExit.epilog-lcssa.loopexit:
3176 ; 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 ]
3177 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
3178 ; EPILOG: latchExit.epilog-lcssa.loopexit2:
3179 ; EPILOG-NEXT: %i2.ph.ph1.ph3 = phi i32 [ %i4.epil, %header.epil ], [ -1, %latch.epil ]
3180 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
3181 ; EPILOG: latchExit.epilog-lcssa:
3182 ; EPILOG-NEXT: %i2.ph.ph1 = phi i32 [ %i2.ph.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %i2.ph.ph1.ph3, %latchExit.epilog-lcssa.loopexit2 ]
3183 ; EPILOG-NEXT: br label %latchExit
3184 ; EPILOG: latchExit:
3185 ; EPILOG-NEXT: %i2.ph = phi i32 [ %i2.ph.ph, %latchExit.unr-lcssa ], [ %i2.ph.ph1, %latchExit.epilog-lcssa ]
3186 ; EPILOG-NEXT: ret void
3188 ; EPILOG-BLOCK-LABEL: @unique_exit(
3189 ; EPILOG-BLOCK-NEXT: preheader:
3190 ; EPILOG-BLOCK-NEXT: %M.shifted = shl i32 %M, 3
3191 ; EPILOG-BLOCK-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3192 ; EPILOG-BLOCK-NEXT: %0 = freeze i32 %umax
3193 ; EPILOG-BLOCK-NEXT: %1 = add i32 %0, -1
3194 ; EPILOG-BLOCK-NEXT: %xtraiter = and i32 %0, 1
3195 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i32 %1, 1
3196 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %preheader.new
3197 ; EPILOG-BLOCK: preheader.new:
3198 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i32 %0, %xtraiter
3199 ; EPILOG-BLOCK-NEXT: br label %header
3200 ; EPILOG-BLOCK: header:
3201 ; EPILOG-BLOCK-NEXT: %i4 = phi i32 [ 0, %preheader.new ], [ %inc.1, %latch.1 ]
3202 ; EPILOG-BLOCK-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.1, %latch.1 ]
3203 ; EPILOG-BLOCK-NEXT: %inc = add nuw nsw i32 %i4, 1
3204 ; EPILOG-BLOCK-NEXT: %cmp1 = icmp ult i32 %inc, %N
3205 ; EPILOG-BLOCK-NEXT: br i1 %cmp1, label %latch, label %latchExit.epilog-lcssa.loopexit
3206 ; EPILOG-BLOCK: latch:
3207 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i32 %niter, 1
3208 ; EPILOG-BLOCK-NEXT: %inc.1 = add nuw i32 %inc, 1
3209 ; EPILOG-BLOCK-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3210 ; EPILOG-BLOCK-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.epilog-lcssa.loopexit
3211 ; EPILOG-BLOCK: latch.1:
3212 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add nuw i32 %niter.next, 1
3213 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i32 %niter.next.1, %unroll_iter
3214 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %header, label %latchExit.unr-lcssa.loopexit, !llvm.loop !8
3215 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
3216 ; EPILOG-BLOCK-NEXT: %i2.ph.ph.ph = phi i32 [ -1, %latch.1 ]
3217 ; EPILOG-BLOCK-NEXT: %i4.unr.ph = phi i32 [ %inc.1, %latch.1 ]
3218 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
3219 ; EPILOG-BLOCK: latchExit.unr-lcssa:
3220 ; EPILOG-BLOCK-NEXT: %i2.ph.ph = phi i32 [ undef, %preheader ], [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ]
3221 ; EPILOG-BLOCK-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ %i4.unr.ph, %latchExit.unr-lcssa.loopexit ]
3222 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3223 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
3224 ; EPILOG-BLOCK: header.epil.preheader:
3225 ; EPILOG-BLOCK-NEXT: br label %header.epil
3226 ; EPILOG-BLOCK: header.epil:
3227 ; EPILOG-BLOCK-NEXT: %inc.epil = add nuw i32 %i4.unr, 1
3228 ; EPILOG-BLOCK-NEXT: %cmp1.epil = icmp ult i32 %inc.epil, %N
3229 ; EPILOG-BLOCK-NEXT: br i1 %cmp1.epil, label %latch.epil, label %latchExit.epilog-lcssa
3230 ; EPILOG-BLOCK: latch.epil:
3231 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
3232 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
3233 ; EPILOG-BLOCK-NEXT: %i2.ph.ph1.ph = phi i32 [ %i4, %header ], [ %inc, %latch ]
3234 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
3235 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
3236 ; EPILOG-BLOCK-NEXT: %i2.ph.ph1 = phi i32 [ -1, %latch.epil ], [ %i4.unr, %header.epil ], [ %i2.ph.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
3237 ; EPILOG-BLOCK-NEXT: br label %latchExit
3238 ; EPILOG-BLOCK: latchExit:
3239 ; EPILOG-BLOCK-NEXT: %i2.ph = phi i32 [ %i2.ph.ph, %latchExit.unr-lcssa ], [ %i2.ph.ph1, %latchExit.epilog-lcssa ]
3240 ; EPILOG-BLOCK-NEXT: ret void
3242 ; PROLOG-LABEL: @unique_exit(
3243 ; PROLOG-NEXT: preheader:
3244 ; PROLOG-NEXT: %M.shifted = shl i32 %M, 3
3245 ; PROLOG-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3246 ; PROLOG-NEXT: %0 = freeze i32 %umax
3247 ; PROLOG-NEXT: %1 = add i32 %0, -1
3248 ; PROLOG-NEXT: %xtraiter = and i32 %0, 7
3249 ; PROLOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3250 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
3251 ; PROLOG: header.prol.preheader:
3252 ; PROLOG-NEXT: br label %header.prol
3253 ; PROLOG: header.prol:
3254 ; PROLOG-NEXT: %i4.prol = phi i32 [ %inc.prol, %latch.prol ], [ 0, %header.prol.preheader ]
3255 ; PROLOG-NEXT: %prol.iter = phi i32 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
3256 ; PROLOG-NEXT: %inc.prol = add nuw i32 %i4.prol, 1
3257 ; PROLOG-NEXT: %cmp1.prol = icmp ult i32 %inc.prol, %N
3258 ; PROLOG-NEXT: br i1 %cmp1.prol, label %latch.prol, label %latchExit.unr-lcssa.loopexit1
3259 ; PROLOG: latch.prol:
3260 ; PROLOG-NEXT: %cmp.prol = icmp ult i32 %inc.prol, %M.shifted
3261 ; PROLOG-NEXT: %prol.iter.next = add i32 %prol.iter, 1
3262 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i32 %prol.iter.next, %xtraiter
3263 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !8
3264 ; PROLOG: header.prol.loopexit.unr-lcssa:
3265 ; PROLOG-NEXT: %i4.unr.ph = phi i32 [ %inc.prol, %latch.prol ]
3266 ; PROLOG-NEXT: %i2.ph.unr.ph = phi i32 [ -1, %latch.prol ]
3267 ; PROLOG-NEXT: br label %header.prol.loopexit
3268 ; PROLOG: header.prol.loopexit:
3269 ; PROLOG-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ %i4.unr.ph, %header.prol.loopexit.unr-lcssa ]
3270 ; PROLOG-NEXT: %i2.ph.unr = phi i32 [ undef, %preheader ], [ %i2.ph.unr.ph, %header.prol.loopexit.unr-lcssa ]
3271 ; PROLOG-NEXT: %2 = icmp ult i32 %1, 7
3272 ; PROLOG-NEXT: br i1 %2, label %latchExit, label %preheader.new
3273 ; PROLOG: preheader.new:
3274 ; PROLOG-NEXT: br label %header
3276 ; PROLOG-NEXT: %i4 = phi i32 [ %i4.unr, %preheader.new ], [ %inc.7, %latch.7 ]
3277 ; PROLOG-NEXT: %inc = add nuw i32 %i4, 1
3278 ; PROLOG-NEXT: %cmp1 = icmp ult i32 %inc, %N
3279 ; PROLOG-NEXT: br i1 %cmp1, label %latch, label %latchExit.unr-lcssa.loopexit
3281 ; PROLOG-NEXT: %inc.1 = add nuw i32 %inc, 1
3282 ; PROLOG-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3283 ; PROLOG-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.unr-lcssa.loopexit
3285 ; PROLOG-NEXT: %inc.2 = add nuw i32 %inc.1, 1
3286 ; PROLOG-NEXT: %cmp1.2 = icmp ult i32 %inc.2, %N
3287 ; PROLOG-NEXT: br i1 %cmp1.2, label %latch.2, label %latchExit.unr-lcssa.loopexit
3289 ; PROLOG-NEXT: %inc.3 = add nuw i32 %inc.2, 1
3290 ; PROLOG-NEXT: %cmp1.3 = icmp ult i32 %inc.3, %N
3291 ; PROLOG-NEXT: br i1 %cmp1.3, label %latch.3, label %latchExit.unr-lcssa.loopexit
3293 ; PROLOG-NEXT: %inc.4 = add nuw i32 %inc.3, 1
3294 ; PROLOG-NEXT: %cmp1.4 = icmp ult i32 %inc.4, %N
3295 ; PROLOG-NEXT: br i1 %cmp1.4, label %latch.4, label %latchExit.unr-lcssa.loopexit
3297 ; PROLOG-NEXT: %inc.5 = add nuw i32 %inc.4, 1
3298 ; PROLOG-NEXT: %cmp1.5 = icmp ult i32 %inc.5, %N
3299 ; PROLOG-NEXT: br i1 %cmp1.5, label %latch.5, label %latchExit.unr-lcssa.loopexit
3301 ; PROLOG-NEXT: %inc.6 = add nuw i32 %inc.5, 1
3302 ; PROLOG-NEXT: %cmp1.6 = icmp ult i32 %inc.6, %N
3303 ; PROLOG-NEXT: br i1 %cmp1.6, label %latch.6, label %latchExit.unr-lcssa.loopexit
3305 ; PROLOG-NEXT: %inc.7 = add nuw i32 %inc.6, 1
3306 ; PROLOG-NEXT: %cmp1.7 = icmp ult i32 %inc.7, %N
3307 ; PROLOG-NEXT: br i1 %cmp1.7, label %latch.7, label %latchExit.unr-lcssa.loopexit
3309 ; PROLOG-NEXT: %cmp.7 = icmp ult i32 %inc.7, %M.shifted
3310 ; PROLOG-NEXT: br i1 %cmp.7, label %header, label %latchExit.unr-lcssa.loopexit
3311 ; PROLOG: latchExit.unr-lcssa.loopexit:
3312 ; 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 ]
3313 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
3314 ; PROLOG: latchExit.unr-lcssa.loopexit1:
3315 ; PROLOG-NEXT: %i2.ph.ph.ph2 = phi i32 [ %i4.prol, %header.prol ]
3316 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
3317 ; PROLOG: latchExit.unr-lcssa:
3318 ; PROLOG-NEXT: %i2.ph.ph = phi i32 [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %i2.ph.ph.ph2, %latchExit.unr-lcssa.loopexit1 ]
3319 ; PROLOG-NEXT: br label %latchExit
3320 ; PROLOG: latchExit:
3321 ; PROLOG-NEXT: %i2.ph = phi i32 [ %i2.ph.unr, %header.prol.loopexit ], [ %i2.ph.ph, %latchExit.unr-lcssa ]
3322 ; PROLOG-NEXT: ret void
3324 ; PROLOG-BLOCK-LABEL: @unique_exit(
3325 ; PROLOG-BLOCK-NEXT: preheader:
3326 ; PROLOG-BLOCK-NEXT: %M.shifted = shl i32 %M, 3
3327 ; PROLOG-BLOCK-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3328 ; PROLOG-BLOCK-NEXT: %0 = freeze i32 %umax
3329 ; PROLOG-BLOCK-NEXT: %1 = add i32 %0, -1
3330 ; PROLOG-BLOCK-NEXT: %xtraiter = and i32 %0, 1
3331 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3332 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
3333 ; PROLOG-BLOCK: header.prol.preheader:
3334 ; PROLOG-BLOCK-NEXT: br label %header.prol
3335 ; PROLOG-BLOCK: header.prol:
3336 ; PROLOG-BLOCK-NEXT: %cmp1.prol = icmp ult i32 1, %N
3337 ; PROLOG-BLOCK-NEXT: br i1 %cmp1.prol, label %latch.prol, label %latchExit.unr-lcssa
3338 ; PROLOG-BLOCK: latch.prol:
3339 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
3340 ; PROLOG-BLOCK: header.prol.loopexit:
3341 ; PROLOG-BLOCK-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ 1, %latch.prol ]
3342 ; PROLOG-BLOCK-NEXT: %i2.ph.unr = phi i32 [ undef, %preheader ], [ -1, %latch.prol ]
3343 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i32 %1, 1
3344 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latchExit, label %preheader.new
3345 ; PROLOG-BLOCK: preheader.new:
3346 ; PROLOG-BLOCK-NEXT: br label %header
3347 ; PROLOG-BLOCK: header:
3348 ; PROLOG-BLOCK-NEXT: %i4 = phi i32 [ %i4.unr, %preheader.new ], [ %inc.1, %latch.1 ]
3349 ; PROLOG-BLOCK-NEXT: %inc = add nuw i32 %i4, 1
3350 ; PROLOG-BLOCK-NEXT: %cmp1 = icmp ult i32 %inc, %N
3351 ; PROLOG-BLOCK-NEXT: br i1 %cmp1, label %latch, label %latchExit.unr-lcssa.loopexit
3352 ; PROLOG-BLOCK: latch:
3353 ; PROLOG-BLOCK-NEXT: %inc.1 = add nuw i32 %inc, 1
3354 ; PROLOG-BLOCK-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3355 ; PROLOG-BLOCK-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.unr-lcssa.loopexit
3356 ; PROLOG-BLOCK: latch.1:
3357 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ult i32 %inc.1, %M.shifted
3358 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %header, label %latchExit.unr-lcssa.loopexit, !llvm.loop !8
3359 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
3360 ; PROLOG-BLOCK-NEXT: %i2.ph.ph.ph = phi i32 [ %i4, %header ], [ %inc, %latch ], [ -1, %latch.1 ]
3361 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
3362 ; PROLOG-BLOCK: latchExit.unr-lcssa:
3363 ; PROLOG-BLOCK-NEXT: %i2.ph.ph = phi i32 [ 0, %header.prol ], [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ]
3364 ; PROLOG-BLOCK-NEXT: br label %latchExit
3365 ; PROLOG-BLOCK: latchExit:
3366 ; PROLOG-BLOCK-NEXT: %i2.ph = phi i32 [ %i2.ph.unr, %header.prol.loopexit ], [ %i2.ph.ph, %latchExit.unr-lcssa ]
3367 ; PROLOG-BLOCK-NEXT: ret void
3371 %M.shifted = shl nuw i32 %M, 3
3374 header: ; preds = %preheader, %latch
3375 %i4 = phi i32 [ %inc, %latch ], [ 0, %preheader ]
3376 %inc = add nuw i32 %i4, 1
3377 %cmp1 = icmp ult i32 %inc, %N
3378 br i1 %cmp1, label %latch, label %latchExit
3380 latch: ; preds = %header
3381 %cmp = icmp ult i32 %inc, %M.shifted
3382 br i1 %cmp, label %header, label %latchExit
3384 latchExit: ; preds = %header, %latch
3385 %i2.ph = phi i32 [ %i4, %header ], [ -1, %latch ]
3390 ; two exiting and two exit blocks.
3391 ; the non-latch exiting block has duplicate edges to the non-latch exit block.
3392 define i64 @test5(i64 %trip, i64 %add, i1 %cond) {
3393 ; EPILOG-LABEL: @test5(
3394 ; EPILOG-NEXT: entry:
3395 ; EPILOG-NEXT: %0 = freeze i64 %trip
3396 ; EPILOG-NEXT: %1 = add i64 %0, -1
3397 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
3398 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
3399 ; EPILOG-NEXT: br i1 %2, label %latchexit.unr-lcssa, label %entry.new
3400 ; EPILOG: entry.new:
3401 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
3402 ; EPILOG-NEXT: br label %loop_header
3403 ; EPILOG: loop_header:
3404 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
3405 ; EPILOG-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
3406 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
3407 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3408 ; EPILOG: loop_exiting:
3409 ; EPILOG-NEXT: %ivy = add i64 %iv, %add
3410 ; EPILOG-NEXT: switch i64 %sum, label %loop_latch [
3411 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3412 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3414 ; EPILOG: loop_latch:
3415 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3416 ; EPILOG-NEXT: %sum.next = add i64 %sum, %add
3417 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
3418 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3419 ; EPILOG: loop_exiting.1:
3420 ; EPILOG-NEXT: %ivy.1 = add i64 %iv_next, %add
3421 ; EPILOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3422 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3423 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3425 ; EPILOG: loop_latch.1:
3426 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
3427 ; EPILOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
3428 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
3429 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting.2
3430 ; EPILOG: loop_exiting.2:
3431 ; EPILOG-NEXT: %ivy.2 = add i64 %iv_next.1, %add
3432 ; EPILOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
3433 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3434 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3436 ; EPILOG: loop_latch.2:
3437 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
3438 ; EPILOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
3439 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
3440 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting.3
3441 ; EPILOG: loop_exiting.3:
3442 ; EPILOG-NEXT: %ivy.3 = add i64 %iv_next.2, %add
3443 ; EPILOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
3444 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3445 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3447 ; EPILOG: loop_latch.3:
3448 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
3449 ; EPILOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
3450 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
3451 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting.4
3452 ; EPILOG: loop_exiting.4:
3453 ; EPILOG-NEXT: %ivy.4 = add i64 %iv_next.3, %add
3454 ; EPILOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
3455 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3456 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3458 ; EPILOG: loop_latch.4:
3459 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
3460 ; EPILOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
3461 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
3462 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting.5
3463 ; EPILOG: loop_exiting.5:
3464 ; EPILOG-NEXT: %ivy.5 = add i64 %iv_next.4, %add
3465 ; EPILOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
3466 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3467 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3469 ; EPILOG: loop_latch.5:
3470 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
3471 ; EPILOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
3472 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
3473 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting.6
3474 ; EPILOG: loop_exiting.6:
3475 ; EPILOG-NEXT: %ivy.6 = add i64 %iv_next.5, %add
3476 ; EPILOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
3477 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3478 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3480 ; EPILOG: loop_latch.6:
3481 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
3482 ; EPILOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
3483 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
3484 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting.7
3485 ; EPILOG: loop_exiting.7:
3486 ; EPILOG-NEXT: %ivy.7 = add i64 %iv_next.6, %add
3487 ; EPILOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
3488 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3489 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3491 ; EPILOG: loop_latch.7:
3492 ; EPILOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv_next.6, 1
3493 ; EPILOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
3494 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
3495 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
3496 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %latchexit.unr-lcssa.loopexit
3497 ; EPILOG: exit1.loopexit:
3498 ; 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 ]
3499 ; EPILOG-NEXT: br label %exit1
3500 ; EPILOG: exit1.loopexit2:
3501 ; EPILOG-NEXT: %result.ph3 = phi i64 [ %ivy.epil, %loop_exiting.epil ], [ %ivy.epil, %loop_exiting.epil ]
3502 ; EPILOG-NEXT: br label %exit1
3504 ; EPILOG-NEXT: %result = phi i64 [ %result.ph, %exit1.loopexit ], [ %result.ph3, %exit1.loopexit2 ]
3505 ; EPILOG-NEXT: ret i64 %result
3506 ; EPILOG: latchexit.unr-lcssa.loopexit:
3507 ; EPILOG-NEXT: %sum.next.lcssa.ph.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
3508 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
3509 ; EPILOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
3510 ; EPILOG-NEXT: br label %latchexit.unr-lcssa
3511 ; EPILOG: latchexit.unr-lcssa:
3512 ; EPILOG-NEXT: %sum.next.lcssa.ph = phi i64 [ undef, %entry ], [ %sum.next.lcssa.ph.ph, %latchexit.unr-lcssa.loopexit ]
3513 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %latchexit.unr-lcssa.loopexit ]
3514 ; EPILOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %latchexit.unr-lcssa.loopexit ]
3515 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3516 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %latchexit
3517 ; EPILOG: loop_header.epil.preheader:
3518 ; EPILOG-NEXT: br label %loop_header.epil
3519 ; EPILOG: loop_header.epil:
3520 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
3521 ; EPILOG-NEXT: %sum.epil = phi i64 [ %sum.unr, %loop_header.epil.preheader ], [ %sum.next.epil, %loop_latch.epil ]
3522 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
3523 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting.epil
3524 ; EPILOG: loop_exiting.epil:
3525 ; EPILOG-NEXT: %ivy.epil = add i64 %iv.epil, %add
3526 ; EPILOG-NEXT: switch i64 %sum.epil, label %loop_latch.epil [
3527 ; EPILOG-NEXT: i64 24, label %exit1.loopexit2
3528 ; EPILOG-NEXT: i64 42, label %exit1.loopexit2
3530 ; EPILOG: loop_latch.epil:
3531 ; EPILOG-NEXT: %iv_next.epil = add nuw nsw i64 %iv.epil, 1
3532 ; EPILOG-NEXT: %sum.next.epil = add i64 %sum.epil, %add
3533 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
3534 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
3535 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
3536 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %latchexit.epilog-lcssa, !llvm.loop !9
3537 ; EPILOG: latchexit.epilog-lcssa:
3538 ; EPILOG-NEXT: %sum.next.lcssa.ph1 = phi i64 [ %sum.next.epil, %loop_latch.epil ]
3539 ; EPILOG-NEXT: br label %latchexit
3540 ; EPILOG: latchexit:
3541 ; EPILOG-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ], [ %sum.next.lcssa.ph1, %latchexit.epilog-lcssa ]
3542 ; EPILOG-NEXT: ret i64 %sum.next.lcssa
3544 ; EPILOG-BLOCK-LABEL: @test5(
3545 ; EPILOG-BLOCK-NEXT: entry:
3546 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
3547 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
3548 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
3549 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
3550 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchexit.unr-lcssa, label %entry.new
3551 ; EPILOG-BLOCK: entry.new:
3552 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
3553 ; EPILOG-BLOCK-NEXT: br label %loop_header
3554 ; EPILOG-BLOCK: loop_header:
3555 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
3556 ; EPILOG-BLOCK-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
3557 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
3558 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3559 ; EPILOG-BLOCK: loop_exiting:
3560 ; EPILOG-BLOCK-NEXT: %ivy = add i64 %iv, %add
3561 ; EPILOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
3562 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3563 ; EPILOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3564 ; EPILOG-BLOCK-NEXT: ]
3565 ; EPILOG-BLOCK: loop_latch:
3566 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3567 ; EPILOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
3568 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
3569 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3570 ; EPILOG-BLOCK: loop_exiting.1:
3571 ; EPILOG-BLOCK-NEXT: %ivy.1 = add i64 %iv_next, %add
3572 ; EPILOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3573 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3574 ; EPILOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3575 ; EPILOG-BLOCK-NEXT: ]
3576 ; EPILOG-BLOCK: loop_latch.1:
3577 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
3578 ; EPILOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
3579 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
3580 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
3581 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %latchexit.unr-lcssa.loopexit, !llvm.loop !9
3582 ; EPILOG-BLOCK: exit1.loopexit:
3583 ; EPILOG-BLOCK-NEXT: %result.ph = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.1, %loop_exiting.1 ]
3584 ; EPILOG-BLOCK-NEXT: br label %exit1
3585 ; EPILOG-BLOCK: exit1:
3586 ; EPILOG-BLOCK-NEXT: %result = phi i64 [ %ivy.epil, %loop_exiting.epil ], [ %ivy.epil, %loop_exiting.epil ], [ %result.ph, %exit1.loopexit ]
3587 ; EPILOG-BLOCK-NEXT: ret i64 %result
3588 ; EPILOG-BLOCK: latchexit.unr-lcssa.loopexit:
3589 ; EPILOG-BLOCK-NEXT: %sum.next.lcssa.ph.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
3590 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
3591 ; EPILOG-BLOCK-NEXT: %sum.unr.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
3592 ; EPILOG-BLOCK-NEXT: br label %latchexit.unr-lcssa
3593 ; EPILOG-BLOCK: latchexit.unr-lcssa:
3594 ; EPILOG-BLOCK-NEXT: %sum.next.lcssa.ph = phi i64 [ undef, %entry ], [ %sum.next.lcssa.ph.ph, %latchexit.unr-lcssa.loopexit ]
3595 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %latchexit.unr-lcssa.loopexit ]
3596 ; EPILOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %latchexit.unr-lcssa.loopexit ]
3597 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3598 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %latchexit
3599 ; EPILOG-BLOCK: loop_header.epil.preheader:
3600 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
3601 ; EPILOG-BLOCK: loop_header.epil:
3602 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting.epil
3603 ; EPILOG-BLOCK: loop_exiting.epil:
3604 ; EPILOG-BLOCK-NEXT: %ivy.epil = add i64 %iv.unr, %add
3605 ; EPILOG-BLOCK-NEXT: switch i64 %sum.unr, label %loop_latch.epil [
3606 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1
3607 ; EPILOG-BLOCK-NEXT: i64 42, label %exit1
3608 ; EPILOG-BLOCK-NEXT: ]
3609 ; EPILOG-BLOCK: loop_latch.epil:
3610 ; EPILOG-BLOCK-NEXT: %sum.next.epil = add i64 %sum.unr, %add
3611 ; EPILOG-BLOCK-NEXT: br label %latchexit
3612 ; EPILOG-BLOCK: latchexit:
3613 ; EPILOG-BLOCK-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ], [ %sum.next.epil, %loop_latch.epil ]
3614 ; EPILOG-BLOCK-NEXT: ret i64 %sum.next.lcssa
3616 ; PROLOG-LABEL: @test5(
3617 ; PROLOG-NEXT: entry:
3618 ; PROLOG-NEXT: %0 = freeze i64 %trip
3619 ; PROLOG-NEXT: %1 = add i64 %0, -1
3620 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
3621 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3622 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
3623 ; PROLOG: loop_header.prol.preheader:
3624 ; PROLOG-NEXT: br label %loop_header.prol
3625 ; PROLOG: loop_header.prol:
3626 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
3627 ; PROLOG-NEXT: %sum.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %sum.next.prol, %loop_latch.prol ]
3628 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
3629 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting.prol
3630 ; PROLOG: loop_exiting.prol:
3631 ; PROLOG-NEXT: %ivy.prol = add i64 %iv.prol, %add
3632 ; PROLOG-NEXT: switch i64 %sum.prol, label %loop_latch.prol [
3633 ; PROLOG-NEXT: i64 24, label %exit1.loopexit1
3634 ; PROLOG-NEXT: i64 42, label %exit1.loopexit1
3636 ; PROLOG: loop_latch.prol:
3637 ; PROLOG-NEXT: %iv_next.prol = add nuw nsw i64 %iv.prol, 1
3638 ; PROLOG-NEXT: %sum.next.prol = add i64 %sum.prol, %add
3639 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
3640 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
3641 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
3642 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !9
3643 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
3644 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
3645 ; PROLOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.prol, %loop_latch.prol ]
3646 ; PROLOG-NEXT: %sum.next.lcssa.unr.ph = phi i64 [ %sum.next.prol, %loop_latch.prol ]
3647 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
3648 ; PROLOG: loop_header.prol.loopexit:
3649 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
3650 ; PROLOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
3651 ; PROLOG-NEXT: %sum.next.lcssa.unr = phi i64 [ undef, %entry ], [ %sum.next.lcssa.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
3652 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
3653 ; PROLOG-NEXT: br i1 %2, label %latchexit, label %entry.new
3654 ; PROLOG: entry.new:
3655 ; PROLOG-NEXT: br label %loop_header
3656 ; PROLOG: loop_header:
3657 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
3658 ; PROLOG-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
3659 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3660 ; PROLOG: loop_exiting:
3661 ; PROLOG-NEXT: %ivy = add i64 %iv, %add
3662 ; PROLOG-NEXT: switch i64 %sum, label %loop_latch [
3663 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3664 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3666 ; PROLOG: loop_latch:
3667 ; PROLOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3668 ; PROLOG-NEXT: %sum.next = add i64 %sum, %add
3669 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3670 ; PROLOG: loop_exiting.1:
3671 ; PROLOG-NEXT: %ivy.1 = add i64 %iv_next, %add
3672 ; PROLOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3673 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3674 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3676 ; PROLOG: loop_latch.1:
3677 ; PROLOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
3678 ; PROLOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
3679 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting.2
3680 ; PROLOG: loop_exiting.2:
3681 ; PROLOG-NEXT: %ivy.2 = add i64 %iv_next.1, %add
3682 ; PROLOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
3683 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3684 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3686 ; PROLOG: loop_latch.2:
3687 ; PROLOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
3688 ; PROLOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
3689 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting.3
3690 ; PROLOG: loop_exiting.3:
3691 ; PROLOG-NEXT: %ivy.3 = add i64 %iv_next.2, %add
3692 ; PROLOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
3693 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3694 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3696 ; PROLOG: loop_latch.3:
3697 ; PROLOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
3698 ; PROLOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
3699 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting.4
3700 ; PROLOG: loop_exiting.4:
3701 ; PROLOG-NEXT: %ivy.4 = add i64 %iv_next.3, %add
3702 ; PROLOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
3703 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3704 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3706 ; PROLOG: loop_latch.4:
3707 ; PROLOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
3708 ; PROLOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
3709 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting.5
3710 ; PROLOG: loop_exiting.5:
3711 ; PROLOG-NEXT: %ivy.5 = add i64 %iv_next.4, %add
3712 ; PROLOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
3713 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3714 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3716 ; PROLOG: loop_latch.5:
3717 ; PROLOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
3718 ; PROLOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
3719 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting.6
3720 ; PROLOG: loop_exiting.6:
3721 ; PROLOG-NEXT: %ivy.6 = add i64 %iv_next.5, %add
3722 ; PROLOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
3723 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3724 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3726 ; PROLOG: loop_latch.6:
3727 ; PROLOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
3728 ; PROLOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
3729 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting.7
3730 ; PROLOG: loop_exiting.7:
3731 ; PROLOG-NEXT: %ivy.7 = add i64 %iv_next.6, %add
3732 ; PROLOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
3733 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3734 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3736 ; PROLOG: loop_latch.7:
3737 ; PROLOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv_next.6, 1
3738 ; PROLOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
3739 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
3740 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %latchexit.unr-lcssa
3741 ; PROLOG: exit1.loopexit:
3742 ; 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 ]
3743 ; PROLOG-NEXT: br label %exit1
3744 ; PROLOG: exit1.loopexit1:
3745 ; PROLOG-NEXT: %result.ph2 = phi i64 [ %ivy.prol, %loop_exiting.prol ], [ %ivy.prol, %loop_exiting.prol ]
3746 ; PROLOG-NEXT: br label %exit1
3748 ; PROLOG-NEXT: %result = phi i64 [ %result.ph, %exit1.loopexit ], [ %result.ph2, %exit1.loopexit1 ]
3749 ; PROLOG-NEXT: ret i64 %result
3750 ; PROLOG: latchexit.unr-lcssa:
3751 ; PROLOG-NEXT: %sum.next.lcssa.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
3752 ; PROLOG-NEXT: br label %latchexit
3753 ; PROLOG: latchexit:
3754 ; PROLOG-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.unr, %loop_header.prol.loopexit ], [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ]
3755 ; PROLOG-NEXT: ret i64 %sum.next.lcssa
3757 ; PROLOG-BLOCK-LABEL: @test5(
3758 ; PROLOG-BLOCK-NEXT: entry:
3759 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
3760 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
3761 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
3762 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3763 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
3764 ; PROLOG-BLOCK: loop_header.prol.preheader:
3765 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
3766 ; PROLOG-BLOCK: loop_header.prol:
3767 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting.prol
3768 ; PROLOG-BLOCK: loop_exiting.prol:
3769 ; PROLOG-BLOCK-NEXT: switch i64 0, label %loop_latch.prol [
3770 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1
3771 ; PROLOG-BLOCK-NEXT: i64 42, label %exit1
3772 ; PROLOG-BLOCK-NEXT: ]
3773 ; PROLOG-BLOCK: loop_latch.prol:
3774 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
3775 ; PROLOG-BLOCK: loop_header.prol.loopexit:
3776 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
3777 ; PROLOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %add, %loop_latch.prol ]
3778 ; PROLOG-BLOCK-NEXT: %sum.next.lcssa.unr = phi i64 [ undef, %entry ], [ %add, %loop_latch.prol ]
3779 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
3780 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latchexit, label %entry.new
3781 ; PROLOG-BLOCK: entry.new:
3782 ; PROLOG-BLOCK-NEXT: br label %loop_header
3783 ; PROLOG-BLOCK: loop_header:
3784 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
3785 ; PROLOG-BLOCK-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
3786 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3787 ; PROLOG-BLOCK: loop_exiting:
3788 ; PROLOG-BLOCK-NEXT: %ivy = add i64 %iv, %add
3789 ; PROLOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
3790 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3791 ; PROLOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3792 ; PROLOG-BLOCK-NEXT: ]
3793 ; PROLOG-BLOCK: loop_latch:
3794 ; PROLOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3795 ; PROLOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
3796 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3797 ; PROLOG-BLOCK: loop_exiting.1:
3798 ; PROLOG-BLOCK-NEXT: %ivy.1 = add i64 %iv_next, %add
3799 ; PROLOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3800 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3801 ; PROLOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3802 ; PROLOG-BLOCK-NEXT: ]
3803 ; PROLOG-BLOCK: loop_latch.1:
3804 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
3805 ; PROLOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
3806 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
3807 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %latchexit.unr-lcssa, !llvm.loop !9
3808 ; PROLOG-BLOCK: exit1.loopexit:
3809 ; PROLOG-BLOCK-NEXT: %result.ph = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.1, %loop_exiting.1 ]
3810 ; PROLOG-BLOCK-NEXT: br label %exit1
3811 ; PROLOG-BLOCK: exit1:
3812 ; PROLOG-BLOCK-NEXT: %result = phi i64 [ %add, %loop_exiting.prol ], [ %add, %loop_exiting.prol ], [ %result.ph, %exit1.loopexit ]
3813 ; PROLOG-BLOCK-NEXT: ret i64 %result
3814 ; PROLOG-BLOCK: latchexit.unr-lcssa:
3815 ; PROLOG-BLOCK-NEXT: %sum.next.lcssa.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
3816 ; PROLOG-BLOCK-NEXT: br label %latchexit
3817 ; PROLOG-BLOCK: latchexit:
3818 ; PROLOG-BLOCK-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.unr, %loop_header.prol.loopexit ], [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ]
3819 ; PROLOG-BLOCK-NEXT: ret i64 %sum.next.lcssa
3823 br label %loop_header
3826 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
3827 %sum = phi i64 [ 0, %entry ], [ %sum.next, %loop_latch ]
3828 br i1 %cond, label %loop_latch, label %loop_exiting
3831 %ivy = add i64 %iv, %add
3832 switch i64 %sum, label %loop_latch [
3833 i64 24, label %exit1
3834 i64 42, label %exit1
3838 %iv_next = add nuw nsw i64 %iv, 1
3839 %sum.next = add i64 %sum, %add
3840 %cmp = icmp ne i64 %iv_next, %trip
3841 br i1 %cmp, label %loop_header, label %latchexit
3844 %result = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ]
3851 ; test when exit blocks have successors.
3852 define i32 @test6(i32* nocapture %a, i64 %n, i1 %cond, i32 %x) {
3853 ; EPILOG-LABEL: @test6(
3854 ; EPILOG-NEXT: entry:
3855 ; EPILOG-NEXT: %0 = freeze i64 %n
3856 ; EPILOG-NEXT: %1 = add i64 %0, -1
3857 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
3858 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
3859 ; EPILOG-NEXT: br i1 %2, label %latch_exit.unr-lcssa, label %entry.new
3860 ; EPILOG: entry.new:
3861 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
3862 ; EPILOG-NEXT: br label %header
3864 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
3865 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
3866 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
3867 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
3868 ; EPILOG: for.exiting_block:
3869 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
3870 ; EPILOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
3872 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
3873 ; EPILOG-NEXT: %load = load i32, i32* %arrayidx, align 4
3874 ; EPILOG-NEXT: %add = add nsw i32 %load, %sum.02
3875 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
3876 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
3877 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
3878 ; EPILOG: for.exiting_block.1:
3879 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
3880 ; EPILOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
3882 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
3883 ; EPILOG-NEXT: %load.1 = load i32, i32* %arrayidx.1, align 4
3884 ; EPILOG-NEXT: %add.1 = add nsw i32 %load.1, %add
3885 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv.next, 1
3886 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
3887 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
3888 ; EPILOG: for.exiting_block.2:
3889 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
3890 ; EPILOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
3892 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
3893 ; EPILOG-NEXT: %load.2 = load i32, i32* %arrayidx.2, align 4
3894 ; EPILOG-NEXT: %add.2 = add nsw i32 %load.2, %add.1
3895 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv.next.1, 1
3896 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
3897 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
3898 ; EPILOG: for.exiting_block.3:
3899 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
3900 ; EPILOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
3902 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
3903 ; EPILOG-NEXT: %load.3 = load i32, i32* %arrayidx.3, align 4
3904 ; EPILOG-NEXT: %add.3 = add nsw i32 %load.3, %add.2
3905 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv.next.2, 1
3906 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
3907 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
3908 ; EPILOG: for.exiting_block.4:
3909 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
3910 ; EPILOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
3912 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
3913 ; EPILOG-NEXT: %load.4 = load i32, i32* %arrayidx.4, align 4
3914 ; EPILOG-NEXT: %add.4 = add nsw i32 %load.4, %add.3
3915 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv.next.3, 1
3916 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
3917 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
3918 ; EPILOG: for.exiting_block.5:
3919 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
3920 ; EPILOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
3922 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
3923 ; EPILOG-NEXT: %load.5 = load i32, i32* %arrayidx.5, align 4
3924 ; EPILOG-NEXT: %add.5 = add nsw i32 %load.5, %add.4
3925 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv.next.4, 1
3926 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
3927 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
3928 ; EPILOG: for.exiting_block.6:
3929 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
3930 ; EPILOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
3932 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
3933 ; EPILOG-NEXT: %load.6 = load i32, i32* %arrayidx.6, align 4
3934 ; EPILOG-NEXT: %add.6 = add nsw i32 %load.6, %add.5
3935 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv.next.5, 1
3936 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
3937 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
3938 ; EPILOG: for.exiting_block.7:
3939 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
3940 ; EPILOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
3942 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
3943 ; EPILOG-NEXT: %load.7 = load i32, i32* %arrayidx.7, align 4
3944 ; EPILOG-NEXT: %add.7 = add nsw i32 %load.7, %add.6
3945 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
3946 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
3947 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
3948 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latch_exit.unr-lcssa.loopexit, label %header
3949 ; EPILOG: latch_exit.unr-lcssa.loopexit:
3950 ; EPILOG-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.7, %latch.7 ]
3951 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
3952 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
3953 ; EPILOG-NEXT: br label %latch_exit.unr-lcssa
3954 ; EPILOG: latch_exit.unr-lcssa:
3955 ; EPILOG-NEXT: %sum.0.lcssa.ph = phi i32 [ undef, %entry ], [ %sum.0.lcssa.ph.ph, %latch_exit.unr-lcssa.loopexit ]
3956 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latch_exit.unr-lcssa.loopexit ]
3957 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latch_exit.unr-lcssa.loopexit ]
3958 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3959 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latch_exit
3960 ; EPILOG: header.epil.preheader:
3961 ; EPILOG-NEXT: br label %header.epil
3962 ; EPILOG: header.epil:
3963 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
3964 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
3965 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
3966 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit2, label %for.exiting_block.epil
3967 ; EPILOG: for.exiting_block.epil:
3968 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
3969 ; EPILOG-NEXT: br i1 %cmp.epil, label %for.exit2.loopexit2, label %latch.epil
3970 ; EPILOG: latch.epil:
3971 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.epil
3972 ; EPILOG-NEXT: %load.epil = load i32, i32* %arrayidx.epil, align 4
3973 ; EPILOG-NEXT: %add.epil = add nsw i32 %load.epil, %sum.02.epil
3974 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
3975 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
3976 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
3977 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
3978 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latch_exit.epilog-lcssa, !llvm.loop !10
3979 ; EPILOG: latch_exit.epilog-lcssa:
3980 ; EPILOG-NEXT: %sum.0.lcssa.ph1 = phi i32 [ %add.epil, %latch.epil ]
3981 ; EPILOG-NEXT: br label %latch_exit
3982 ; EPILOG: latch_exit:
3983 ; EPILOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ], [ %sum.0.lcssa.ph1, %latch_exit.epilog-lcssa ]
3984 ; EPILOG-NEXT: ret i32 %sum.0.lcssa
3985 ; EPILOG: for.exit2.loopexit:
3986 ; 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 ]
3987 ; EPILOG-NEXT: br label %for.exit2
3988 ; EPILOG: for.exit2.loopexit2:
3989 ; EPILOG-NEXT: %retval.ph3 = phi i32 [ 42, %for.exiting_block.epil ], [ %sum.02.epil, %header.epil ]
3990 ; EPILOG-NEXT: br label %for.exit2
3991 ; EPILOG: for.exit2:
3992 ; EPILOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph3, %for.exit2.loopexit2 ]
3993 ; EPILOG-NEXT: %addx = add i32 %retval, %x
3994 ; EPILOG-NEXT: br i1 %cond, label %exit_true, label %exit_false
3995 ; EPILOG: exit_true:
3996 ; EPILOG-NEXT: ret i32 %retval
3997 ; EPILOG: exit_false:
3998 ; EPILOG-NEXT: ret i32 %addx
4000 ; EPILOG-BLOCK-LABEL: @test6(
4001 ; EPILOG-BLOCK-NEXT: entry:
4002 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
4003 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
4004 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4005 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4006 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latch_exit.unr-lcssa, label %entry.new
4007 ; EPILOG-BLOCK: entry.new:
4008 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
4009 ; EPILOG-BLOCK-NEXT: br label %header
4010 ; EPILOG-BLOCK: header:
4011 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
4012 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
4013 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
4014 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
4015 ; EPILOG-BLOCK: for.exiting_block:
4016 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
4017 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
4018 ; EPILOG-BLOCK: latch:
4019 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
4020 ; EPILOG-BLOCK-NEXT: %load = load i32, i32* %arrayidx, align 4
4021 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %load, %sum.02
4022 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
4023 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
4024 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
4025 ; EPILOG-BLOCK: for.exiting_block.1:
4026 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
4027 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
4028 ; EPILOG-BLOCK: latch.1:
4029 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
4030 ; EPILOG-BLOCK-NEXT: %load.1 = load i32, i32* %arrayidx.1, align 4
4031 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %load.1, %add
4032 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
4033 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
4034 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
4035 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latch_exit.unr-lcssa.loopexit, label %header, !llvm.loop !10
4036 ; EPILOG-BLOCK: latch_exit.unr-lcssa.loopexit:
4037 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.1, %latch.1 ]
4038 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
4039 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
4040 ; EPILOG-BLOCK-NEXT: br label %latch_exit.unr-lcssa
4041 ; EPILOG-BLOCK: latch_exit.unr-lcssa:
4042 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ undef, %entry ], [ %sum.0.lcssa.ph.ph, %latch_exit.unr-lcssa.loopexit ]
4043 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latch_exit.unr-lcssa.loopexit ]
4044 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latch_exit.unr-lcssa.loopexit ]
4045 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4046 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latch_exit
4047 ; EPILOG-BLOCK: header.epil.preheader:
4048 ; EPILOG-BLOCK-NEXT: br label %header.epil
4049 ; EPILOG-BLOCK: header.epil:
4050 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.epil
4051 ; EPILOG-BLOCK: for.exiting_block.epil:
4052 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
4053 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %for.exit2, label %latch.epil
4054 ; EPILOG-BLOCK: latch.epil:
4055 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.unr
4056 ; EPILOG-BLOCK-NEXT: %load.epil = load i32, i32* %arrayidx.epil, align 4
4057 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %load.epil, %sum.02.unr
4058 ; EPILOG-BLOCK-NEXT: br label %latch_exit
4059 ; EPILOG-BLOCK: latch_exit:
4060 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ], [ %add.epil, %latch.epil ]
4061 ; EPILOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
4062 ; EPILOG-BLOCK: for.exit2.loopexit:
4063 ; EPILOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %latch ], [ 42, %for.exiting_block.1 ]
4064 ; EPILOG-BLOCK-NEXT: br label %for.exit2
4065 ; EPILOG-BLOCK: for.exit2:
4066 ; EPILOG-BLOCK-NEXT: %retval = phi i32 [ %sum.02.unr, %header.epil ], [ 42, %for.exiting_block.epil ], [ %retval.ph, %for.exit2.loopexit ]
4067 ; EPILOG-BLOCK-NEXT: %addx = add i32 %retval, %x
4068 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %exit_true, label %exit_false
4069 ; EPILOG-BLOCK: exit_true:
4070 ; EPILOG-BLOCK-NEXT: ret i32 %retval
4071 ; EPILOG-BLOCK: exit_false:
4072 ; EPILOG-BLOCK-NEXT: ret i32 %addx
4074 ; PROLOG-LABEL: @test6(
4075 ; PROLOG-NEXT: entry:
4076 ; PROLOG-NEXT: %0 = freeze i64 %n
4077 ; PROLOG-NEXT: %1 = add i64 %0, -1
4078 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
4079 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4080 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4081 ; PROLOG: header.prol.preheader:
4082 ; PROLOG-NEXT: br label %header.prol
4083 ; PROLOG: header.prol:
4084 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
4085 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
4086 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
4087 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit1, label %for.exiting_block.prol
4088 ; PROLOG: for.exiting_block.prol:
4089 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
4090 ; PROLOG-NEXT: br i1 %cmp.prol, label %for.exit2.loopexit1, label %latch.prol
4091 ; PROLOG: latch.prol:
4092 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.prol
4093 ; PROLOG-NEXT: %load.prol = load i32, i32* %arrayidx.prol, align 4
4094 ; PROLOG-NEXT: %add.prol = add nsw i32 %load.prol, %sum.02.prol
4095 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
4096 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
4097 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
4098 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
4099 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !10
4100 ; PROLOG: header.prol.loopexit.unr-lcssa:
4101 ; PROLOG-NEXT: %sum.0.lcssa.unr.ph = phi i32 [ %add.prol, %latch.prol ]
4102 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
4103 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
4104 ; PROLOG-NEXT: br label %header.prol.loopexit
4105 ; PROLOG: header.prol.loopexit:
4106 ; PROLOG-NEXT: %sum.0.lcssa.unr = phi i32 [ undef, %entry ], [ %sum.0.lcssa.unr.ph, %header.prol.loopexit.unr-lcssa ]
4107 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
4108 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
4109 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
4110 ; PROLOG-NEXT: br i1 %2, label %latch_exit, label %entry.new
4111 ; PROLOG: entry.new:
4112 ; PROLOG-NEXT: br label %header
4114 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
4115 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
4116 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
4117 ; PROLOG: for.exiting_block:
4118 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
4119 ; PROLOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
4121 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
4122 ; PROLOG-NEXT: %load = load i32, i32* %arrayidx, align 4
4123 ; PROLOG-NEXT: %add = add nsw i32 %load, %sum.02
4124 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
4125 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
4126 ; PROLOG: for.exiting_block.1:
4127 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
4128 ; PROLOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
4130 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
4131 ; PROLOG-NEXT: %load.1 = load i32, i32* %arrayidx.1, align 4
4132 ; PROLOG-NEXT: %add.1 = add nsw i32 %load.1, %add
4133 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
4134 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
4135 ; PROLOG: for.exiting_block.2:
4136 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
4137 ; PROLOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
4139 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.1
4140 ; PROLOG-NEXT: %load.2 = load i32, i32* %arrayidx.2, align 4
4141 ; PROLOG-NEXT: %add.2 = add nsw i32 %load.2, %add.1
4142 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv.next.1, 1
4143 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
4144 ; PROLOG: for.exiting_block.3:
4145 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
4146 ; PROLOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
4148 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.2
4149 ; PROLOG-NEXT: %load.3 = load i32, i32* %arrayidx.3, align 4
4150 ; PROLOG-NEXT: %add.3 = add nsw i32 %load.3, %add.2
4151 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv.next.2, 1
4152 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
4153 ; PROLOG: for.exiting_block.4:
4154 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
4155 ; PROLOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
4157 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.3
4158 ; PROLOG-NEXT: %load.4 = load i32, i32* %arrayidx.4, align 4
4159 ; PROLOG-NEXT: %add.4 = add nsw i32 %load.4, %add.3
4160 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv.next.3, 1
4161 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
4162 ; PROLOG: for.exiting_block.5:
4163 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
4164 ; PROLOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
4166 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.4
4167 ; PROLOG-NEXT: %load.5 = load i32, i32* %arrayidx.5, align 4
4168 ; PROLOG-NEXT: %add.5 = add nsw i32 %load.5, %add.4
4169 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv.next.4, 1
4170 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
4171 ; PROLOG: for.exiting_block.6:
4172 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
4173 ; PROLOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
4175 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.5
4176 ; PROLOG-NEXT: %load.6 = load i32, i32* %arrayidx.6, align 4
4177 ; PROLOG-NEXT: %add.6 = add nsw i32 %load.6, %add.5
4178 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv.next.5, 1
4179 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
4180 ; PROLOG: for.exiting_block.7:
4181 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
4182 ; PROLOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
4184 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next.6
4185 ; PROLOG-NEXT: %load.7 = load i32, i32* %arrayidx.7, align 4
4186 ; PROLOG-NEXT: %add.7 = add nsw i32 %load.7, %add.6
4187 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv.next.6, 1
4188 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
4189 ; PROLOG-NEXT: br i1 %exitcond.7, label %latch_exit.unr-lcssa, label %header
4190 ; PROLOG: latch_exit.unr-lcssa:
4191 ; PROLOG-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.7, %latch.7 ]
4192 ; PROLOG-NEXT: br label %latch_exit
4193 ; PROLOG: latch_exit:
4194 ; PROLOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ]
4195 ; PROLOG-NEXT: ret i32 %sum.0.lcssa
4196 ; PROLOG: for.exit2.loopexit:
4197 ; 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 ]
4198 ; PROLOG-NEXT: br label %for.exit2
4199 ; PROLOG: for.exit2.loopexit1:
4200 ; PROLOG-NEXT: %retval.ph2 = phi i32 [ 42, %for.exiting_block.prol ], [ %sum.02.prol, %header.prol ]
4201 ; PROLOG-NEXT: br label %for.exit2
4202 ; PROLOG: for.exit2:
4203 ; PROLOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph2, %for.exit2.loopexit1 ]
4204 ; PROLOG-NEXT: %addx = add i32 %retval, %x
4205 ; PROLOG-NEXT: br i1 %cond, label %exit_true, label %exit_false
4206 ; PROLOG: exit_true:
4207 ; PROLOG-NEXT: ret i32 %retval
4208 ; PROLOG: exit_false:
4209 ; PROLOG-NEXT: ret i32 %addx
4211 ; PROLOG-BLOCK-LABEL: @test6(
4212 ; PROLOG-BLOCK-NEXT: entry:
4213 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
4214 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
4215 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4216 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4217 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4218 ; PROLOG-BLOCK: header.prol.preheader:
4219 ; PROLOG-BLOCK-NEXT: br label %header.prol
4220 ; PROLOG-BLOCK: header.prol:
4221 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.prol
4222 ; PROLOG-BLOCK: for.exiting_block.prol:
4223 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
4224 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %for.exit2, label %latch.prol
4225 ; PROLOG-BLOCK: latch.prol:
4226 ; PROLOG-BLOCK-NEXT: %load.prol = load i32, i32* %a, align 4
4227 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
4228 ; PROLOG-BLOCK: header.prol.loopexit:
4229 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.unr = phi i32 [ undef, %entry ], [ %load.prol, %latch.prol ]
4230 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
4231 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %load.prol, %latch.prol ]
4232 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4233 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latch_exit, label %entry.new
4234 ; PROLOG-BLOCK: entry.new:
4235 ; PROLOG-BLOCK-NEXT: br label %header
4236 ; PROLOG-BLOCK: header:
4237 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
4238 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
4239 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
4240 ; PROLOG-BLOCK: for.exiting_block:
4241 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
4242 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
4243 ; PROLOG-BLOCK: latch:
4244 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
4245 ; PROLOG-BLOCK-NEXT: %load = load i32, i32* %arrayidx, align 4
4246 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %load, %sum.02
4247 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
4248 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
4249 ; PROLOG-BLOCK: for.exiting_block.1:
4250 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
4251 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
4252 ; PROLOG-BLOCK: latch.1:
4253 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, i32* %a, i64 %indvars.iv.next
4254 ; PROLOG-BLOCK-NEXT: %load.1 = load i32, i32* %arrayidx.1, align 4
4255 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %load.1, %add
4256 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv.next, 1
4257 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
4258 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latch_exit.unr-lcssa, label %header, !llvm.loop !10
4259 ; PROLOG-BLOCK: latch_exit.unr-lcssa:
4260 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.1, %latch.1 ]
4261 ; PROLOG-BLOCK-NEXT: br label %latch_exit
4262 ; PROLOG-BLOCK: latch_exit:
4263 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ]
4264 ; PROLOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
4265 ; PROLOG-BLOCK: for.exit2.loopexit:
4266 ; PROLOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %latch ], [ 42, %for.exiting_block.1 ]
4267 ; PROLOG-BLOCK-NEXT: br label %for.exit2
4268 ; PROLOG-BLOCK: for.exit2:
4269 ; PROLOG-BLOCK-NEXT: %retval = phi i32 [ 0, %header.prol ], [ 42, %for.exiting_block.prol ], [ %retval.ph, %for.exit2.loopexit ]
4270 ; PROLOG-BLOCK-NEXT: %addx = add i32 %retval, %x
4271 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %exit_true, label %exit_false
4272 ; PROLOG-BLOCK: exit_true:
4273 ; PROLOG-BLOCK-NEXT: ret i32 %retval
4274 ; PROLOG-BLOCK: exit_false:
4275 ; PROLOG-BLOCK-NEXT: ret i32 %addx
4282 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
4283 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
4284 br i1 false, label %for.exit2, label %for.exiting_block
4287 %cmp = icmp eq i64 %n, 42
4288 br i1 %cmp, label %for.exit2, label %latch
4291 %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv
4292 %load = load i32, i32* %arrayidx, align 4
4293 %add = add nsw i32 %load, %sum.02
4294 %indvars.iv.next = add i64 %indvars.iv, 1
4295 %exitcond = icmp eq i64 %indvars.iv.next, %n
4296 br i1 %exitcond, label %latch_exit, label %header
4299 %sum.0.lcssa = phi i32 [ %add, %latch ]
4300 ret i32 %sum.0.lcssa
4303 %retval = phi i32 [ %sum.02, %header ], [ 42, %for.exiting_block ]
4304 %addx = add i32 %retval, %x
4305 br i1 %cond, label %exit_true, label %exit_false
4314 ; test when value in exit block does not have VMap.
4315 define i32 @test7(i32 %arg, i32 %arg1, i32 %arg2) {
4316 ; EPILOG-LABEL: @test7(
4318 ; EPILOG-NEXT: %i = icmp slt i32 undef, 2
4319 ; EPILOG-NEXT: %sext = sext i32 undef to i64
4320 ; EPILOG-NEXT: %shft = ashr exact i32 %arg, 16
4321 ; EPILOG-NEXT: br i1 %i, label %loopexit2, label %preheader
4322 ; EPILOG: preheader:
4323 ; EPILOG-NEXT: %0 = add nsw i64 %sext, -1
4324 ; EPILOG-NEXT: %1 = freeze i64 %0
4325 ; EPILOG-NEXT: %2 = add i64 %1, -1
4326 ; EPILOG-NEXT: %xtraiter = and i64 %1, 7
4327 ; EPILOG-NEXT: %3 = icmp ult i64 %2, 7
4328 ; EPILOG-NEXT: br i1 %3, label %latchexit.unr-lcssa, label %preheader.new
4329 ; EPILOG: preheader.new:
4330 ; EPILOG-NEXT: %unroll_iter = sub i64 %1, %xtraiter
4331 ; EPILOG-NEXT: br label %header
4333 ; EPILOG-NEXT: %i6 = phi i64 [ 1, %preheader.new ], [ %add.7, %latch.7 ]
4334 ; EPILOG-NEXT: %niter = phi i64 [ 0, %preheader.new ], [ %niter.next.7, %latch.7 ]
4335 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4337 ; EPILOG-NEXT: %add = add nuw nsw i64 %i6, 1
4338 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
4339 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4341 ; EPILOG-NEXT: %add.1 = add nuw nsw i64 %add, 1
4342 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
4343 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.2
4345 ; EPILOG-NEXT: %add.2 = add nuw nsw i64 %add.1, 1
4346 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
4347 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.3
4349 ; EPILOG-NEXT: %add.3 = add nuw nsw i64 %add.2, 1
4350 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
4351 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.4
4353 ; EPILOG-NEXT: %add.4 = add nuw nsw i64 %add.3, 1
4354 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
4355 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.5
4357 ; EPILOG-NEXT: %add.5 = add nuw nsw i64 %add.4, 1
4358 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
4359 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.6
4361 ; EPILOG-NEXT: %add.6 = add nuw nsw i64 %add.5, 1
4362 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
4363 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.7
4365 ; EPILOG-NEXT: %add.7 = add nuw nsw i64 %add.6, 1
4366 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
4367 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
4368 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %header, label %latchexit.unr-lcssa.loopexit
4369 ; EPILOG: latchexit.unr-lcssa.loopexit:
4370 ; EPILOG-NEXT: %i6.unr.ph = phi i64 [ %add.7, %latch.7 ]
4371 ; EPILOG-NEXT: br label %latchexit.unr-lcssa
4372 ; EPILOG: latchexit.unr-lcssa:
4373 ; EPILOG-NEXT: %i6.unr = phi i64 [ 1, %preheader ], [ %i6.unr.ph, %latchexit.unr-lcssa.loopexit ]
4374 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4375 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchexit
4376 ; EPILOG: header.epil.preheader:
4377 ; EPILOG-NEXT: br label %header.epil
4378 ; EPILOG: header.epil:
4379 ; EPILOG-NEXT: %i6.epil = phi i64 [ %i6.unr, %header.epil.preheader ], [ %add.epil, %latch.epil ]
4380 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
4381 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit1, label %latch.epil
4382 ; EPILOG: latch.epil:
4383 ; EPILOG-NEXT: %add.epil = add nuw nsw i64 %i6.epil, 1
4384 ; EPILOG-NEXT: %i9.epil = icmp slt i64 %add.epil, %sext
4385 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
4386 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
4387 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchexit.epilog-lcssa, !llvm.loop !11
4388 ; EPILOG: latchexit.epilog-lcssa:
4389 ; EPILOG-NEXT: br label %latchexit
4390 ; EPILOG: latchexit:
4391 ; EPILOG-NEXT: unreachable
4392 ; EPILOG: loopexit2:
4393 ; EPILOG-NEXT: ret i32 %shft
4394 ; EPILOG: loopexit1.loopexit:
4395 ; 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 ]
4396 ; EPILOG-NEXT: br label %loopexit1
4397 ; EPILOG: loopexit1.loopexit1:
4398 ; EPILOG-NEXT: %sext3.ph2 = phi i32 [ %shft, %header.epil ]
4399 ; EPILOG-NEXT: br label %loopexit1
4400 ; EPILOG: loopexit1:
4401 ; EPILOG-NEXT: %sext3 = phi i32 [ %sext3.ph, %loopexit1.loopexit ], [ %sext3.ph2, %loopexit1.loopexit1 ]
4402 ; EPILOG-NEXT: ret i32 %sext3
4404 ; EPILOG-BLOCK-LABEL: @test7(
4405 ; EPILOG-BLOCK-NEXT: bb:
4406 ; EPILOG-BLOCK-NEXT: %i = icmp slt i32 undef, 2
4407 ; EPILOG-BLOCK-NEXT: %sext = sext i32 undef to i64
4408 ; EPILOG-BLOCK-NEXT: %shft = ashr exact i32 %arg, 16
4409 ; EPILOG-BLOCK-NEXT: br i1 %i, label %loopexit2, label %preheader
4410 ; EPILOG-BLOCK: preheader:
4411 ; EPILOG-BLOCK-NEXT: %0 = add nsw i64 %sext, -1
4412 ; EPILOG-BLOCK-NEXT: %1 = freeze i64 %0
4413 ; EPILOG-BLOCK-NEXT: %2 = add i64 %1, -1
4414 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %1, 1
4415 ; EPILOG-BLOCK-NEXT: %3 = icmp ult i64 %2, 1
4416 ; EPILOG-BLOCK-NEXT: br i1 %3, label %latchexit.unr-lcssa, label %preheader.new
4417 ; EPILOG-BLOCK: preheader.new:
4418 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %1, %xtraiter
4419 ; EPILOG-BLOCK-NEXT: br label %header
4420 ; EPILOG-BLOCK: header:
4421 ; EPILOG-BLOCK-NEXT: %i6 = phi i64 [ 1, %preheader.new ], [ %add.1, %latch.1 ]
4422 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %preheader.new ], [ %niter.next.1, %latch.1 ]
4423 ; EPILOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4424 ; EPILOG-BLOCK: latch:
4425 ; EPILOG-BLOCK-NEXT: %add = add nuw nsw i64 %i6, 1
4426 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
4427 ; EPILOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4428 ; EPILOG-BLOCK: latch.1:
4429 ; EPILOG-BLOCK-NEXT: %add.1 = add nuw nsw i64 %add, 1
4430 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
4431 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
4432 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %header, label %latchexit.unr-lcssa.loopexit, !llvm.loop !11
4433 ; EPILOG-BLOCK: latchexit.unr-lcssa.loopexit:
4434 ; EPILOG-BLOCK-NEXT: br label %latchexit.unr-lcssa
4435 ; EPILOG-BLOCK: latchexit.unr-lcssa:
4436 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4437 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchexit
4438 ; EPILOG-BLOCK: header.epil.preheader:
4439 ; EPILOG-BLOCK-NEXT: br label %header.epil
4440 ; EPILOG-BLOCK: header.epil:
4441 ; EPILOG-BLOCK-NEXT: br i1 false, label %loopexit1, label %latch.epil
4442 ; EPILOG-BLOCK: latch.epil:
4443 ; EPILOG-BLOCK-NEXT: br label %latchexit
4444 ; EPILOG-BLOCK: latchexit:
4445 ; EPILOG-BLOCK-NEXT: unreachable
4446 ; EPILOG-BLOCK: loopexit2:
4447 ; EPILOG-BLOCK-NEXT: ret i32 %shft
4448 ; EPILOG-BLOCK: loopexit1.loopexit:
4449 ; EPILOG-BLOCK-NEXT: %sext3.ph = phi i32 [ %shft, %header ], [ %shft, %latch ]
4450 ; EPILOG-BLOCK-NEXT: br label %loopexit1
4451 ; EPILOG-BLOCK: loopexit1:
4452 ; EPILOG-BLOCK-NEXT: %sext3 = phi i32 [ %shft, %header.epil ], [ %sext3.ph, %loopexit1.loopexit ]
4453 ; EPILOG-BLOCK-NEXT: ret i32 %sext3
4455 ; PROLOG-LABEL: @test7(
4457 ; PROLOG-NEXT: %i = icmp slt i32 undef, 2
4458 ; PROLOG-NEXT: %sext = sext i32 undef to i64
4459 ; PROLOG-NEXT: %shft = ashr exact i32 %arg, 16
4460 ; PROLOG-NEXT: br i1 %i, label %loopexit2, label %preheader
4461 ; PROLOG: preheader:
4462 ; PROLOG-NEXT: %0 = add nsw i64 %sext, -1
4463 ; PROLOG-NEXT: %1 = freeze i64 %0
4464 ; PROLOG-NEXT: %2 = add i64 %1, -1
4465 ; PROLOG-NEXT: %xtraiter = and i64 %1, 7
4466 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4467 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4468 ; PROLOG: header.prol.preheader:
4469 ; PROLOG-NEXT: br label %header.prol
4470 ; PROLOG: header.prol:
4471 ; PROLOG-NEXT: %i6.prol = phi i64 [ 1, %header.prol.preheader ], [ %add.prol, %latch.prol ]
4472 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
4473 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit1, label %latch.prol
4474 ; PROLOG: latch.prol:
4475 ; PROLOG-NEXT: %add.prol = add nuw nsw i64 %i6.prol, 1
4476 ; PROLOG-NEXT: %i9.prol = icmp slt i64 %add.prol, %sext
4477 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
4478 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
4479 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !11
4480 ; PROLOG: header.prol.loopexit.unr-lcssa:
4481 ; PROLOG-NEXT: %i6.unr.ph = phi i64 [ %add.prol, %latch.prol ]
4482 ; PROLOG-NEXT: br label %header.prol.loopexit
4483 ; PROLOG: header.prol.loopexit:
4484 ; PROLOG-NEXT: %i6.unr = phi i64 [ 1, %preheader ], [ %i6.unr.ph, %header.prol.loopexit.unr-lcssa ]
4485 ; PROLOG-NEXT: %3 = icmp ult i64 %2, 7
4486 ; PROLOG-NEXT: br i1 %3, label %latchexit, label %preheader.new
4487 ; PROLOG: preheader.new:
4488 ; PROLOG-NEXT: br label %header
4490 ; PROLOG-NEXT: %i6 = phi i64 [ %i6.unr, %preheader.new ], [ %add.7, %latch.7 ]
4491 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4493 ; PROLOG-NEXT: %add = add nuw nsw i64 %i6, 1
4494 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4496 ; PROLOG-NEXT: %add.1 = add nuw nsw i64 %add, 1
4497 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.2
4499 ; PROLOG-NEXT: %add.2 = add nuw nsw i64 %add.1, 1
4500 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.3
4502 ; PROLOG-NEXT: %add.3 = add nuw nsw i64 %add.2, 1
4503 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.4
4505 ; PROLOG-NEXT: %add.4 = add nuw nsw i64 %add.3, 1
4506 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.5
4508 ; PROLOG-NEXT: %add.5 = add nuw nsw i64 %add.4, 1
4509 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.6
4511 ; PROLOG-NEXT: %add.6 = add nuw nsw i64 %add.5, 1
4512 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.7
4514 ; PROLOG-NEXT: %add.7 = add nuw nsw i64 %add.6, 1
4515 ; PROLOG-NEXT: %i9.7 = icmp slt i64 %add.7, %sext
4516 ; PROLOG-NEXT: br i1 %i9.7, label %header, label %latchexit.unr-lcssa
4517 ; PROLOG: latchexit.unr-lcssa:
4518 ; PROLOG-NEXT: br label %latchexit
4519 ; PROLOG: latchexit:
4520 ; PROLOG-NEXT: unreachable
4521 ; PROLOG: loopexit2:
4522 ; PROLOG-NEXT: ret i32 %shft
4523 ; PROLOG: loopexit1.loopexit:
4524 ; 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 ]
4525 ; PROLOG-NEXT: br label %loopexit1
4526 ; PROLOG: loopexit1.loopexit1:
4527 ; PROLOG-NEXT: %sext3.ph2 = phi i32 [ %shft, %header.prol ]
4528 ; PROLOG-NEXT: br label %loopexit1
4529 ; PROLOG: loopexit1:
4530 ; PROLOG-NEXT: %sext3 = phi i32 [ %sext3.ph, %loopexit1.loopexit ], [ %sext3.ph2, %loopexit1.loopexit1 ]
4531 ; PROLOG-NEXT: ret i32 %sext3
4533 ; PROLOG-BLOCK-LABEL: @test7(
4534 ; PROLOG-BLOCK-NEXT: bb:
4535 ; PROLOG-BLOCK-NEXT: %i = icmp slt i32 undef, 2
4536 ; PROLOG-BLOCK-NEXT: %sext = sext i32 undef to i64
4537 ; PROLOG-BLOCK-NEXT: %shft = ashr exact i32 %arg, 16
4538 ; PROLOG-BLOCK-NEXT: br i1 %i, label %loopexit2, label %preheader
4539 ; PROLOG-BLOCK: preheader:
4540 ; PROLOG-BLOCK-NEXT: %0 = add nsw i64 %sext, -1
4541 ; PROLOG-BLOCK-NEXT: %1 = freeze i64 %0
4542 ; PROLOG-BLOCK-NEXT: %2 = add i64 %1, -1
4543 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %1, 1
4544 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4545 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4546 ; PROLOG-BLOCK: header.prol.preheader:
4547 ; PROLOG-BLOCK-NEXT: br label %header.prol
4548 ; PROLOG-BLOCK: header.prol:
4549 ; PROLOG-BLOCK-NEXT: br i1 false, label %loopexit1, label %latch.prol
4550 ; PROLOG-BLOCK: latch.prol:
4551 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
4552 ; PROLOG-BLOCK: header.prol.loopexit:
4553 ; PROLOG-BLOCK-NEXT: %i6.unr = phi i64 [ 1, %preheader ], [ 2, %latch.prol ]
4554 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %2, 1
4555 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchexit, label %preheader.new
4556 ; PROLOG-BLOCK: preheader.new:
4557 ; PROLOG-BLOCK-NEXT: br label %header
4558 ; PROLOG-BLOCK: header:
4559 ; PROLOG-BLOCK-NEXT: %i6 = phi i64 [ %i6.unr, %preheader.new ], [ %add.1, %latch.1 ]
4560 ; PROLOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4561 ; PROLOG-BLOCK: latch:
4562 ; PROLOG-BLOCK-NEXT: %add = add nuw nsw i64 %i6, 1
4563 ; PROLOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4564 ; PROLOG-BLOCK: latch.1:
4565 ; PROLOG-BLOCK-NEXT: %add.1 = add nuw nsw i64 %add, 1
4566 ; PROLOG-BLOCK-NEXT: %i9.1 = icmp slt i64 %add.1, %sext
4567 ; PROLOG-BLOCK-NEXT: br i1 %i9.1, label %header, label %latchexit.unr-lcssa, !llvm.loop !11
4568 ; PROLOG-BLOCK: latchexit.unr-lcssa:
4569 ; PROLOG-BLOCK-NEXT: br label %latchexit
4570 ; PROLOG-BLOCK: latchexit:
4571 ; PROLOG-BLOCK-NEXT: unreachable
4572 ; PROLOG-BLOCK: loopexit2:
4573 ; PROLOG-BLOCK-NEXT: ret i32 %shft
4574 ; PROLOG-BLOCK: loopexit1.loopexit:
4575 ; PROLOG-BLOCK-NEXT: %sext3.ph = phi i32 [ %shft, %header ], [ %shft, %latch ]
4576 ; PROLOG-BLOCK-NEXT: br label %loopexit1
4577 ; PROLOG-BLOCK: loopexit1:
4578 ; PROLOG-BLOCK-NEXT: %sext3 = phi i32 [ %shft, %header.prol ], [ %sext3.ph, %loopexit1.loopexit ]
4579 ; PROLOG-BLOCK-NEXT: ret i32 %sext3
4582 %i = icmp slt i32 undef, 2
4583 %sext = sext i32 undef to i64
4584 %shft = ashr exact i32 %arg, 16
4585 br i1 %i, label %loopexit2, label %preheader
4587 preheader: ; preds = %bb2
4590 header: ; preds = %latch, %preheader
4591 %i6 = phi i64 [ 1, %preheader ], [ %add, %latch ]
4592 br i1 false, label %loopexit1, label %latch
4594 latch: ; preds = %header
4595 %add = add nuw nsw i64 %i6, 1
4596 %i9 = icmp slt i64 %add, %sext
4597 br i1 %i9, label %header, label %latchexit
4599 latchexit: ; preds = %latch
4602 loopexit2: ; preds = %bb2
4605 loopexit1: ; preds = %header
4606 %sext3 = phi i32 [ %shft, %header ]
4610 ; Nested loop and inner loop is unrolled. The tricky bit here is that
4611 ; several blocks in the inner loop fall out of the outer block when we
4612 ; use the epilogue block remainder strategy.
4613 define void @test8() {
4614 ; EPILOG-LABEL: @test8(
4616 ; EPILOG-NEXT: br label %outerloop
4617 ; EPILOG: outerloop.loopexit.loopexit:
4618 ; EPILOG-NEXT: br label %outerloop.loopexit
4619 ; EPILOG: outerloop.loopexit.loopexit1:
4620 ; EPILOG-NEXT: br label %outerloop.loopexit
4621 ; EPILOG: outerloop.loopexit:
4622 ; EPILOG-NEXT: br label %outerloop
4623 ; EPILOG: outerloop:
4624 ; EPILOG-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit ]
4625 ; EPILOG-NEXT: %0 = sub i64 100, %i
4626 ; EPILOG-NEXT: %1 = sub i64 99, %i
4627 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
4628 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
4629 ; EPILOG-NEXT: br i1 %2, label %exit.unr-lcssa, label %outerloop.new
4630 ; EPILOG: outerloop.new:
4631 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
4632 ; EPILOG-NEXT: br label %innerH
4634 ; EPILOG-NEXT: %i3 = phi i64 [ %i, %outerloop.new ], [ %i4.7, %latch.7 ]
4635 ; EPILOG-NEXT: %niter = phi i64 [ 0, %outerloop.new ], [ %niter.next.7, %latch.7 ]
4636 ; EPILOG-NEXT: %i4 = add nuw nsw i64 %i3, 1
4637 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4639 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
4640 ; EPILOG-NEXT: %i4.1 = add nuw nsw i64 %i4, 1
4641 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4643 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
4644 ; EPILOG-NEXT: %i4.2 = add nuw nsw i64 %i4.1, 1
4645 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.2
4647 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
4648 ; EPILOG-NEXT: %i4.3 = add nuw nsw i64 %i4.2, 1
4649 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.3
4651 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
4652 ; EPILOG-NEXT: %i4.4 = add nuw nsw i64 %i4.3, 1
4653 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.4
4655 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
4656 ; EPILOG-NEXT: %i4.5 = add nuw nsw i64 %i4.4, 1
4657 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.5
4659 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
4660 ; EPILOG-NEXT: %i4.6 = add nuw nsw i64 %i4.5, 1
4661 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.6
4663 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
4664 ; EPILOG-NEXT: %i4.7 = add nuw nsw i64 %i4.6, 1
4665 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.7
4667 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
4668 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
4669 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %innerH, label %exit.unr-lcssa.loopexit
4670 ; EPILOG: exit.unr-lcssa.loopexit:
4671 ; EPILOG-NEXT: %i3.unr.ph = phi i64 [ %i4.7, %latch.7 ]
4672 ; EPILOG-NEXT: br label %exit.unr-lcssa
4673 ; EPILOG: exit.unr-lcssa:
4674 ; EPILOG-NEXT: %i3.unr = phi i64 [ %i, %outerloop ], [ %i3.unr.ph, %exit.unr-lcssa.loopexit ]
4675 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4676 ; EPILOG-NEXT: br i1 %lcmp.mod, label %innerH.epil.preheader, label %exit.loopexit
4677 ; EPILOG: innerH.epil.preheader:
4678 ; EPILOG-NEXT: br label %innerH.epil
4679 ; EPILOG: innerH.epil:
4680 ; EPILOG-NEXT: %i3.epil = phi i64 [ %i4.epil, %latch.epil ], [ %i3.unr, %innerH.epil.preheader ]
4681 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %innerH.epil.preheader ], [ %epil.iter.next, %latch.epil ]
4682 ; EPILOG-NEXT: %i4.epil = add nuw nsw i64 %i3.epil, 1
4683 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit1, label %latch.epil
4684 ; EPILOG: latch.epil:
4685 ; EPILOG-NEXT: %i6.epil = icmp ult i64 %i4.epil, 100
4686 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
4687 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
4688 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %innerH.epil, label %exit.epilog-lcssa, !llvm.loop !12
4689 ; EPILOG: exit.epilog-lcssa:
4690 ; EPILOG-NEXT: br label %exit
4691 ; EPILOG: exit.loopexit:
4692 ; EPILOG-NEXT: br label %exit
4694 ; EPILOG-NEXT: ret void
4696 ; EPILOG-BLOCK-LABEL: @test8(
4697 ; EPILOG-BLOCK-NEXT: bb:
4698 ; EPILOG-BLOCK-NEXT: br label %outerloop
4699 ; EPILOG-BLOCK: outerloop.loopexit.loopexit:
4700 ; EPILOG-BLOCK-NEXT: br label %outerloop.loopexit
4701 ; EPILOG-BLOCK: outerloop.loopexit:
4702 ; EPILOG-BLOCK-NEXT: br i1 false, label %exit.unr-lcssa.1, label %outerloop.new.1
4703 ; EPILOG-BLOCK: outerloop.new.1:
4704 ; EPILOG-BLOCK-NEXT: br label %innerH.1
4705 ; EPILOG-BLOCK: innerH.1:
4706 ; EPILOG-BLOCK-NEXT: %i3.1 = phi i64 [ 0, %outerloop.new.1 ], [ %i4.1.1, %latch.1.1 ]
4707 ; EPILOG-BLOCK-NEXT: %niter.1 = phi i64 [ 0, %outerloop.new.1 ], [ %niter.next.1.1, %latch.1.1 ]
4708 ; EPILOG-BLOCK-NEXT: %i4.12 = add nuw nsw i64 %i3.1, 1
4709 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.14
4710 ; EPILOG-BLOCK: latch.14:
4711 ; EPILOG-BLOCK-NEXT: %niter.next.13 = add nuw nsw i64 %niter.1, 1
4712 ; EPILOG-BLOCK-NEXT: %i4.1.1 = add nuw nsw i64 %i4.12, 1
4713 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.1.1
4714 ; EPILOG-BLOCK: latch.1.1:
4715 ; EPILOG-BLOCK-NEXT: %niter.next.1.1 = add i64 %niter.next.13, 1
4716 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1.1 = icmp ne i64 %niter.next.1.1, 100
4717 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1.1, label %innerH.1, label %exit.unr-lcssa.loopexit.1, !llvm.loop !12
4718 ; EPILOG-BLOCK: exit.unr-lcssa.loopexit.1:
4719 ; EPILOG-BLOCK-NEXT: br label %exit.unr-lcssa.1
4720 ; EPILOG-BLOCK: outerloop.loopexit.loopexit.1:
4721 ; EPILOG-BLOCK-NEXT: br label %outerloop.loopexit.1
4722 ; EPILOG-BLOCK: exit.unr-lcssa.1:
4723 ; EPILOG-BLOCK-NEXT: br i1 false, label %innerH.epil.preheader.1, label %exit.loopexit
4724 ; EPILOG-BLOCK: innerH.epil.preheader.1:
4725 ; EPILOG-BLOCK-NEXT: br label %innerH.epil.1
4726 ; EPILOG-BLOCK: innerH.epil.1:
4727 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.1, label %latch.epil
4728 ; EPILOG-BLOCK: outerloop.loopexit.1:
4729 ; EPILOG-BLOCK-NEXT: br label %outerloop, !llvm.loop !13
4730 ; EPILOG-BLOCK: outerloop:
4731 ; EPILOG-BLOCK-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit.1 ]
4732 ; EPILOG-BLOCK-NEXT: %0 = sub i64 100, %i
4733 ; EPILOG-BLOCK-NEXT: %1 = sub i64 99, %i
4734 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4735 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4736 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit.unr-lcssa, label %outerloop.new
4737 ; EPILOG-BLOCK: outerloop.new:
4738 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
4739 ; EPILOG-BLOCK-NEXT: br label %innerH
4740 ; EPILOG-BLOCK: innerH:
4741 ; EPILOG-BLOCK-NEXT: %i3 = phi i64 [ %i, %outerloop.new ], [ %i4.1, %latch.1 ]
4742 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %outerloop.new ], [ %niter.next.1, %latch.1 ]
4743 ; EPILOG-BLOCK-NEXT: %i4 = add nuw nsw i64 %i3, 1
4744 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4745 ; EPILOG-BLOCK: latch:
4746 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
4747 ; EPILOG-BLOCK-NEXT: %i4.1 = add nuw nsw i64 %i4, 1
4748 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4749 ; EPILOG-BLOCK: latch.1:
4750 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
4751 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
4752 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %innerH, label %exit.unr-lcssa.loopexit, !llvm.loop !12
4753 ; EPILOG-BLOCK: exit.unr-lcssa.loopexit:
4754 ; EPILOG-BLOCK-NEXT: br label %exit.unr-lcssa
4755 ; EPILOG-BLOCK: exit.unr-lcssa:
4756 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4757 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %innerH.epil.preheader, label %exit.loopexit
4758 ; EPILOG-BLOCK: innerH.epil.preheader:
4759 ; EPILOG-BLOCK-NEXT: br label %innerH.epil
4760 ; EPILOG-BLOCK: innerH.epil:
4761 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit, label %latch.epil
4762 ; EPILOG-BLOCK: latch.epil:
4763 ; EPILOG-BLOCK-NEXT: br label %exit
4764 ; EPILOG-BLOCK: exit.loopexit:
4765 ; EPILOG-BLOCK-NEXT: br label %exit
4766 ; EPILOG-BLOCK: exit:
4767 ; EPILOG-BLOCK-NEXT: ret void
4769 ; PROLOG-LABEL: @test8(
4771 ; PROLOG-NEXT: br label %outerloop
4772 ; PROLOG: outerloop.loopexit.loopexit:
4773 ; PROLOG-NEXT: br label %outerloop.loopexit
4774 ; PROLOG: outerloop.loopexit.loopexit1:
4775 ; PROLOG-NEXT: br label %outerloop.loopexit
4776 ; PROLOG: outerloop.loopexit:
4777 ; PROLOG-NEXT: br label %outerloop
4778 ; PROLOG: outerloop:
4779 ; PROLOG-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit ]
4780 ; PROLOG-NEXT: %0 = sub i64 100, %i
4781 ; PROLOG-NEXT: %1 = sub i64 99, %i
4782 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
4783 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4784 ; PROLOG-NEXT: br i1 %lcmp.mod, label %innerH.prol.preheader, label %innerH.prol.loopexit
4785 ; PROLOG: innerH.prol.preheader:
4786 ; PROLOG-NEXT: br label %innerH.prol
4787 ; PROLOG: innerH.prol:
4788 ; PROLOG-NEXT: %i3.prol = phi i64 [ %i4.prol, %latch.prol ], [ %i, %innerH.prol.preheader ]
4789 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %innerH.prol.preheader ], [ %prol.iter.next, %latch.prol ]
4790 ; PROLOG-NEXT: %i4.prol = add nuw nsw i64 %i3.prol, 1
4791 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit1, label %latch.prol
4792 ; PROLOG: latch.prol:
4793 ; PROLOG-NEXT: %i6.prol = icmp ult i64 %i4.prol, 100
4794 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
4795 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
4796 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %innerH.prol, label %innerH.prol.loopexit.unr-lcssa, !llvm.loop !12
4797 ; PROLOG: innerH.prol.loopexit.unr-lcssa:
4798 ; PROLOG-NEXT: %i3.unr.ph = phi i64 [ %i4.prol, %latch.prol ]
4799 ; PROLOG-NEXT: br label %innerH.prol.loopexit
4800 ; PROLOG: innerH.prol.loopexit:
4801 ; PROLOG-NEXT: %i3.unr = phi i64 [ %i, %outerloop ], [ %i3.unr.ph, %innerH.prol.loopexit.unr-lcssa ]
4802 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
4803 ; PROLOG-NEXT: br i1 %2, label %exit.loopexit, label %outerloop.new
4804 ; PROLOG: outerloop.new:
4805 ; PROLOG-NEXT: br label %innerH
4807 ; PROLOG-NEXT: %i3 = phi i64 [ %i3.unr, %outerloop.new ], [ %i4.7, %latch.7 ]
4808 ; PROLOG-NEXT: %i4 = add nuw nsw i64 %i3, 1
4809 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4811 ; PROLOG-NEXT: %i4.1 = add nuw nsw i64 %i4, 1
4812 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4814 ; PROLOG-NEXT: %i4.2 = add nuw nsw i64 %i4.1, 1
4815 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.2
4817 ; PROLOG-NEXT: %i4.3 = add nuw nsw i64 %i4.2, 1
4818 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.3
4820 ; PROLOG-NEXT: %i4.4 = add nuw nsw i64 %i4.3, 1
4821 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.4
4823 ; PROLOG-NEXT: %i4.5 = add nuw nsw i64 %i4.4, 1
4824 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.5
4826 ; PROLOG-NEXT: %i4.6 = add nuw nsw i64 %i4.5, 1
4827 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.6
4829 ; PROLOG-NEXT: %i4.7 = add nuw nsw i64 %i4.6, 1
4830 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.7
4832 ; PROLOG-NEXT: %i6.7 = icmp ult i64 %i4.7, 100
4833 ; PROLOG-NEXT: br i1 %i6.7, label %innerH, label %exit.unr-lcssa
4834 ; PROLOG: exit.unr-lcssa:
4835 ; PROLOG-NEXT: br label %exit
4836 ; PROLOG: exit.loopexit:
4837 ; PROLOG-NEXT: br label %exit
4839 ; PROLOG-NEXT: ret void
4841 ; PROLOG-BLOCK-LABEL: @test8(
4842 ; PROLOG-BLOCK-NEXT: bb:
4843 ; PROLOG-BLOCK-NEXT: br label %outerloop
4844 ; PROLOG-BLOCK: outerloop.loopexit.loopexit:
4845 ; PROLOG-BLOCK-NEXT: br label %outerloop.loopexit
4846 ; PROLOG-BLOCK: outerloop.loopexit:
4847 ; PROLOG-BLOCK-NEXT: br i1 false, label %innerH.prol.preheader.1, label %innerH.prol.loopexit.1
4848 ; PROLOG-BLOCK: innerH.prol.preheader.1:
4849 ; PROLOG-BLOCK-NEXT: br label %innerH.prol.1
4850 ; PROLOG-BLOCK: innerH.prol.1:
4851 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.1, label %latch.prol.1
4852 ; PROLOG-BLOCK: latch.prol.1:
4853 ; PROLOG-BLOCK-NEXT: br label %innerH.prol.loopexit.1
4854 ; PROLOG-BLOCK: innerH.prol.loopexit.1:
4855 ; PROLOG-BLOCK-NEXT: %i3.unr.1 = phi i64 [ 0, %outerloop.loopexit ], [ 1, %latch.prol.1 ]
4856 ; PROLOG-BLOCK-NEXT: br i1 false, label %exit.loopexit, label %outerloop.new.1
4857 ; PROLOG-BLOCK: outerloop.new.1:
4858 ; PROLOG-BLOCK-NEXT: br label %innerH.1
4859 ; PROLOG-BLOCK: innerH.1:
4860 ; PROLOG-BLOCK-NEXT: %i3.1 = phi i64 [ %i3.unr.1, %outerloop.new.1 ], [ %i4.1.1, %latch.1.1 ]
4861 ; PROLOG-BLOCK-NEXT: %i4.11 = add nuw nsw i64 %i3.1, 1
4862 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.12
4863 ; PROLOG-BLOCK: latch.12:
4864 ; PROLOG-BLOCK-NEXT: %i4.1.1 = add nuw nsw i64 %i4.11, 1
4865 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.1.1
4866 ; PROLOG-BLOCK: latch.1.1:
4867 ; PROLOG-BLOCK-NEXT: %i6.1.1 = icmp ult i64 %i4.1.1, 100
4868 ; PROLOG-BLOCK-NEXT: br i1 %i6.1.1, label %innerH.1, label %exit.unr-lcssa.loopexit3, !llvm.loop !12
4869 ; PROLOG-BLOCK: outerloop.loopexit.loopexit.1:
4870 ; PROLOG-BLOCK-NEXT: br label %outerloop.loopexit.1
4871 ; PROLOG-BLOCK: outerloop.loopexit.1:
4872 ; PROLOG-BLOCK-NEXT: br label %outerloop, !llvm.loop !13
4873 ; PROLOG-BLOCK: outerloop:
4874 ; PROLOG-BLOCK-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit.1 ]
4875 ; PROLOG-BLOCK-NEXT: %0 = sub i64 100, %i
4876 ; PROLOG-BLOCK-NEXT: %1 = sub i64 99, %i
4877 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4878 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4879 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %innerH.prol.preheader, label %innerH.prol.loopexit
4880 ; PROLOG-BLOCK: innerH.prol.preheader:
4881 ; PROLOG-BLOCK-NEXT: br label %innerH.prol
4882 ; PROLOG-BLOCK: innerH.prol:
4883 ; PROLOG-BLOCK-NEXT: %i4.prol = add nuw nsw i64 %i, 1
4884 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit, label %latch.prol
4885 ; PROLOG-BLOCK: latch.prol:
4886 ; PROLOG-BLOCK-NEXT: br label %innerH.prol.loopexit
4887 ; PROLOG-BLOCK: innerH.prol.loopexit:
4888 ; PROLOG-BLOCK-NEXT: %i3.unr = phi i64 [ %i, %outerloop ], [ %i4.prol, %latch.prol ]
4889 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4890 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit.loopexit, label %outerloop.new
4891 ; PROLOG-BLOCK: outerloop.new:
4892 ; PROLOG-BLOCK-NEXT: br label %innerH
4893 ; PROLOG-BLOCK: innerH:
4894 ; PROLOG-BLOCK-NEXT: %i3 = phi i64 [ %i3.unr, %outerloop.new ], [ %i4.1, %latch.1 ]
4895 ; PROLOG-BLOCK-NEXT: %i4 = add nuw nsw i64 %i3, 1
4896 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4897 ; PROLOG-BLOCK: latch:
4898 ; PROLOG-BLOCK-NEXT: %i4.1 = add nuw nsw i64 %i4, 1
4899 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4900 ; PROLOG-BLOCK: latch.1:
4901 ; PROLOG-BLOCK-NEXT: %i6.1 = icmp ult i64 %i4.1, 100
4902 ; PROLOG-BLOCK-NEXT: br i1 %i6.1, label %innerH, label %exit.unr-lcssa.loopexit, !llvm.loop !12
4903 ; PROLOG-BLOCK: exit.unr-lcssa.loopexit:
4904 ; PROLOG-BLOCK-NEXT: br label %exit.unr-lcssa
4905 ; PROLOG-BLOCK: exit.unr-lcssa.loopexit3:
4906 ; PROLOG-BLOCK-NEXT: br label %exit.unr-lcssa
4907 ; PROLOG-BLOCK: exit.unr-lcssa:
4908 ; PROLOG-BLOCK-NEXT: br label %exit
4909 ; PROLOG-BLOCK: exit.loopexit:
4910 ; PROLOG-BLOCK-NEXT: br label %exit
4911 ; PROLOG-BLOCK: exit:
4912 ; PROLOG-BLOCK-NEXT: ret void
4918 outerloop: ; preds = %innerH, %bb
4919 %i = phi i64 [ 3, %bb ], [ 0, %innerH ]
4922 innerH: ; preds = %latch, %outerloop
4923 %i3 = phi i64 [ %i4, %latch ], [ %i, %outerloop ]
4924 %i4 = add nuw nsw i64 %i3, 1
4925 br i1 false, label %outerloop, label %latch
4927 latch: ; preds = %innerH
4928 %i6 = icmp ult i64 %i4, 100
4929 br i1 %i6, label %innerH, label %exit
4931 exit: ; preds = %latch
4935 declare i8 addrspace(1)* @foo(i32)
4936 ; inner loop prolog unrolled
4937 ; a value from outer loop is used in exit block of inner loop.
4938 ; Don't create VMap entries for such values (%trip).
4939 define i8 addrspace(1)* @test9(i8* nocapture readonly %arg, i32 %n) {
4940 ; EPILOG-LABEL: @test9(
4942 ; EPILOG-NEXT: %0 = add i32 %n, -1
4943 ; EPILOG-NEXT: br label %outerloopHdr
4944 ; EPILOG: outerloopHdr:
4945 ; EPILOG-NEXT: %trip = add i32 %n, -1
4946 ; EPILOG-NEXT: %outercnd = icmp slt i32 0, %trip
4947 ; EPILOG-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
4948 ; EPILOG: preheader:
4949 ; EPILOG-NEXT: %i4 = zext i32 0 to i64
4950 ; EPILOG-NEXT: %1 = freeze i32 %0
4951 ; EPILOG-NEXT: %2 = add i32 %1, -1
4952 ; EPILOG-NEXT: %xtraiter = and i32 %1, 7
4953 ; EPILOG-NEXT: %3 = icmp ult i32 %2, 7
4954 ; EPILOG-NEXT: br i1 %3, label %outerLatch.loopexit.unr-lcssa, label %preheader.new
4955 ; EPILOG: preheader.new:
4956 ; EPILOG-NEXT: %unroll_iter = sub i32 %1, %xtraiter
4957 ; EPILOG-NEXT: br label %header
4959 ; EPILOG-NEXT: %phi = phi i64 [ %i4, %preheader.new ], [ %iv.next.7, %latch.7 ]
4960 ; EPILOG-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.7, %latch.7 ]
4961 ; EPILOG-NEXT: br i1 true, label %latch, label %innerexit.loopexit
4962 ; EPILOG: innerexit.loopexit:
4963 ; 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 ]
4964 ; EPILOG-NEXT: br label %innerexit
4965 ; EPILOG: innerexit.loopexit1:
4966 ; EPILOG-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.epil ]
4967 ; EPILOG-NEXT: br label %innerexit
4968 ; EPILOG: innerexit:
4969 ; EPILOG-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
4970 ; EPILOG-NEXT: %i9 = call i8 addrspace(1)* @foo(i32 %trip.lcssa)
4971 ; EPILOG-NEXT: ret i8 addrspace(1)* %i9
4973 ; EPILOG-NEXT: %iv.next = add nuw nsw i64 %phi, 1
4974 ; EPILOG-NEXT: %niter.next = add nuw nsw i32 %niter, 1
4975 ; EPILOG-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit
4977 ; EPILOG-NEXT: %iv.next.1 = add nuw nsw i64 %iv.next, 1
4978 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i32 %niter.next, 1
4979 ; EPILOG-NEXT: br i1 true, label %latch.2, label %innerexit.loopexit
4981 ; EPILOG-NEXT: %iv.next.2 = add nuw nsw i64 %iv.next.1, 1
4982 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i32 %niter.next.1, 1
4983 ; EPILOG-NEXT: br i1 true, label %latch.3, label %innerexit.loopexit
4985 ; EPILOG-NEXT: %iv.next.3 = add nuw nsw i64 %iv.next.2, 1
4986 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i32 %niter.next.2, 1
4987 ; EPILOG-NEXT: br i1 true, label %latch.4, label %innerexit.loopexit
4989 ; EPILOG-NEXT: %iv.next.4 = add nuw nsw i64 %iv.next.3, 1
4990 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i32 %niter.next.3, 1
4991 ; EPILOG-NEXT: br i1 true, label %latch.5, label %innerexit.loopexit
4993 ; EPILOG-NEXT: %iv.next.5 = add nuw nsw i64 %iv.next.4, 1
4994 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i32 %niter.next.4, 1
4995 ; EPILOG-NEXT: br i1 true, label %latch.6, label %innerexit.loopexit
4997 ; EPILOG-NEXT: %iv.next.6 = add nuw nsw i64 %iv.next.5, 1
4998 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i32 %niter.next.5, 1
4999 ; EPILOG-NEXT: br i1 true, label %latch.7, label %innerexit.loopexit
5001 ; EPILOG-NEXT: %iv.next.7 = add nuw nsw i64 %iv.next.6, 1
5002 ; EPILOG-NEXT: %niter.next.7 = add i32 %niter.next.6, 1
5003 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i32 %niter.next.7, %unroll_iter
5004 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %header, label %outerLatch.loopexit.unr-lcssa.loopexit
5005 ; EPILOG: outerLatch.loopexit.unr-lcssa.loopexit:
5006 ; EPILOG-NEXT: %phi.unr.ph = phi i64 [ %iv.next.7, %latch.7 ]
5007 ; EPILOG-NEXT: br label %outerLatch.loopexit.unr-lcssa
5008 ; EPILOG: outerLatch.loopexit.unr-lcssa:
5009 ; EPILOG-NEXT: %phi.unr = phi i64 [ %i4, %preheader ], [ %phi.unr.ph, %outerLatch.loopexit.unr-lcssa.loopexit ]
5010 ; EPILOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
5011 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %outerLatch.loopexit
5012 ; EPILOG: header.epil.preheader:
5013 ; EPILOG-NEXT: br label %header.epil
5014 ; EPILOG: header.epil:
5015 ; EPILOG-NEXT: %phi.epil = phi i64 [ %phi.unr, %header.epil.preheader ], [ %iv.next.epil, %latch.epil ]
5016 ; EPILOG-NEXT: %epil.iter = phi i32 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
5017 ; EPILOG-NEXT: %i7.epil = trunc i64 %phi.epil to i32
5018 ; EPILOG-NEXT: br i1 true, label %latch.epil, label %innerexit.loopexit1
5019 ; EPILOG: latch.epil:
5020 ; EPILOG-NEXT: %i11.epil = add nsw i32 %i7.epil, 1
5021 ; EPILOG-NEXT: %innercnd.epil = icmp slt i32 %i11.epil, %trip
5022 ; EPILOG-NEXT: %iv.next.epil = add nuw nsw i64 %phi.epil, 1
5023 ; EPILOG-NEXT: %epil.iter.next = add i32 %epil.iter, 1
5024 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i32 %epil.iter.next, %xtraiter
5025 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %outerLatch.loopexit.epilog-lcssa, !llvm.loop !13
5026 ; EPILOG: outerLatch.loopexit.epilog-lcssa:
5027 ; EPILOG-NEXT: br label %outerLatch.loopexit
5028 ; EPILOG: outerLatch.loopexit:
5029 ; EPILOG-NEXT: br label %outerLatch
5030 ; EPILOG: outerLatch:
5031 ; EPILOG-NEXT: br label %outerloopHdr
5033 ; EPILOG-BLOCK-LABEL: @test9(
5034 ; EPILOG-BLOCK-NEXT: bb:
5035 ; EPILOG-BLOCK-NEXT: %0 = add i32 %n, -1
5036 ; EPILOG-BLOCK-NEXT: br label %outerloopHdr
5037 ; EPILOG-BLOCK: outerloopHdr:
5038 ; EPILOG-BLOCK-NEXT: %trip = add i32 %n, -1
5039 ; EPILOG-BLOCK-NEXT: %outercnd = icmp slt i32 0, %trip
5040 ; EPILOG-BLOCK-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
5041 ; EPILOG-BLOCK: preheader:
5042 ; EPILOG-BLOCK-NEXT: %1 = freeze i32 %0
5043 ; EPILOG-BLOCK-NEXT: %2 = add i32 %1, -1
5044 ; EPILOG-BLOCK-NEXT: %xtraiter = and i32 %1, 1
5045 ; EPILOG-BLOCK-NEXT: %3 = icmp ult i32 %2, 1
5046 ; EPILOG-BLOCK-NEXT: br i1 %3, label %outerLatch.loopexit.unr-lcssa, label %preheader.new
5047 ; EPILOG-BLOCK: preheader.new:
5048 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i32 %1, %xtraiter
5049 ; EPILOG-BLOCK-NEXT: br label %header
5050 ; EPILOG-BLOCK: header:
5051 ; EPILOG-BLOCK-NEXT: %phi = phi i64 [ 0, %preheader.new ], [ %iv.next.1, %latch.1 ]
5052 ; EPILOG-BLOCK-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.1, %latch.1 ]
5053 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch, label %innerexit.loopexit.loopexit
5054 ; EPILOG-BLOCK: innerexit.loopexit.loopexit:
5055 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph.ph = phi i32 [ %trip, %latch ], [ %trip, %header ]
5056 ; EPILOG-BLOCK-NEXT: br label %innerexit.loopexit
5057 ; EPILOG-BLOCK: innerexit.loopexit.loopexit6:
5058 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph.ph7 = phi i32 [ %trip.1, %latch.15 ], [ %trip.1, %header.1 ]
5059 ; EPILOG-BLOCK-NEXT: br label %innerexit.loopexit
5060 ; EPILOG-BLOCK: innerexit.loopexit:
5061 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph = phi i32 [ %trip.lcssa.ph.ph, %innerexit.loopexit.loopexit ], [ %trip.lcssa.ph.ph7, %innerexit.loopexit.loopexit6 ]
5062 ; EPILOG-BLOCK-NEXT: br label %innerexit
5063 ; EPILOG-BLOCK: innerexit.loopexit1:
5064 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.epil ], [ %trip.1, %header.epil.1 ]
5065 ; EPILOG-BLOCK-NEXT: br label %innerexit
5066 ; EPILOG-BLOCK: innerexit:
5067 ; EPILOG-BLOCK-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
5068 ; EPILOG-BLOCK-NEXT: %i9 = call i8 addrspace(1)* @foo(i32 %trip.lcssa)
5069 ; EPILOG-BLOCK-NEXT: ret i8 addrspace(1)* %i9
5070 ; EPILOG-BLOCK: latch:
5071 ; EPILOG-BLOCK-NEXT: %iv.next = add nuw nsw i64 %phi, 1
5072 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i32 %niter, 1
5073 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit.loopexit
5074 ; EPILOG-BLOCK: latch.1:
5075 ; EPILOG-BLOCK-NEXT: %iv.next.1 = add nuw nsw i64 %iv.next, 1
5076 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i32 %niter.next, 1
5077 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i32 %niter.next.1, %unroll_iter
5078 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %header, label %outerLatch.loopexit.unr-lcssa.loopexit, !llvm.loop !14
5079 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa.loopexit:
5080 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit.unr-lcssa
5081 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa:
5082 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
5083 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %outerLatch.loopexit
5084 ; EPILOG-BLOCK: header.epil.preheader:
5085 ; EPILOG-BLOCK-NEXT: br label %header.epil
5086 ; EPILOG-BLOCK: header.epil:
5087 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.epil, label %innerexit.loopexit1
5088 ; EPILOG-BLOCK: latch.epil:
5089 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit
5090 ; EPILOG-BLOCK: outerLatch.loopexit:
5091 ; EPILOG-BLOCK-NEXT: br label %outerLatch
5092 ; EPILOG-BLOCK: outerLatch:
5093 ; EPILOG-BLOCK-NEXT: %trip.1 = add i32 %n, -1
5094 ; EPILOG-BLOCK-NEXT: %outercnd.1 = icmp slt i32 0, %trip.1
5095 ; EPILOG-BLOCK-NEXT: br i1 %outercnd.1, label %preheader.1, label %outerLatch.1
5096 ; EPILOG-BLOCK: preheader.1:
5097 ; EPILOG-BLOCK-NEXT: %4 = freeze i32 %0
5098 ; EPILOG-BLOCK-NEXT: %5 = add i32 %4, -1
5099 ; EPILOG-BLOCK-NEXT: %xtraiter.1 = and i32 %4, 1
5100 ; EPILOG-BLOCK-NEXT: %6 = icmp ult i32 %5, 1
5101 ; EPILOG-BLOCK-NEXT: br i1 %6, label %outerLatch.loopexit.unr-lcssa.1, label %preheader.new.1
5102 ; EPILOG-BLOCK: preheader.new.1:
5103 ; EPILOG-BLOCK-NEXT: %unroll_iter.1 = sub i32 %4, %xtraiter.1
5104 ; EPILOG-BLOCK-NEXT: br label %header.1
5105 ; EPILOG-BLOCK: header.1:
5106 ; EPILOG-BLOCK-NEXT: %phi.1 = phi i64 [ 0, %preheader.new.1 ], [ %iv.next.1.1, %latch.1.1 ]
5107 ; EPILOG-BLOCK-NEXT: %niter.1 = phi i32 [ 0, %preheader.new.1 ], [ %niter.next.1.1, %latch.1.1 ]
5108 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.15, label %innerexit.loopexit.loopexit6
5109 ; EPILOG-BLOCK: latch.15:
5110 ; EPILOG-BLOCK-NEXT: %iv.next.13 = add nuw nsw i64 %phi.1, 1
5111 ; EPILOG-BLOCK-NEXT: %niter.next.14 = add nuw nsw i32 %niter.1, 1
5112 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.1.1, label %innerexit.loopexit.loopexit6
5113 ; EPILOG-BLOCK: latch.1.1:
5114 ; EPILOG-BLOCK-NEXT: %iv.next.1.1 = add nuw nsw i64 %iv.next.13, 1
5115 ; EPILOG-BLOCK-NEXT: %niter.next.1.1 = add i32 %niter.next.14, 1
5116 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1.1 = icmp ne i32 %niter.next.1.1, %unroll_iter.1
5117 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1.1, label %header.1, label %outerLatch.loopexit.unr-lcssa.loopexit.1, !llvm.loop !14
5118 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa.loopexit.1:
5119 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit.unr-lcssa.1
5120 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa.1:
5121 ; EPILOG-BLOCK-NEXT: %lcmp.mod.1 = icmp ne i32 %xtraiter.1, 0
5122 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod.1, label %header.epil.preheader.1, label %outerLatch.loopexit.1
5123 ; EPILOG-BLOCK: header.epil.preheader.1:
5124 ; EPILOG-BLOCK-NEXT: br label %header.epil.1
5125 ; EPILOG-BLOCK: header.epil.1:
5126 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.epil.1, label %innerexit.loopexit1
5127 ; EPILOG-BLOCK: latch.epil.1:
5128 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit.1
5129 ; EPILOG-BLOCK: outerLatch.loopexit.1:
5130 ; EPILOG-BLOCK-NEXT: br label %outerLatch.1
5131 ; EPILOG-BLOCK: outerLatch.1:
5132 ; EPILOG-BLOCK-NEXT: br label %outerloopHdr, !llvm.loop !15
5134 ; PROLOG-LABEL: @test9(
5136 ; PROLOG-NEXT: %0 = add i32 %n, -1
5137 ; PROLOG-NEXT: br label %outerloopHdr
5138 ; PROLOG: outerloopHdr:
5139 ; PROLOG-NEXT: %trip = add i32 %n, -1
5140 ; PROLOG-NEXT: %outercnd = icmp slt i32 0, %trip
5141 ; PROLOG-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
5142 ; PROLOG: preheader:
5143 ; PROLOG-NEXT: %i4 = zext i32 0 to i64
5144 ; PROLOG-NEXT: %1 = freeze i32 %0
5145 ; PROLOG-NEXT: %2 = add i32 %1, -1
5146 ; PROLOG-NEXT: %xtraiter = and i32 %1, 7
5147 ; PROLOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
5148 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
5149 ; PROLOG: header.prol.preheader:
5150 ; PROLOG-NEXT: br label %header.prol
5151 ; PROLOG: header.prol:
5152 ; PROLOG-NEXT: %phi.prol = phi i64 [ %i4, %header.prol.preheader ], [ %iv.next.prol, %latch.prol ]
5153 ; PROLOG-NEXT: %prol.iter = phi i32 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
5154 ; PROLOG-NEXT: %i7.prol = trunc i64 %phi.prol to i32
5155 ; PROLOG-NEXT: br i1 true, label %latch.prol, label %innerexit.loopexit1
5156 ; PROLOG: latch.prol:
5157 ; PROLOG-NEXT: %i11.prol = add nsw i32 %i7.prol, 1
5158 ; PROLOG-NEXT: %innercnd.prol = icmp slt i32 %i11.prol, %trip
5159 ; PROLOG-NEXT: %iv.next.prol = add nuw nsw i64 %phi.prol, 1
5160 ; PROLOG-NEXT: %prol.iter.next = add i32 %prol.iter, 1
5161 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i32 %prol.iter.next, %xtraiter
5162 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !13
5163 ; PROLOG: header.prol.loopexit.unr-lcssa:
5164 ; PROLOG-NEXT: %phi.unr.ph = phi i64 [ %iv.next.prol, %latch.prol ]
5165 ; PROLOG-NEXT: br label %header.prol.loopexit
5166 ; PROLOG: header.prol.loopexit:
5167 ; PROLOG-NEXT: %phi.unr = phi i64 [ %i4, %preheader ], [ %phi.unr.ph, %header.prol.loopexit.unr-lcssa ]
5168 ; PROLOG-NEXT: %3 = icmp ult i32 %2, 7
5169 ; PROLOG-NEXT: br i1 %3, label %outerLatch.loopexit, label %preheader.new
5170 ; PROLOG: preheader.new:
5171 ; PROLOG-NEXT: br label %header
5173 ; PROLOG-NEXT: %phi = phi i64 [ %phi.unr, %preheader.new ], [ %iv.next.7, %latch.7 ]
5174 ; PROLOG-NEXT: br i1 true, label %latch, label %innerexit.loopexit
5175 ; PROLOG: innerexit.loopexit:
5176 ; 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 ]
5177 ; PROLOG-NEXT: br label %innerexit
5178 ; PROLOG: innerexit.loopexit1:
5179 ; PROLOG-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.prol ]
5180 ; PROLOG-NEXT: br label %innerexit
5181 ; PROLOG: innerexit:
5182 ; PROLOG-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
5183 ; PROLOG-NEXT: %i9 = call i8 addrspace(1)* @foo(i32 %trip.lcssa)
5184 ; PROLOG-NEXT: ret i8 addrspace(1)* %i9
5186 ; PROLOG-NEXT: %iv.next = add nuw nsw i64 %phi, 1
5187 ; PROLOG-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit
5189 ; PROLOG-NEXT: %iv.next.1 = add nuw nsw i64 %iv.next, 1
5190 ; PROLOG-NEXT: br i1 true, label %latch.2, label %innerexit.loopexit
5192 ; PROLOG-NEXT: %iv.next.2 = add nuw nsw i64 %iv.next.1, 1
5193 ; PROLOG-NEXT: br i1 true, label %latch.3, label %innerexit.loopexit
5195 ; PROLOG-NEXT: %iv.next.3 = add nuw nsw i64 %iv.next.2, 1
5196 ; PROLOG-NEXT: br i1 true, label %latch.4, label %innerexit.loopexit
5198 ; PROLOG-NEXT: %iv.next.4 = add nuw nsw i64 %iv.next.3, 1
5199 ; PROLOG-NEXT: br i1 true, label %latch.5, label %innerexit.loopexit
5201 ; PROLOG-NEXT: %iv.next.5 = add nuw nsw i64 %iv.next.4, 1
5202 ; PROLOG-NEXT: br i1 true, label %latch.6, label %innerexit.loopexit
5204 ; PROLOG-NEXT: %iv.next.6 = add nuw nsw i64 %iv.next.5, 1
5205 ; PROLOG-NEXT: %i7.7 = trunc i64 %iv.next.6 to i32
5206 ; PROLOG-NEXT: br i1 true, label %latch.7, label %innerexit.loopexit
5208 ; PROLOG-NEXT: %i11.7 = add nsw i32 %i7.7, 1
5209 ; PROLOG-NEXT: %innercnd.7 = icmp slt i32 %i11.7, %trip
5210 ; PROLOG-NEXT: %iv.next.7 = add nuw nsw i64 %iv.next.6, 1
5211 ; PROLOG-NEXT: br i1 %innercnd.7, label %header, label %outerLatch.loopexit.unr-lcssa
5212 ; PROLOG: outerLatch.loopexit.unr-lcssa:
5213 ; PROLOG-NEXT: br label %outerLatch.loopexit
5214 ; PROLOG: outerLatch.loopexit:
5215 ; PROLOG-NEXT: br label %outerLatch
5216 ; PROLOG: outerLatch:
5217 ; PROLOG-NEXT: br label %outerloopHdr
5219 ; PROLOG-BLOCK-LABEL: @test9(
5220 ; PROLOG-BLOCK-NEXT: bb:
5221 ; PROLOG-BLOCK-NEXT: %0 = add i32 %n, -1
5222 ; PROLOG-BLOCK-NEXT: br label %outerloopHdr
5223 ; PROLOG-BLOCK: outerloopHdr:
5224 ; PROLOG-BLOCK-NEXT: %trip = add i32 %n, -1
5225 ; PROLOG-BLOCK-NEXT: %outercnd = icmp slt i32 0, %trip
5226 ; PROLOG-BLOCK-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
5227 ; PROLOG-BLOCK: preheader:
5228 ; PROLOG-BLOCK-NEXT: %1 = freeze i32 %0
5229 ; PROLOG-BLOCK-NEXT: %2 = add i32 %1, -1
5230 ; PROLOG-BLOCK-NEXT: %xtraiter = and i32 %1, 1
5231 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
5232 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
5233 ; PROLOG-BLOCK: header.prol.preheader:
5234 ; PROLOG-BLOCK-NEXT: br label %header.prol
5235 ; PROLOG-BLOCK: header.prol:
5236 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.prol, label %innerexit.loopexit1
5237 ; PROLOG-BLOCK: latch.prol:
5238 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
5239 ; PROLOG-BLOCK: header.prol.loopexit:
5240 ; PROLOG-BLOCK-NEXT: %phi.unr = phi i64 [ 0, %preheader ], [ 1, %latch.prol ]
5241 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i32 %2, 1
5242 ; PROLOG-BLOCK-NEXT: br i1 %3, label %outerLatch.loopexit, label %preheader.new
5243 ; PROLOG-BLOCK: preheader.new:
5244 ; PROLOG-BLOCK-NEXT: br label %header
5245 ; PROLOG-BLOCK: header:
5246 ; PROLOG-BLOCK-NEXT: %phi = phi i64 [ %phi.unr, %preheader.new ], [ %iv.next.1, %latch.1 ]
5247 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch, label %innerexit.loopexit.loopexit
5248 ; PROLOG-BLOCK: innerexit.loopexit.loopexit:
5249 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph.ph = phi i32 [ %trip, %latch ], [ %trip, %header ]
5250 ; PROLOG-BLOCK-NEXT: br label %innerexit.loopexit
5251 ; PROLOG-BLOCK: innerexit.loopexit.loopexit5:
5252 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph.ph6 = phi i32 [ %trip.1, %latch.14 ], [ %trip.1, %header.1 ]
5253 ; PROLOG-BLOCK-NEXT: br label %innerexit.loopexit
5254 ; PROLOG-BLOCK: innerexit.loopexit:
5255 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph = phi i32 [ %trip.lcssa.ph.ph, %innerexit.loopexit.loopexit ], [ %trip.lcssa.ph.ph6, %innerexit.loopexit.loopexit5 ]
5256 ; PROLOG-BLOCK-NEXT: br label %innerexit
5257 ; PROLOG-BLOCK: innerexit.loopexit1:
5258 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.prol ], [ %trip.1, %header.prol.1 ]
5259 ; PROLOG-BLOCK-NEXT: br label %innerexit
5260 ; PROLOG-BLOCK: innerexit:
5261 ; PROLOG-BLOCK-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
5262 ; PROLOG-BLOCK-NEXT: %i9 = call i8 addrspace(1)* @foo(i32 %trip.lcssa)
5263 ; PROLOG-BLOCK-NEXT: ret i8 addrspace(1)* %i9
5264 ; PROLOG-BLOCK: latch:
5265 ; PROLOG-BLOCK-NEXT: %iv.next = add nuw nsw i64 %phi, 1
5266 ; PROLOG-BLOCK-NEXT: %i7.1 = trunc i64 %iv.next to i32
5267 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit.loopexit
5268 ; PROLOG-BLOCK: latch.1:
5269 ; PROLOG-BLOCK-NEXT: %i11.1 = add nsw i32 %i7.1, 1
5270 ; PROLOG-BLOCK-NEXT: %innercnd.1 = icmp slt i32 %i11.1, %trip
5271 ; PROLOG-BLOCK-NEXT: %iv.next.1 = add nuw nsw i64 %iv.next, 1
5272 ; PROLOG-BLOCK-NEXT: br i1 %innercnd.1, label %header, label %outerLatch.loopexit.unr-lcssa, !llvm.loop !14
5273 ; PROLOG-BLOCK: outerLatch.loopexit.unr-lcssa:
5274 ; PROLOG-BLOCK-NEXT: br label %outerLatch.loopexit
5275 ; PROLOG-BLOCK: outerLatch.loopexit:
5276 ; PROLOG-BLOCK-NEXT: br label %outerLatch
5277 ; PROLOG-BLOCK: outerLatch:
5278 ; PROLOG-BLOCK-NEXT: %trip.1 = add i32 %n, -1
5279 ; PROLOG-BLOCK-NEXT: %outercnd.1 = icmp slt i32 0, %trip.1
5280 ; PROLOG-BLOCK-NEXT: br i1 %outercnd.1, label %preheader.1, label %outerLatch.1
5281 ; PROLOG-BLOCK: preheader.1:
5282 ; PROLOG-BLOCK-NEXT: %4 = freeze i32 %0
5283 ; PROLOG-BLOCK-NEXT: %5 = add i32 %4, -1
5284 ; PROLOG-BLOCK-NEXT: %xtraiter.1 = and i32 %4, 1
5285 ; PROLOG-BLOCK-NEXT: %lcmp.mod.1 = icmp ne i32 %xtraiter.1, 0
5286 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod.1, label %header.prol.preheader.1, label %header.prol.loopexit.1
5287 ; PROLOG-BLOCK: header.prol.preheader.1:
5288 ; PROLOG-BLOCK-NEXT: br label %header.prol.1
5289 ; PROLOG-BLOCK: header.prol.1:
5290 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.prol.1, label %innerexit.loopexit1
5291 ; PROLOG-BLOCK: latch.prol.1:
5292 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit.1
5293 ; PROLOG-BLOCK: header.prol.loopexit.1:
5294 ; PROLOG-BLOCK-NEXT: %phi.unr.1 = phi i64 [ 0, %preheader.1 ], [ 1, %latch.prol.1 ]
5295 ; PROLOG-BLOCK-NEXT: %6 = icmp ult i32 %5, 1
5296 ; PROLOG-BLOCK-NEXT: br i1 %6, label %outerLatch.loopexit.1, label %preheader.new.1
5297 ; PROLOG-BLOCK: preheader.new.1:
5298 ; PROLOG-BLOCK-NEXT: br label %header.1
5299 ; PROLOG-BLOCK: header.1:
5300 ; PROLOG-BLOCK-NEXT: %phi.1 = phi i64 [ %phi.unr.1, %preheader.new.1 ], [ %iv.next.1.1, %latch.1.1 ]
5301 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.14, label %innerexit.loopexit.loopexit5
5302 ; PROLOG-BLOCK: latch.14:
5303 ; PROLOG-BLOCK-NEXT: %iv.next.13 = add nuw nsw i64 %phi.1, 1
5304 ; PROLOG-BLOCK-NEXT: %i7.1.1 = trunc i64 %iv.next.13 to i32
5305 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.1.1, label %innerexit.loopexit.loopexit5
5306 ; PROLOG-BLOCK: latch.1.1:
5307 ; PROLOG-BLOCK-NEXT: %i11.1.1 = add nsw i32 %i7.1.1, 1
5308 ; PROLOG-BLOCK-NEXT: %innercnd.1.1 = icmp slt i32 %i11.1.1, %trip.1
5309 ; PROLOG-BLOCK-NEXT: %iv.next.1.1 = add nuw nsw i64 %iv.next.13, 1
5310 ; PROLOG-BLOCK-NEXT: br i1 %innercnd.1.1, label %header.1, label %outerLatch.loopexit.unr-lcssa.1, !llvm.loop !14
5311 ; PROLOG-BLOCK: outerLatch.loopexit.unr-lcssa.1:
5312 ; PROLOG-BLOCK-NEXT: br label %outerLatch.loopexit.1
5313 ; PROLOG-BLOCK: outerLatch.loopexit.1:
5314 ; PROLOG-BLOCK-NEXT: br label %outerLatch.1
5315 ; PROLOG-BLOCK: outerLatch.1:
5316 ; PROLOG-BLOCK-NEXT: br label %outerloopHdr, !llvm.loop !15
5319 br label %outerloopHdr
5321 outerloopHdr: ; preds = %outerLatch, %bb
5322 %trip = add i32 %n, -1
5323 %outercnd = icmp slt i32 0, %trip
5324 br i1 %outercnd, label %preheader, label %outerLatch
5326 preheader: ; preds = %outerloopHdr
5327 %i4 = zext i32 0 to i64
5330 header: ; preds = %latch, %preheader
5331 %phi = phi i64 [ %i4, %preheader ], [ %iv.next, %latch ]
5332 %i7 = trunc i64 %phi to i32
5333 br i1 true, label %latch, label %innerexit
5335 innerexit: ; preds = %header
5336 %i9 = call i8 addrspace(1)* @foo(i32 %trip)
5337 ret i8 addrspace(1)* %i9
5339 latch: ; preds = %header
5340 %i11 = add nsw i32 %i7, 1
5341 %innercnd = icmp slt i32 %i11, %trip
5342 %iv.next = add nuw nsw i64 %phi, 1
5343 br i1 %innercnd, label %header, label %outerLatch
5345 outerLatch: ; preds = %latch, %outerloopHdr
5346 br label %outerloopHdr
5351 ; This is a case where we should be able to eliminate N-1 copies
5352 ; of the early exit test in the main loop when runtime unrolling
5354 define void @test10(i64 %trip, i64 %trip2) {
5355 ; EPILOG-LABEL: @test10(
5356 ; EPILOG-NEXT: entry:
5357 ; EPILOG-NEXT: %0 = freeze i64 %trip
5358 ; EPILOG-NEXT: %1 = add i64 %0, -1
5359 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
5360 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
5361 ; EPILOG-NEXT: br i1 %2, label %exit2.unr-lcssa, label %entry.new
5362 ; EPILOG: entry.new:
5363 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5364 ; EPILOG-NEXT: br label %loop_header
5365 ; EPILOG: loop_header:
5366 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5367 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
5368 ; EPILOG-NEXT: call void @bar()
5369 ; EPILOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5370 ; EPILOG-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5371 ; EPILOG: loop_latch:
5372 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5373 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5374 ; EPILOG-NEXT: call void @bar()
5375 ; EPILOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5376 ; EPILOG-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5377 ; EPILOG: loop_latch.1:
5378 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
5379 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
5380 ; EPILOG-NEXT: call void @bar()
5381 ; EPILOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5382 ; EPILOG-NEXT: br i1 %cmp_early.2, label %loop_latch.2, label %exit1.loopexit
5383 ; EPILOG: loop_latch.2:
5384 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
5385 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
5386 ; EPILOG-NEXT: call void @bar()
5387 ; EPILOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5388 ; EPILOG-NEXT: br i1 %cmp_early.3, label %loop_latch.3, label %exit1.loopexit
5389 ; EPILOG: loop_latch.3:
5390 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
5391 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
5392 ; EPILOG-NEXT: call void @bar()
5393 ; EPILOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5394 ; EPILOG-NEXT: br i1 %cmp_early.4, label %loop_latch.4, label %exit1.loopexit
5395 ; EPILOG: loop_latch.4:
5396 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
5397 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
5398 ; EPILOG-NEXT: call void @bar()
5399 ; EPILOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5400 ; EPILOG-NEXT: br i1 %cmp_early.5, label %loop_latch.5, label %exit1.loopexit
5401 ; EPILOG: loop_latch.5:
5402 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
5403 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
5404 ; EPILOG-NEXT: call void @bar()
5405 ; EPILOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5406 ; EPILOG-NEXT: br i1 %cmp_early.6, label %loop_latch.6, label %exit1.loopexit
5407 ; EPILOG: loop_latch.6:
5408 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
5409 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
5410 ; EPILOG-NEXT: call void @bar()
5411 ; EPILOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5412 ; EPILOG-NEXT: br i1 %cmp_early.7, label %loop_latch.7, label %exit1.loopexit
5413 ; EPILOG: loop_latch.7:
5414 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5415 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
5416 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
5417 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.unr-lcssa.loopexit
5418 ; EPILOG: exit1.loopexit:
5419 ; EPILOG-NEXT: br label %exit1
5420 ; EPILOG: exit1.loopexit1:
5421 ; EPILOG-NEXT: br label %exit1
5423 ; EPILOG-NEXT: ret void
5424 ; EPILOG: exit2.unr-lcssa.loopexit:
5425 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
5426 ; EPILOG-NEXT: br label %exit2.unr-lcssa
5427 ; EPILOG: exit2.unr-lcssa:
5428 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.unr-lcssa.loopexit ]
5429 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5430 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5431 ; EPILOG: loop_header.epil.preheader:
5432 ; EPILOG-NEXT: br label %loop_header.epil
5433 ; EPILOG: loop_header.epil:
5434 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
5435 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
5436 ; EPILOG-NEXT: call void @bar()
5437 ; EPILOG-NEXT: %cmp_early.epil = icmp ne i64 %iv.epil, %trip2
5438 ; EPILOG-NEXT: br i1 %cmp_early.epil, label %loop_latch.epil, label %exit1.loopexit1
5439 ; EPILOG: loop_latch.epil:
5440 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
5441 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
5442 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
5443 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
5444 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.epilog-lcssa, !llvm.loop !14
5445 ; EPILOG: exit2.epilog-lcssa:
5446 ; EPILOG-NEXT: br label %exit2
5448 ; EPILOG-NEXT: ret void
5450 ; EPILOG-BLOCK-LABEL: @test10(
5451 ; EPILOG-BLOCK-NEXT: entry:
5452 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
5453 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
5454 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5455 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5456 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit2.unr-lcssa, label %entry.new
5457 ; EPILOG-BLOCK: entry.new:
5458 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5459 ; EPILOG-BLOCK-NEXT: br label %loop_header
5460 ; EPILOG-BLOCK: loop_header:
5461 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5462 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
5463 ; EPILOG-BLOCK-NEXT: call void @bar()
5464 ; EPILOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5465 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5466 ; EPILOG-BLOCK: loop_latch:
5467 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5468 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5469 ; EPILOG-BLOCK-NEXT: call void @bar()
5470 ; EPILOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5471 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5472 ; EPILOG-BLOCK: loop_latch.1:
5473 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
5474 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
5475 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
5476 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.unr-lcssa.loopexit, !llvm.loop !16
5477 ; EPILOG-BLOCK: exit1.loopexit:
5478 ; EPILOG-BLOCK-NEXT: br label %exit1
5479 ; EPILOG-BLOCK: exit1:
5480 ; EPILOG-BLOCK-NEXT: ret void
5481 ; EPILOG-BLOCK: exit2.unr-lcssa.loopexit:
5482 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
5483 ; EPILOG-BLOCK-NEXT: br label %exit2.unr-lcssa
5484 ; EPILOG-BLOCK: exit2.unr-lcssa:
5485 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.unr-lcssa.loopexit ]
5486 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5487 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5488 ; EPILOG-BLOCK: loop_header.epil.preheader:
5489 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
5490 ; EPILOG-BLOCK: loop_header.epil:
5491 ; EPILOG-BLOCK-NEXT: call void @bar()
5492 ; EPILOG-BLOCK-NEXT: %cmp_early.epil = icmp ne i64 %iv.unr, %trip2
5493 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.epil, label %loop_latch.epil, label %exit1
5494 ; EPILOG-BLOCK: loop_latch.epil:
5495 ; EPILOG-BLOCK-NEXT: br label %exit2
5496 ; EPILOG-BLOCK: exit2:
5497 ; EPILOG-BLOCK-NEXT: ret void
5499 ; PROLOG-LABEL: @test10(
5500 ; PROLOG-NEXT: entry:
5501 ; PROLOG-NEXT: %0 = freeze i64 %trip
5502 ; PROLOG-NEXT: %1 = add i64 %0, -1
5503 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
5504 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5505 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5506 ; PROLOG: loop_header.prol.preheader:
5507 ; PROLOG-NEXT: br label %loop_header.prol
5508 ; PROLOG: loop_header.prol:
5509 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
5510 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
5511 ; PROLOG-NEXT: call void @bar()
5512 ; PROLOG-NEXT: %cmp_early.prol = icmp ne i64 %iv.prol, %trip2
5513 ; PROLOG-NEXT: br i1 %cmp_early.prol, label %loop_latch.prol, label %exit1.loopexit1
5514 ; PROLOG: loop_latch.prol:
5515 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
5516 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
5517 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
5518 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
5519 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !14
5520 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
5521 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
5522 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
5523 ; PROLOG: loop_header.prol.loopexit:
5524 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
5525 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
5526 ; PROLOG-NEXT: br i1 %2, label %exit2, label %entry.new
5527 ; PROLOG: entry.new:
5528 ; PROLOG-NEXT: br label %loop_header
5529 ; PROLOG: loop_header:
5530 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5531 ; PROLOG-NEXT: call void @bar()
5532 ; PROLOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5533 ; PROLOG-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5534 ; PROLOG: loop_latch:
5535 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
5536 ; PROLOG-NEXT: call void @bar()
5537 ; PROLOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5538 ; PROLOG-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5539 ; PROLOG: loop_latch.1:
5540 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
5541 ; PROLOG-NEXT: call void @bar()
5542 ; PROLOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5543 ; PROLOG-NEXT: br i1 %cmp_early.2, label %loop_latch.2, label %exit1.loopexit
5544 ; PROLOG: loop_latch.2:
5545 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
5546 ; PROLOG-NEXT: call void @bar()
5547 ; PROLOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5548 ; PROLOG-NEXT: br i1 %cmp_early.3, label %loop_latch.3, label %exit1.loopexit
5549 ; PROLOG: loop_latch.3:
5550 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
5551 ; PROLOG-NEXT: call void @bar()
5552 ; PROLOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5553 ; PROLOG-NEXT: br i1 %cmp_early.4, label %loop_latch.4, label %exit1.loopexit
5554 ; PROLOG: loop_latch.4:
5555 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
5556 ; PROLOG-NEXT: call void @bar()
5557 ; PROLOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5558 ; PROLOG-NEXT: br i1 %cmp_early.5, label %loop_latch.5, label %exit1.loopexit
5559 ; PROLOG: loop_latch.5:
5560 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
5561 ; PROLOG-NEXT: call void @bar()
5562 ; PROLOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5563 ; PROLOG-NEXT: br i1 %cmp_early.6, label %loop_latch.6, label %exit1.loopexit
5564 ; PROLOG: loop_latch.6:
5565 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
5566 ; PROLOG-NEXT: call void @bar()
5567 ; PROLOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5568 ; PROLOG-NEXT: br i1 %cmp_early.7, label %loop_latch.7, label %exit1.loopexit
5569 ; PROLOG: loop_latch.7:
5570 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5571 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
5572 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.unr-lcssa
5573 ; PROLOG: exit1.loopexit:
5574 ; PROLOG-NEXT: br label %exit1
5575 ; PROLOG: exit1.loopexit1:
5576 ; PROLOG-NEXT: br label %exit1
5578 ; PROLOG-NEXT: ret void
5579 ; PROLOG: exit2.unr-lcssa:
5580 ; PROLOG-NEXT: br label %exit2
5582 ; PROLOG-NEXT: ret void
5584 ; PROLOG-BLOCK-LABEL: @test10(
5585 ; PROLOG-BLOCK-NEXT: entry:
5586 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
5587 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
5588 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5589 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5590 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5591 ; PROLOG-BLOCK: loop_header.prol.preheader:
5592 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
5593 ; PROLOG-BLOCK: loop_header.prol:
5594 ; PROLOG-BLOCK-NEXT: call void @bar()
5595 ; PROLOG-BLOCK-NEXT: %cmp_early.prol = icmp ne i64 0, %trip2
5596 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.prol, label %loop_latch.prol, label %exit1
5597 ; PROLOG-BLOCK: loop_latch.prol:
5598 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
5599 ; PROLOG-BLOCK: loop_header.prol.loopexit:
5600 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
5601 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5602 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit2, label %entry.new
5603 ; PROLOG-BLOCK: entry.new:
5604 ; PROLOG-BLOCK-NEXT: br label %loop_header
5605 ; PROLOG-BLOCK: loop_header:
5606 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5607 ; PROLOG-BLOCK-NEXT: call void @bar()
5608 ; PROLOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5609 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5610 ; PROLOG-BLOCK: loop_latch:
5611 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
5612 ; PROLOG-BLOCK-NEXT: call void @bar()
5613 ; PROLOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5614 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5615 ; PROLOG-BLOCK: loop_latch.1:
5616 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
5617 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
5618 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.unr-lcssa, !llvm.loop !16
5619 ; PROLOG-BLOCK: exit1.loopexit:
5620 ; PROLOG-BLOCK-NEXT: br label %exit1
5621 ; PROLOG-BLOCK: exit1:
5622 ; PROLOG-BLOCK-NEXT: ret void
5623 ; PROLOG-BLOCK: exit2.unr-lcssa:
5624 ; PROLOG-BLOCK-NEXT: br label %exit2
5625 ; PROLOG-BLOCK: exit2:
5626 ; PROLOG-BLOCK-NEXT: ret void
5629 br label %loop_header
5632 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
5634 %cmp_early = icmp ne i64 %iv, %trip2
5635 br i1 %cmp_early, label %loop_latch, label %exit1
5638 %iv_next = add i64 %iv, 1
5639 %cmp = icmp ne i64 %iv_next, %trip
5640 br i1 %cmp, label %loop_header, label %exit2
5649 ; With a loop invariant, we can eliminate the last N-1
5650 ; copies of the exit test in the unrolled main loop body.
5651 define void @test11(i64 %trip, i1 %cond) {
5652 ; EPILOG-LABEL: @test11(
5653 ; EPILOG-NEXT: entry:
5654 ; EPILOG-NEXT: %0 = freeze i64 %trip
5655 ; EPILOG-NEXT: %1 = add i64 %0, -1
5656 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
5657 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
5658 ; EPILOG-NEXT: br i1 %2, label %exit2.unr-lcssa, label %entry.new
5659 ; EPILOG: entry.new:
5660 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5661 ; EPILOG-NEXT: br label %loop_header
5662 ; EPILOG: loop_header:
5663 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5664 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
5665 ; EPILOG-NEXT: call void @bar()
5666 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5667 ; EPILOG: loop_latch:
5668 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5669 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5670 ; EPILOG-NEXT: call void @bar()
5671 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5672 ; EPILOG: loop_latch.1:
5673 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
5674 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
5675 ; EPILOG-NEXT: call void @bar()
5676 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.loopexit
5677 ; EPILOG: loop_latch.2:
5678 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
5679 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
5680 ; EPILOG-NEXT: call void @bar()
5681 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.loopexit
5682 ; EPILOG: loop_latch.3:
5683 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
5684 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
5685 ; EPILOG-NEXT: call void @bar()
5686 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.loopexit
5687 ; EPILOG: loop_latch.4:
5688 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
5689 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
5690 ; EPILOG-NEXT: call void @bar()
5691 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.loopexit
5692 ; EPILOG: loop_latch.5:
5693 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
5694 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
5695 ; EPILOG-NEXT: call void @bar()
5696 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.loopexit
5697 ; EPILOG: loop_latch.6:
5698 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
5699 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
5700 ; EPILOG-NEXT: call void @bar()
5701 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.loopexit
5702 ; EPILOG: loop_latch.7:
5703 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5704 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
5705 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
5706 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.unr-lcssa.loopexit
5707 ; EPILOG: exit1.loopexit:
5708 ; EPILOG-NEXT: br label %exit1
5709 ; EPILOG: exit1.loopexit1:
5710 ; EPILOG-NEXT: br label %exit1
5712 ; EPILOG-NEXT: ret void
5713 ; EPILOG: exit2.unr-lcssa.loopexit:
5714 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
5715 ; EPILOG-NEXT: br label %exit2.unr-lcssa
5716 ; EPILOG: exit2.unr-lcssa:
5717 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.unr-lcssa.loopexit ]
5718 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5719 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5720 ; EPILOG: loop_header.epil.preheader:
5721 ; EPILOG-NEXT: br label %loop_header.epil
5722 ; EPILOG: loop_header.epil:
5723 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
5724 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
5725 ; EPILOG-NEXT: call void @bar()
5726 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1.loopexit1
5727 ; EPILOG: loop_latch.epil:
5728 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
5729 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
5730 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
5731 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
5732 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.epilog-lcssa, !llvm.loop !15
5733 ; EPILOG: exit2.epilog-lcssa:
5734 ; EPILOG-NEXT: br label %exit2
5736 ; EPILOG-NEXT: ret void
5738 ; EPILOG-BLOCK-LABEL: @test11(
5739 ; EPILOG-BLOCK-NEXT: entry:
5740 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
5741 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
5742 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5743 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5744 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit2.unr-lcssa, label %entry.new
5745 ; EPILOG-BLOCK: entry.new:
5746 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5747 ; EPILOG-BLOCK-NEXT: br label %loop_header
5748 ; EPILOG-BLOCK: loop_header:
5749 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5750 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
5751 ; EPILOG-BLOCK-NEXT: call void @bar()
5752 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5753 ; EPILOG-BLOCK: loop_latch:
5754 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5755 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5756 ; EPILOG-BLOCK-NEXT: call void @bar()
5757 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5758 ; EPILOG-BLOCK: loop_latch.1:
5759 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
5760 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
5761 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
5762 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.unr-lcssa.loopexit, !llvm.loop !17
5763 ; EPILOG-BLOCK: exit1.loopexit:
5764 ; EPILOG-BLOCK-NEXT: br label %exit1
5765 ; EPILOG-BLOCK: exit1:
5766 ; EPILOG-BLOCK-NEXT: ret void
5767 ; EPILOG-BLOCK: exit2.unr-lcssa.loopexit:
5768 ; EPILOG-BLOCK-NEXT: br label %exit2.unr-lcssa
5769 ; EPILOG-BLOCK: exit2.unr-lcssa:
5770 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5771 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5772 ; EPILOG-BLOCK: loop_header.epil.preheader:
5773 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
5774 ; EPILOG-BLOCK: loop_header.epil:
5775 ; EPILOG-BLOCK-NEXT: call void @bar()
5776 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1
5777 ; EPILOG-BLOCK: loop_latch.epil:
5778 ; EPILOG-BLOCK-NEXT: br label %exit2
5779 ; EPILOG-BLOCK: exit2:
5780 ; EPILOG-BLOCK-NEXT: ret void
5782 ; PROLOG-LABEL: @test11(
5783 ; PROLOG-NEXT: entry:
5784 ; PROLOG-NEXT: %0 = freeze i64 %trip
5785 ; PROLOG-NEXT: %1 = add i64 %0, -1
5786 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
5787 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5788 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5789 ; PROLOG: loop_header.prol.preheader:
5790 ; PROLOG-NEXT: br label %loop_header.prol
5791 ; PROLOG: loop_header.prol:
5792 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
5793 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
5794 ; PROLOG-NEXT: call void @bar()
5795 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1.loopexit1
5796 ; PROLOG: loop_latch.prol:
5797 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
5798 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
5799 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
5800 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
5801 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !15
5802 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
5803 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
5804 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
5805 ; PROLOG: loop_header.prol.loopexit:
5806 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
5807 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
5808 ; PROLOG-NEXT: br i1 %2, label %exit2, label %entry.new
5809 ; PROLOG: entry.new:
5810 ; PROLOG-NEXT: br label %loop_header
5811 ; PROLOG: loop_header:
5812 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5813 ; PROLOG-NEXT: call void @bar()
5814 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5815 ; PROLOG: loop_latch:
5816 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
5817 ; PROLOG-NEXT: call void @bar()
5818 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5819 ; PROLOG: loop_latch.1:
5820 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
5821 ; PROLOG-NEXT: call void @bar()
5822 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.loopexit
5823 ; PROLOG: loop_latch.2:
5824 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
5825 ; PROLOG-NEXT: call void @bar()
5826 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.loopexit
5827 ; PROLOG: loop_latch.3:
5828 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
5829 ; PROLOG-NEXT: call void @bar()
5830 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.loopexit
5831 ; PROLOG: loop_latch.4:
5832 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
5833 ; PROLOG-NEXT: call void @bar()
5834 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.loopexit
5835 ; PROLOG: loop_latch.5:
5836 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
5837 ; PROLOG-NEXT: call void @bar()
5838 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.loopexit
5839 ; PROLOG: loop_latch.6:
5840 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
5841 ; PROLOG-NEXT: call void @bar()
5842 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.loopexit
5843 ; PROLOG: loop_latch.7:
5844 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5845 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
5846 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.unr-lcssa
5847 ; PROLOG: exit1.loopexit:
5848 ; PROLOG-NEXT: br label %exit1
5849 ; PROLOG: exit1.loopexit1:
5850 ; PROLOG-NEXT: br label %exit1
5852 ; PROLOG-NEXT: ret void
5853 ; PROLOG: exit2.unr-lcssa:
5854 ; PROLOG-NEXT: br label %exit2
5856 ; PROLOG-NEXT: ret void
5858 ; PROLOG-BLOCK-LABEL: @test11(
5859 ; PROLOG-BLOCK-NEXT: entry:
5860 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
5861 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
5862 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5863 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5864 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5865 ; PROLOG-BLOCK: loop_header.prol.preheader:
5866 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
5867 ; PROLOG-BLOCK: loop_header.prol:
5868 ; PROLOG-BLOCK-NEXT: call void @bar()
5869 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1
5870 ; PROLOG-BLOCK: loop_latch.prol:
5871 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
5872 ; PROLOG-BLOCK: loop_header.prol.loopexit:
5873 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
5874 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5875 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit2, label %entry.new
5876 ; PROLOG-BLOCK: entry.new:
5877 ; PROLOG-BLOCK-NEXT: br label %loop_header
5878 ; PROLOG-BLOCK: loop_header:
5879 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5880 ; PROLOG-BLOCK-NEXT: call void @bar()
5881 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5882 ; PROLOG-BLOCK: loop_latch:
5883 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
5884 ; PROLOG-BLOCK-NEXT: call void @bar()
5885 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5886 ; PROLOG-BLOCK: loop_latch.1:
5887 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
5888 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
5889 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.unr-lcssa, !llvm.loop !17
5890 ; PROLOG-BLOCK: exit1.loopexit:
5891 ; PROLOG-BLOCK-NEXT: br label %exit1
5892 ; PROLOG-BLOCK: exit1:
5893 ; PROLOG-BLOCK-NEXT: ret void
5894 ; PROLOG-BLOCK: exit2.unr-lcssa:
5895 ; PROLOG-BLOCK-NEXT: br label %exit2
5896 ; PROLOG-BLOCK: exit2:
5897 ; PROLOG-BLOCK-NEXT: ret void
5900 br label %loop_header
5903 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
5905 br i1 %cond, label %loop_latch, label %exit1
5908 %iv_next = add i64 %iv, 1
5909 %cmp = icmp ne i64 %iv_next, %trip
5910 br i1 %cmp, label %loop_header, label %exit2
5919 ; Combine a computeable and invariant test to make sure
5920 ; the interaction of both doesn't do anything weird
5921 define void @test12(i64 %trip, i64 %trip2, i1 %cond) {
5922 ; EPILOG-LABEL: @test12(
5923 ; EPILOG-NEXT: entry:
5924 ; EPILOG-NEXT: %0 = freeze i64 %trip
5925 ; EPILOG-NEXT: %1 = add i64 %0, -1
5926 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
5927 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
5928 ; EPILOG-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
5929 ; EPILOG: entry.new:
5930 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5931 ; EPILOG-NEXT: br label %loop_header
5932 ; EPILOG: loop_header:
5933 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5934 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
5935 ; EPILOG-NEXT: call void @bar()
5936 ; EPILOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5937 ; EPILOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
5938 ; EPILOG: loop_exiting_bb2:
5939 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.epilog-lcssa.loopexit
5940 ; EPILOG: loop_latch:
5941 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5942 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
5943 ; EPILOG-NEXT: call void @bar()
5944 ; EPILOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5945 ; EPILOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
5946 ; EPILOG: loop_exiting_bb2.1:
5947 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
5948 ; EPILOG: loop_latch.1:
5949 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
5950 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
5951 ; EPILOG-NEXT: call void @bar()
5952 ; EPILOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5953 ; EPILOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.epilog-lcssa.loopexit
5954 ; EPILOG: loop_exiting_bb2.2:
5955 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.epilog-lcssa.loopexit
5956 ; EPILOG: loop_latch.2:
5957 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
5958 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
5959 ; EPILOG-NEXT: call void @bar()
5960 ; EPILOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5961 ; EPILOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.epilog-lcssa.loopexit
5962 ; EPILOG: loop_exiting_bb2.3:
5963 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.epilog-lcssa.loopexit
5964 ; EPILOG: loop_latch.3:
5965 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
5966 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
5967 ; EPILOG-NEXT: call void @bar()
5968 ; EPILOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5969 ; EPILOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.epilog-lcssa.loopexit
5970 ; EPILOG: loop_exiting_bb2.4:
5971 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.epilog-lcssa.loopexit
5972 ; EPILOG: loop_latch.4:
5973 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
5974 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
5975 ; EPILOG-NEXT: call void @bar()
5976 ; EPILOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5977 ; EPILOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.epilog-lcssa.loopexit
5978 ; EPILOG: loop_exiting_bb2.5:
5979 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.epilog-lcssa.loopexit
5980 ; EPILOG: loop_latch.5:
5981 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
5982 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
5983 ; EPILOG-NEXT: call void @bar()
5984 ; EPILOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5985 ; EPILOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.epilog-lcssa.loopexit
5986 ; EPILOG: loop_exiting_bb2.6:
5987 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.epilog-lcssa.loopexit
5988 ; EPILOG: loop_latch.6:
5989 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
5990 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
5991 ; EPILOG-NEXT: call void @bar()
5992 ; EPILOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5993 ; EPILOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.epilog-lcssa.loopexit
5994 ; EPILOG: loop_exiting_bb2.7:
5995 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.epilog-lcssa.loopexit
5996 ; EPILOG: loop_latch.7:
5997 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
5998 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
5999 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
6000 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6001 ; EPILOG: exit1.unr-lcssa.loopexit:
6002 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
6003 ; EPILOG-NEXT: br label %exit1.unr-lcssa
6004 ; EPILOG: exit1.unr-lcssa:
6005 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6006 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6007 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6008 ; EPILOG: loop_header.epil.preheader:
6009 ; EPILOG-NEXT: br label %loop_header.epil
6010 ; EPILOG: loop_header.epil:
6011 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
6012 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
6013 ; EPILOG-NEXT: call void @bar()
6014 ; EPILOG-NEXT: %cmp_early.epil = icmp ne i64 %iv.epil, %trip2
6015 ; EPILOG-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa.loopexit1
6016 ; EPILOG: loop_exiting_bb2.epil:
6017 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1.epilog-lcssa.loopexit1
6018 ; EPILOG: loop_latch.epil:
6019 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
6020 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
6021 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
6022 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
6023 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit1.epilog-lcssa.loopexit1, !llvm.loop !16
6024 ; EPILOG: exit1.epilog-lcssa.loopexit:
6025 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6026 ; EPILOG: exit1.epilog-lcssa.loopexit1:
6027 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6028 ; EPILOG: exit1.epilog-lcssa:
6029 ; EPILOG-NEXT: br label %exit1
6031 ; EPILOG-NEXT: ret void
6033 ; EPILOG-BLOCK-LABEL: @test12(
6034 ; EPILOG-BLOCK-NEXT: entry:
6035 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
6036 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
6037 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6038 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6039 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
6040 ; EPILOG-BLOCK: entry.new:
6041 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
6042 ; EPILOG-BLOCK-NEXT: br label %loop_header
6043 ; EPILOG-BLOCK: loop_header:
6044 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6045 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
6046 ; EPILOG-BLOCK-NEXT: call void @bar()
6047 ; EPILOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6048 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6049 ; EPILOG-BLOCK: loop_exiting_bb2:
6050 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6051 ; EPILOG-BLOCK: loop_latch:
6052 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6053 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
6054 ; EPILOG-BLOCK-NEXT: call void @bar()
6055 ; EPILOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6056 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6057 ; EPILOG-BLOCK: loop_exiting_bb2.1:
6058 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6059 ; EPILOG-BLOCK: loop_latch.1:
6060 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6061 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
6062 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
6063 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !18
6064 ; EPILOG-BLOCK: exit1.unr-lcssa.loopexit:
6065 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
6066 ; EPILOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6067 ; EPILOG-BLOCK: exit1.unr-lcssa:
6068 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6069 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6070 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6071 ; EPILOG-BLOCK: loop_header.epil.preheader:
6072 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
6073 ; EPILOG-BLOCK: loop_header.epil:
6074 ; EPILOG-BLOCK-NEXT: call void @bar()
6075 ; EPILOG-BLOCK-NEXT: %cmp_early.epil = icmp ne i64 %iv.unr, %trip2
6076 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa
6077 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
6078 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1.epilog-lcssa
6079 ; EPILOG-BLOCK: loop_latch.epil:
6080 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6081 ; EPILOG-BLOCK: exit1.epilog-lcssa.loopexit:
6082 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6083 ; EPILOG-BLOCK: exit1.epilog-lcssa:
6084 ; EPILOG-BLOCK-NEXT: br label %exit1
6085 ; EPILOG-BLOCK: exit1:
6086 ; EPILOG-BLOCK-NEXT: ret void
6088 ; PROLOG-LABEL: @test12(
6089 ; PROLOG-NEXT: entry:
6090 ; PROLOG-NEXT: %0 = freeze i64 %trip
6091 ; PROLOG-NEXT: %1 = add i64 %0, -1
6092 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
6093 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6094 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6095 ; PROLOG: loop_header.prol.preheader:
6096 ; PROLOG-NEXT: br label %loop_header.prol
6097 ; PROLOG: loop_header.prol:
6098 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
6099 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
6100 ; PROLOG-NEXT: call void @bar()
6101 ; PROLOG-NEXT: %cmp_early.prol = icmp ne i64 %iv.prol, %trip2
6102 ; PROLOG-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa.loopexit1
6103 ; PROLOG: loop_exiting_bb2.prol:
6104 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1.unr-lcssa.loopexit1
6105 ; PROLOG: loop_latch.prol:
6106 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
6107 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
6108 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
6109 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
6110 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !16
6111 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
6112 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
6113 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
6114 ; PROLOG: loop_header.prol.loopexit:
6115 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
6116 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
6117 ; PROLOG-NEXT: br i1 %2, label %exit1, label %entry.new
6118 ; PROLOG: entry.new:
6119 ; PROLOG-NEXT: br label %loop_header
6120 ; PROLOG: loop_header:
6121 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6122 ; PROLOG-NEXT: call void @bar()
6123 ; PROLOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6124 ; PROLOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6125 ; PROLOG: loop_exiting_bb2:
6126 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.unr-lcssa.loopexit
6127 ; PROLOG: loop_latch:
6128 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
6129 ; PROLOG-NEXT: call void @bar()
6130 ; PROLOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6131 ; PROLOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6132 ; PROLOG: loop_exiting_bb2.1:
6133 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6134 ; PROLOG: loop_latch.1:
6135 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
6136 ; PROLOG-NEXT: call void @bar()
6137 ; PROLOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
6138 ; PROLOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.unr-lcssa.loopexit
6139 ; PROLOG: loop_exiting_bb2.2:
6140 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.unr-lcssa.loopexit
6141 ; PROLOG: loop_latch.2:
6142 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
6143 ; PROLOG-NEXT: call void @bar()
6144 ; PROLOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
6145 ; PROLOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.unr-lcssa.loopexit
6146 ; PROLOG: loop_exiting_bb2.3:
6147 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.unr-lcssa.loopexit
6148 ; PROLOG: loop_latch.3:
6149 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
6150 ; PROLOG-NEXT: call void @bar()
6151 ; PROLOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
6152 ; PROLOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.unr-lcssa.loopexit
6153 ; PROLOG: loop_exiting_bb2.4:
6154 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.unr-lcssa.loopexit
6155 ; PROLOG: loop_latch.4:
6156 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
6157 ; PROLOG-NEXT: call void @bar()
6158 ; PROLOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
6159 ; PROLOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.unr-lcssa.loopexit
6160 ; PROLOG: loop_exiting_bb2.5:
6161 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.unr-lcssa.loopexit
6162 ; PROLOG: loop_latch.5:
6163 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
6164 ; PROLOG-NEXT: call void @bar()
6165 ; PROLOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
6166 ; PROLOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.unr-lcssa.loopexit
6167 ; PROLOG: loop_exiting_bb2.6:
6168 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.unr-lcssa.loopexit
6169 ; PROLOG: loop_latch.6:
6170 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
6171 ; PROLOG-NEXT: call void @bar()
6172 ; PROLOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
6173 ; PROLOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.unr-lcssa.loopexit
6174 ; PROLOG: loop_exiting_bb2.7:
6175 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.unr-lcssa.loopexit
6176 ; PROLOG: loop_latch.7:
6177 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6178 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
6179 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6180 ; PROLOG: exit1.unr-lcssa.loopexit:
6181 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6182 ; PROLOG: exit1.unr-lcssa.loopexit1:
6183 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6184 ; PROLOG: exit1.unr-lcssa:
6185 ; PROLOG-NEXT: br label %exit1
6187 ; PROLOG-NEXT: ret void
6189 ; PROLOG-BLOCK-LABEL: @test12(
6190 ; PROLOG-BLOCK-NEXT: entry:
6191 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
6192 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
6193 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6194 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6195 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6196 ; PROLOG-BLOCK: loop_header.prol.preheader:
6197 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
6198 ; PROLOG-BLOCK: loop_header.prol:
6199 ; PROLOG-BLOCK-NEXT: call void @bar()
6200 ; PROLOG-BLOCK-NEXT: %cmp_early.prol = icmp ne i64 0, %trip2
6201 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa
6202 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
6203 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1.unr-lcssa
6204 ; PROLOG-BLOCK: loop_latch.prol:
6205 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
6206 ; PROLOG-BLOCK: loop_header.prol.loopexit:
6207 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
6208 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6209 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit1, label %entry.new
6210 ; PROLOG-BLOCK: entry.new:
6211 ; PROLOG-BLOCK-NEXT: br label %loop_header
6212 ; PROLOG-BLOCK: loop_header:
6213 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6214 ; PROLOG-BLOCK-NEXT: call void @bar()
6215 ; PROLOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6216 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6217 ; PROLOG-BLOCK: loop_exiting_bb2:
6218 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.unr-lcssa.loopexit
6219 ; PROLOG-BLOCK: loop_latch:
6220 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
6221 ; PROLOG-BLOCK-NEXT: call void @bar()
6222 ; PROLOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6223 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6224 ; PROLOG-BLOCK: loop_exiting_bb2.1:
6225 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6226 ; PROLOG-BLOCK: loop_latch.1:
6227 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6228 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
6229 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !18
6230 ; PROLOG-BLOCK: exit1.unr-lcssa.loopexit:
6231 ; PROLOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6232 ; PROLOG-BLOCK: exit1.unr-lcssa:
6233 ; PROLOG-BLOCK-NEXT: br label %exit1
6234 ; PROLOG-BLOCK: exit1:
6235 ; PROLOG-BLOCK-NEXT: ret void
6238 br label %loop_header
6241 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
6243 %cmp_early = icmp ne i64 %iv, %trip2
6244 br i1 %cmp_early, label %loop_exiting_bb2, label %exit1
6247 br i1 %cond, label %loop_latch, label %exit1
6250 %iv_next = add i64 %iv, 1
6251 %cmp = icmp ne i64 %iv_next, %trip
6252 br i1 %cmp, label %loop_header, label %exit1
6258 declare i1 @unknown_cond()
6260 ; Mix of computable and uncompatable exits
6261 define void @test13(i64 %trip, i64 %trip2) {
6262 ; EPILOG-LABEL: @test13(
6263 ; EPILOG-NEXT: entry:
6264 ; EPILOG-NEXT: %0 = freeze i64 %trip
6265 ; EPILOG-NEXT: %1 = add i64 %0, -1
6266 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
6267 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
6268 ; EPILOG-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
6269 ; EPILOG: entry.new:
6270 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
6271 ; EPILOG-NEXT: br label %loop_header
6272 ; EPILOG: loop_header:
6273 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6274 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
6275 ; EPILOG-NEXT: call void @bar()
6276 ; EPILOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6277 ; EPILOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6278 ; EPILOG: loop_exiting_bb2:
6279 ; EPILOG-NEXT: %unknown = call i1 @unknown_cond()
6280 ; EPILOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6281 ; EPILOG: loop_latch:
6282 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6283 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
6284 ; EPILOG-NEXT: call void @bar()
6285 ; EPILOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6286 ; EPILOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6287 ; EPILOG: loop_exiting_bb2.1:
6288 ; EPILOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6289 ; EPILOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6290 ; EPILOG: loop_latch.1:
6291 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
6292 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
6293 ; EPILOG-NEXT: call void @bar()
6294 ; EPILOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
6295 ; EPILOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.epilog-lcssa.loopexit
6296 ; EPILOG: loop_exiting_bb2.2:
6297 ; EPILOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6298 ; EPILOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.epilog-lcssa.loopexit
6299 ; EPILOG: loop_latch.2:
6300 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
6301 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
6302 ; EPILOG-NEXT: call void @bar()
6303 ; EPILOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
6304 ; EPILOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.epilog-lcssa.loopexit
6305 ; EPILOG: loop_exiting_bb2.3:
6306 ; EPILOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6307 ; EPILOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.epilog-lcssa.loopexit
6308 ; EPILOG: loop_latch.3:
6309 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
6310 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
6311 ; EPILOG-NEXT: call void @bar()
6312 ; EPILOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
6313 ; EPILOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.epilog-lcssa.loopexit
6314 ; EPILOG: loop_exiting_bb2.4:
6315 ; EPILOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6316 ; EPILOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.epilog-lcssa.loopexit
6317 ; EPILOG: loop_latch.4:
6318 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
6319 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
6320 ; EPILOG-NEXT: call void @bar()
6321 ; EPILOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
6322 ; EPILOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.epilog-lcssa.loopexit
6323 ; EPILOG: loop_exiting_bb2.5:
6324 ; EPILOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6325 ; EPILOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.epilog-lcssa.loopexit
6326 ; EPILOG: loop_latch.5:
6327 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
6328 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
6329 ; EPILOG-NEXT: call void @bar()
6330 ; EPILOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
6331 ; EPILOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.epilog-lcssa.loopexit
6332 ; EPILOG: loop_exiting_bb2.6:
6333 ; EPILOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6334 ; EPILOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.epilog-lcssa.loopexit
6335 ; EPILOG: loop_latch.6:
6336 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
6337 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
6338 ; EPILOG-NEXT: call void @bar()
6339 ; EPILOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
6340 ; EPILOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.epilog-lcssa.loopexit
6341 ; EPILOG: loop_exiting_bb2.7:
6342 ; EPILOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6343 ; EPILOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.epilog-lcssa.loopexit
6344 ; EPILOG: loop_latch.7:
6345 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6346 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
6347 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
6348 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6349 ; EPILOG: exit1.unr-lcssa.loopexit:
6350 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
6351 ; EPILOG-NEXT: br label %exit1.unr-lcssa
6352 ; EPILOG: exit1.unr-lcssa:
6353 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6354 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6355 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6356 ; EPILOG: loop_header.epil.preheader:
6357 ; EPILOG-NEXT: br label %loop_header.epil
6358 ; EPILOG: loop_header.epil:
6359 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
6360 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
6361 ; EPILOG-NEXT: call void @bar()
6362 ; EPILOG-NEXT: %cmp_early.epil = icmp ne i64 %iv.epil, %trip2
6363 ; EPILOG-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa.loopexit1
6364 ; EPILOG: loop_exiting_bb2.epil:
6365 ; EPILOG-NEXT: %unknown.epil = call i1 @unknown_cond()
6366 ; EPILOG-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa.loopexit1
6367 ; EPILOG: loop_latch.epil:
6368 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
6369 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
6370 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
6371 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
6372 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit1.epilog-lcssa.loopexit1, !llvm.loop !17
6373 ; EPILOG: exit1.epilog-lcssa.loopexit:
6374 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6375 ; EPILOG: exit1.epilog-lcssa.loopexit1:
6376 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6377 ; EPILOG: exit1.epilog-lcssa:
6378 ; EPILOG-NEXT: br label %exit1
6380 ; EPILOG-NEXT: ret void
6382 ; EPILOG-BLOCK-LABEL: @test13(
6383 ; EPILOG-BLOCK-NEXT: entry:
6384 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
6385 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
6386 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6387 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6388 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
6389 ; EPILOG-BLOCK: entry.new:
6390 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
6391 ; EPILOG-BLOCK-NEXT: br label %loop_header
6392 ; EPILOG-BLOCK: loop_header:
6393 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6394 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
6395 ; EPILOG-BLOCK-NEXT: call void @bar()
6396 ; EPILOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6397 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6398 ; EPILOG-BLOCK: loop_exiting_bb2:
6399 ; EPILOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6400 ; EPILOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6401 ; EPILOG-BLOCK: loop_latch:
6402 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6403 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
6404 ; EPILOG-BLOCK-NEXT: call void @bar()
6405 ; EPILOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6406 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6407 ; EPILOG-BLOCK: loop_exiting_bb2.1:
6408 ; EPILOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6409 ; EPILOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6410 ; EPILOG-BLOCK: loop_latch.1:
6411 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6412 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
6413 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
6414 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !19
6415 ; EPILOG-BLOCK: exit1.unr-lcssa.loopexit:
6416 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
6417 ; EPILOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6418 ; EPILOG-BLOCK: exit1.unr-lcssa:
6419 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6420 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6421 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6422 ; EPILOG-BLOCK: loop_header.epil.preheader:
6423 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
6424 ; EPILOG-BLOCK: loop_header.epil:
6425 ; EPILOG-BLOCK-NEXT: call void @bar()
6426 ; EPILOG-BLOCK-NEXT: %cmp_early.epil = icmp ne i64 %iv.unr, %trip2
6427 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa
6428 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
6429 ; EPILOG-BLOCK-NEXT: %unknown.epil = call i1 @unknown_cond()
6430 ; EPILOG-BLOCK-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa
6431 ; EPILOG-BLOCK: loop_latch.epil:
6432 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6433 ; EPILOG-BLOCK: exit1.epilog-lcssa.loopexit:
6434 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6435 ; EPILOG-BLOCK: exit1.epilog-lcssa:
6436 ; EPILOG-BLOCK-NEXT: br label %exit1
6437 ; EPILOG-BLOCK: exit1:
6438 ; EPILOG-BLOCK-NEXT: ret void
6440 ; PROLOG-LABEL: @test13(
6441 ; PROLOG-NEXT: entry:
6442 ; PROLOG-NEXT: %0 = freeze i64 %trip
6443 ; PROLOG-NEXT: %1 = add i64 %0, -1
6444 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
6445 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6446 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6447 ; PROLOG: loop_header.prol.preheader:
6448 ; PROLOG-NEXT: br label %loop_header.prol
6449 ; PROLOG: loop_header.prol:
6450 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
6451 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
6452 ; PROLOG-NEXT: call void @bar()
6453 ; PROLOG-NEXT: %cmp_early.prol = icmp ne i64 %iv.prol, %trip2
6454 ; PROLOG-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa.loopexit1
6455 ; PROLOG: loop_exiting_bb2.prol:
6456 ; PROLOG-NEXT: %unknown.prol = call i1 @unknown_cond()
6457 ; PROLOG-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa.loopexit1
6458 ; PROLOG: loop_latch.prol:
6459 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
6460 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
6461 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
6462 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
6463 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !17
6464 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
6465 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
6466 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
6467 ; PROLOG: loop_header.prol.loopexit:
6468 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
6469 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
6470 ; PROLOG-NEXT: br i1 %2, label %exit1, label %entry.new
6471 ; PROLOG: entry.new:
6472 ; PROLOG-NEXT: br label %loop_header
6473 ; PROLOG: loop_header:
6474 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6475 ; PROLOG-NEXT: call void @bar()
6476 ; PROLOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6477 ; PROLOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6478 ; PROLOG: loop_exiting_bb2:
6479 ; PROLOG-NEXT: %unknown = call i1 @unknown_cond()
6480 ; PROLOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6481 ; PROLOG: loop_latch:
6482 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
6483 ; PROLOG-NEXT: call void @bar()
6484 ; PROLOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6485 ; PROLOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6486 ; PROLOG: loop_exiting_bb2.1:
6487 ; PROLOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6488 ; PROLOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6489 ; PROLOG: loop_latch.1:
6490 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
6491 ; PROLOG-NEXT: call void @bar()
6492 ; PROLOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
6493 ; PROLOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.unr-lcssa.loopexit
6494 ; PROLOG: loop_exiting_bb2.2:
6495 ; PROLOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6496 ; PROLOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.unr-lcssa.loopexit
6497 ; PROLOG: loop_latch.2:
6498 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
6499 ; PROLOG-NEXT: call void @bar()
6500 ; PROLOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
6501 ; PROLOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.unr-lcssa.loopexit
6502 ; PROLOG: loop_exiting_bb2.3:
6503 ; PROLOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6504 ; PROLOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.unr-lcssa.loopexit
6505 ; PROLOG: loop_latch.3:
6506 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
6507 ; PROLOG-NEXT: call void @bar()
6508 ; PROLOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
6509 ; PROLOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.unr-lcssa.loopexit
6510 ; PROLOG: loop_exiting_bb2.4:
6511 ; PROLOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6512 ; PROLOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.unr-lcssa.loopexit
6513 ; PROLOG: loop_latch.4:
6514 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
6515 ; PROLOG-NEXT: call void @bar()
6516 ; PROLOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
6517 ; PROLOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.unr-lcssa.loopexit
6518 ; PROLOG: loop_exiting_bb2.5:
6519 ; PROLOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6520 ; PROLOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.unr-lcssa.loopexit
6521 ; PROLOG: loop_latch.5:
6522 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
6523 ; PROLOG-NEXT: call void @bar()
6524 ; PROLOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
6525 ; PROLOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.unr-lcssa.loopexit
6526 ; PROLOG: loop_exiting_bb2.6:
6527 ; PROLOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6528 ; PROLOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.unr-lcssa.loopexit
6529 ; PROLOG: loop_latch.6:
6530 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
6531 ; PROLOG-NEXT: call void @bar()
6532 ; PROLOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
6533 ; PROLOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.unr-lcssa.loopexit
6534 ; PROLOG: loop_exiting_bb2.7:
6535 ; PROLOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6536 ; PROLOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.unr-lcssa.loopexit
6537 ; PROLOG: loop_latch.7:
6538 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6539 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
6540 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6541 ; PROLOG: exit1.unr-lcssa.loopexit:
6542 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6543 ; PROLOG: exit1.unr-lcssa.loopexit1:
6544 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6545 ; PROLOG: exit1.unr-lcssa:
6546 ; PROLOG-NEXT: br label %exit1
6548 ; PROLOG-NEXT: ret void
6550 ; PROLOG-BLOCK-LABEL: @test13(
6551 ; PROLOG-BLOCK-NEXT: entry:
6552 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
6553 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
6554 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6555 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6556 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6557 ; PROLOG-BLOCK: loop_header.prol.preheader:
6558 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
6559 ; PROLOG-BLOCK: loop_header.prol:
6560 ; PROLOG-BLOCK-NEXT: call void @bar()
6561 ; PROLOG-BLOCK-NEXT: %cmp_early.prol = icmp ne i64 0, %trip2
6562 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa
6563 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
6564 ; PROLOG-BLOCK-NEXT: %unknown.prol = call i1 @unknown_cond()
6565 ; PROLOG-BLOCK-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa
6566 ; PROLOG-BLOCK: loop_latch.prol:
6567 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
6568 ; PROLOG-BLOCK: loop_header.prol.loopexit:
6569 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
6570 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6571 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit1, label %entry.new
6572 ; PROLOG-BLOCK: entry.new:
6573 ; PROLOG-BLOCK-NEXT: br label %loop_header
6574 ; PROLOG-BLOCK: loop_header:
6575 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6576 ; PROLOG-BLOCK-NEXT: call void @bar()
6577 ; PROLOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6578 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6579 ; PROLOG-BLOCK: loop_exiting_bb2:
6580 ; PROLOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6581 ; PROLOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6582 ; PROLOG-BLOCK: loop_latch:
6583 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
6584 ; PROLOG-BLOCK-NEXT: call void @bar()
6585 ; PROLOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6586 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6587 ; PROLOG-BLOCK: loop_exiting_bb2.1:
6588 ; PROLOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6589 ; PROLOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6590 ; PROLOG-BLOCK: loop_latch.1:
6591 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6592 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
6593 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !19
6594 ; PROLOG-BLOCK: exit1.unr-lcssa.loopexit:
6595 ; PROLOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6596 ; PROLOG-BLOCK: exit1.unr-lcssa:
6597 ; PROLOG-BLOCK-NEXT: br label %exit1
6598 ; PROLOG-BLOCK: exit1:
6599 ; PROLOG-BLOCK-NEXT: ret void
6602 br label %loop_header
6605 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
6607 %cmp_early = icmp ne i64 %iv, %trip2
6608 br i1 %cmp_early, label %loop_exiting_bb2, label %exit1
6611 %unknown = call i1 @unknown_cond()
6612 br i1 %unknown, label %loop_latch, label %exit1
6615 %iv_next = add i64 %iv, 1
6616 %cmp = icmp ne i64 %iv_next, %trip
6617 br i1 %cmp, label %loop_header, label %exit1
6623 ; Mix of invariant and (even in theory) uncomputable exits
6624 define void @test14(i64 %trip, i1 %cond) {
6625 ; EPILOG-LABEL: @test14(
6626 ; EPILOG-NEXT: entry:
6627 ; EPILOG-NEXT: %0 = freeze i64 %trip
6628 ; EPILOG-NEXT: %1 = add i64 %0, -1
6629 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
6630 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
6631 ; EPILOG-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
6632 ; EPILOG: entry.new:
6633 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
6634 ; EPILOG-NEXT: br label %loop_header
6635 ; EPILOG: loop_header:
6636 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6637 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
6638 ; EPILOG-NEXT: call void @bar()
6639 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6640 ; EPILOG: loop_exiting_bb2:
6641 ; EPILOG-NEXT: %unknown = call i1 @unknown_cond()
6642 ; EPILOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6643 ; EPILOG: loop_latch:
6644 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6645 ; EPILOG-NEXT: %niter.next = add nuw nsw i64 %niter, 1
6646 ; EPILOG-NEXT: call void @bar()
6647 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6648 ; EPILOG: loop_exiting_bb2.1:
6649 ; EPILOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6650 ; EPILOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6651 ; EPILOG: loop_latch.1:
6652 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv_next, 1
6653 ; EPILOG-NEXT: %niter.next.1 = add nuw nsw i64 %niter.next, 1
6654 ; EPILOG-NEXT: call void @bar()
6655 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.2, label %exit1.epilog-lcssa.loopexit
6656 ; EPILOG: loop_exiting_bb2.2:
6657 ; EPILOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6658 ; EPILOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.epilog-lcssa.loopexit
6659 ; EPILOG: loop_latch.2:
6660 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv_next.1, 1
6661 ; EPILOG-NEXT: %niter.next.2 = add nuw nsw i64 %niter.next.1, 1
6662 ; EPILOG-NEXT: call void @bar()
6663 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.3, label %exit1.epilog-lcssa.loopexit
6664 ; EPILOG: loop_exiting_bb2.3:
6665 ; EPILOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6666 ; EPILOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.epilog-lcssa.loopexit
6667 ; EPILOG: loop_latch.3:
6668 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv_next.2, 1
6669 ; EPILOG-NEXT: %niter.next.3 = add nuw nsw i64 %niter.next.2, 1
6670 ; EPILOG-NEXT: call void @bar()
6671 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.4, label %exit1.epilog-lcssa.loopexit
6672 ; EPILOG: loop_exiting_bb2.4:
6673 ; EPILOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6674 ; EPILOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.epilog-lcssa.loopexit
6675 ; EPILOG: loop_latch.4:
6676 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv_next.3, 1
6677 ; EPILOG-NEXT: %niter.next.4 = add nuw nsw i64 %niter.next.3, 1
6678 ; EPILOG-NEXT: call void @bar()
6679 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.5, label %exit1.epilog-lcssa.loopexit
6680 ; EPILOG: loop_exiting_bb2.5:
6681 ; EPILOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6682 ; EPILOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.epilog-lcssa.loopexit
6683 ; EPILOG: loop_latch.5:
6684 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv_next.4, 1
6685 ; EPILOG-NEXT: %niter.next.5 = add nuw nsw i64 %niter.next.4, 1
6686 ; EPILOG-NEXT: call void @bar()
6687 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.6, label %exit1.epilog-lcssa.loopexit
6688 ; EPILOG: loop_exiting_bb2.6:
6689 ; EPILOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6690 ; EPILOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.epilog-lcssa.loopexit
6691 ; EPILOG: loop_latch.6:
6692 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv_next.5, 1
6693 ; EPILOG-NEXT: %niter.next.6 = add nuw nsw i64 %niter.next.5, 1
6694 ; EPILOG-NEXT: call void @bar()
6695 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.7, label %exit1.epilog-lcssa.loopexit
6696 ; EPILOG: loop_exiting_bb2.7:
6697 ; EPILOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6698 ; EPILOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.epilog-lcssa.loopexit
6699 ; EPILOG: loop_latch.7:
6700 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6701 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter.next.6, 1
6702 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
6703 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6704 ; EPILOG: exit1.unr-lcssa.loopexit:
6705 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
6706 ; EPILOG-NEXT: br label %exit1.unr-lcssa
6707 ; EPILOG: exit1.unr-lcssa:
6708 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6709 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6710 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6711 ; EPILOG: loop_header.epil.preheader:
6712 ; EPILOG-NEXT: br label %loop_header.epil
6713 ; EPILOG: loop_header.epil:
6714 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
6715 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
6716 ; EPILOG-NEXT: call void @bar()
6717 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa.loopexit1
6718 ; EPILOG: loop_exiting_bb2.epil:
6719 ; EPILOG-NEXT: %unknown.epil = call i1 @unknown_cond()
6720 ; EPILOG-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa.loopexit1
6721 ; EPILOG: loop_latch.epil:
6722 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
6723 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
6724 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
6725 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
6726 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit1.epilog-lcssa.loopexit1, !llvm.loop !18
6727 ; EPILOG: exit1.epilog-lcssa.loopexit:
6728 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6729 ; EPILOG: exit1.epilog-lcssa.loopexit1:
6730 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6731 ; EPILOG: exit1.epilog-lcssa:
6732 ; EPILOG-NEXT: br label %exit1
6734 ; EPILOG-NEXT: ret void
6736 ; EPILOG-BLOCK-LABEL: @test14(
6737 ; EPILOG-BLOCK-NEXT: entry:
6738 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
6739 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
6740 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6741 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6742 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
6743 ; EPILOG-BLOCK: entry.new:
6744 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
6745 ; EPILOG-BLOCK-NEXT: br label %loop_header
6746 ; EPILOG-BLOCK: loop_header:
6747 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6748 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
6749 ; EPILOG-BLOCK-NEXT: call void @bar()
6750 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6751 ; EPILOG-BLOCK: loop_exiting_bb2:
6752 ; EPILOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6753 ; EPILOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6754 ; EPILOG-BLOCK: loop_latch:
6755 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6756 ; EPILOG-BLOCK-NEXT: %niter.next = add nuw nsw i64 %niter, 1
6757 ; EPILOG-BLOCK-NEXT: call void @bar()
6758 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6759 ; EPILOG-BLOCK: loop_exiting_bb2.1:
6760 ; EPILOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6761 ; EPILOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6762 ; EPILOG-BLOCK: loop_latch.1:
6763 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6764 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter.next, 1
6765 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
6766 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !20
6767 ; EPILOG-BLOCK: exit1.unr-lcssa.loopexit:
6768 ; EPILOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6769 ; EPILOG-BLOCK: exit1.unr-lcssa:
6770 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6771 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6772 ; EPILOG-BLOCK: loop_header.epil.preheader:
6773 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
6774 ; EPILOG-BLOCK: loop_header.epil:
6775 ; EPILOG-BLOCK-NEXT: call void @bar()
6776 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa
6777 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
6778 ; EPILOG-BLOCK-NEXT: %unknown.epil = call i1 @unknown_cond()
6779 ; EPILOG-BLOCK-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa
6780 ; EPILOG-BLOCK: loop_latch.epil:
6781 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6782 ; EPILOG-BLOCK: exit1.epilog-lcssa.loopexit:
6783 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6784 ; EPILOG-BLOCK: exit1.epilog-lcssa:
6785 ; EPILOG-BLOCK-NEXT: br label %exit1
6786 ; EPILOG-BLOCK: exit1:
6787 ; EPILOG-BLOCK-NEXT: ret void
6789 ; PROLOG-LABEL: @test14(
6790 ; PROLOG-NEXT: entry:
6791 ; PROLOG-NEXT: %0 = freeze i64 %trip
6792 ; PROLOG-NEXT: %1 = add i64 %0, -1
6793 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
6794 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6795 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6796 ; PROLOG: loop_header.prol.preheader:
6797 ; PROLOG-NEXT: br label %loop_header.prol
6798 ; PROLOG: loop_header.prol:
6799 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
6800 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
6801 ; PROLOG-NEXT: call void @bar()
6802 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa.loopexit1
6803 ; PROLOG: loop_exiting_bb2.prol:
6804 ; PROLOG-NEXT: %unknown.prol = call i1 @unknown_cond()
6805 ; PROLOG-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa.loopexit1
6806 ; PROLOG: loop_latch.prol:
6807 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
6808 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
6809 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
6810 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
6811 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !18
6812 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
6813 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
6814 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
6815 ; PROLOG: loop_header.prol.loopexit:
6816 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
6817 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
6818 ; PROLOG-NEXT: br i1 %2, label %exit1, label %entry.new
6819 ; PROLOG: entry.new:
6820 ; PROLOG-NEXT: br label %loop_header
6821 ; PROLOG: loop_header:
6822 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6823 ; PROLOG-NEXT: call void @bar()
6824 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6825 ; PROLOG: loop_exiting_bb2:
6826 ; PROLOG-NEXT: %unknown = call i1 @unknown_cond()
6827 ; PROLOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6828 ; PROLOG: loop_latch:
6829 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
6830 ; PROLOG-NEXT: call void @bar()
6831 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6832 ; PROLOG: loop_exiting_bb2.1:
6833 ; PROLOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6834 ; PROLOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6835 ; PROLOG: loop_latch.1:
6836 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv_next, 1
6837 ; PROLOG-NEXT: call void @bar()
6838 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.2, label %exit1.unr-lcssa.loopexit
6839 ; PROLOG: loop_exiting_bb2.2:
6840 ; PROLOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6841 ; PROLOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.unr-lcssa.loopexit
6842 ; PROLOG: loop_latch.2:
6843 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv_next.1, 1
6844 ; PROLOG-NEXT: call void @bar()
6845 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.3, label %exit1.unr-lcssa.loopexit
6846 ; PROLOG: loop_exiting_bb2.3:
6847 ; PROLOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6848 ; PROLOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.unr-lcssa.loopexit
6849 ; PROLOG: loop_latch.3:
6850 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv_next.2, 1
6851 ; PROLOG-NEXT: call void @bar()
6852 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.4, label %exit1.unr-lcssa.loopexit
6853 ; PROLOG: loop_exiting_bb2.4:
6854 ; PROLOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6855 ; PROLOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.unr-lcssa.loopexit
6856 ; PROLOG: loop_latch.4:
6857 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv_next.3, 1
6858 ; PROLOG-NEXT: call void @bar()
6859 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.5, label %exit1.unr-lcssa.loopexit
6860 ; PROLOG: loop_exiting_bb2.5:
6861 ; PROLOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6862 ; PROLOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.unr-lcssa.loopexit
6863 ; PROLOG: loop_latch.5:
6864 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv_next.4, 1
6865 ; PROLOG-NEXT: call void @bar()
6866 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.6, label %exit1.unr-lcssa.loopexit
6867 ; PROLOG: loop_exiting_bb2.6:
6868 ; PROLOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6869 ; PROLOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.unr-lcssa.loopexit
6870 ; PROLOG: loop_latch.6:
6871 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv_next.5, 1
6872 ; PROLOG-NEXT: call void @bar()
6873 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.7, label %exit1.unr-lcssa.loopexit
6874 ; PROLOG: loop_exiting_bb2.7:
6875 ; PROLOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6876 ; PROLOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.unr-lcssa.loopexit
6877 ; PROLOG: loop_latch.7:
6878 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv_next.6, 1
6879 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
6880 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6881 ; PROLOG: exit1.unr-lcssa.loopexit:
6882 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6883 ; PROLOG: exit1.unr-lcssa.loopexit1:
6884 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6885 ; PROLOG: exit1.unr-lcssa:
6886 ; PROLOG-NEXT: br label %exit1
6888 ; PROLOG-NEXT: ret void
6890 ; PROLOG-BLOCK-LABEL: @test14(
6891 ; PROLOG-BLOCK-NEXT: entry:
6892 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
6893 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
6894 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6895 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6896 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6897 ; PROLOG-BLOCK: loop_header.prol.preheader:
6898 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
6899 ; PROLOG-BLOCK: loop_header.prol:
6900 ; PROLOG-BLOCK-NEXT: call void @bar()
6901 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa
6902 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
6903 ; PROLOG-BLOCK-NEXT: %unknown.prol = call i1 @unknown_cond()
6904 ; PROLOG-BLOCK-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa
6905 ; PROLOG-BLOCK: loop_latch.prol:
6906 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
6907 ; PROLOG-BLOCK: loop_header.prol.loopexit:
6908 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
6909 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6910 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit1, label %entry.new
6911 ; PROLOG-BLOCK: entry.new:
6912 ; PROLOG-BLOCK-NEXT: br label %loop_header
6913 ; PROLOG-BLOCK: loop_header:
6914 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6915 ; PROLOG-BLOCK-NEXT: call void @bar()
6916 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6917 ; PROLOG-BLOCK: loop_exiting_bb2:
6918 ; PROLOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6919 ; PROLOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6920 ; PROLOG-BLOCK: loop_latch:
6921 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
6922 ; PROLOG-BLOCK-NEXT: call void @bar()
6923 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6924 ; PROLOG-BLOCK: loop_exiting_bb2.1:
6925 ; PROLOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6926 ; PROLOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6927 ; PROLOG-BLOCK: loop_latch.1:
6928 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv_next, 1
6929 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
6930 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !20
6931 ; PROLOG-BLOCK: exit1.unr-lcssa.loopexit:
6932 ; PROLOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6933 ; PROLOG-BLOCK: exit1.unr-lcssa:
6934 ; PROLOG-BLOCK-NEXT: br label %exit1
6935 ; PROLOG-BLOCK: exit1:
6936 ; PROLOG-BLOCK-NEXT: ret void
6939 br label %loop_header
6942 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
6944 br i1 %cond, label %loop_exiting_bb2, label %exit1
6947 %unknown = call i1 @unknown_cond()
6948 br i1 %unknown, label %loop_latch, label %exit1
6951 %iv_next = add i64 %iv, 1
6952 %cmp = icmp ne i64 %iv_next, %trip
6953 br i1 %cmp, label %loop_header, label %exit1