1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: -p
2 ; RUN: opt < %s -passes=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 -passes=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 -passes=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 -passes=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: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
38 ; EPILOG: loop_exiting_bb1.1:
39 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
40 ; EPILOG: loop_exiting_bb2.1:
41 ; EPILOG-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
42 ; EPILOG: loop_latch.1:
43 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting_bb1.2
44 ; EPILOG: loop_exiting_bb1.2:
45 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.2, label %exit1.loopexit
46 ; EPILOG: loop_exiting_bb2.2:
47 ; EPILOG-NEXT: br i1 false, label %loop_latch.2, label %exit3.loopexit
48 ; EPILOG: loop_latch.2:
49 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting_bb1.3
50 ; EPILOG: loop_exiting_bb1.3:
51 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.3, label %exit1.loopexit
52 ; EPILOG: loop_exiting_bb2.3:
53 ; EPILOG-NEXT: br i1 false, label %loop_latch.3, label %exit3.loopexit
54 ; EPILOG: loop_latch.3:
55 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting_bb1.4
56 ; EPILOG: loop_exiting_bb1.4:
57 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.4, label %exit1.loopexit
58 ; EPILOG: loop_exiting_bb2.4:
59 ; EPILOG-NEXT: br i1 false, label %loop_latch.4, label %exit3.loopexit
60 ; EPILOG: loop_latch.4:
61 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting_bb1.5
62 ; EPILOG: loop_exiting_bb1.5:
63 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.5, label %exit1.loopexit
64 ; EPILOG: loop_exiting_bb2.5:
65 ; EPILOG-NEXT: br i1 false, label %loop_latch.5, label %exit3.loopexit
66 ; EPILOG: loop_latch.5:
67 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting_bb1.6
68 ; EPILOG: loop_exiting_bb1.6:
69 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.6, label %exit1.loopexit
70 ; EPILOG: loop_exiting_bb2.6:
71 ; EPILOG-NEXT: br i1 false, label %loop_latch.6, label %exit3.loopexit
72 ; EPILOG: loop_latch.6:
73 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting_bb1.7
74 ; EPILOG: loop_exiting_bb1.7:
75 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.7, label %exit1.loopexit
76 ; EPILOG: loop_exiting_bb2.7:
77 ; EPILOG-NEXT: br i1 false, label %loop_latch.7, label %exit3.loopexit
78 ; EPILOG: loop_latch.7:
79 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv, 8
80 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
81 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
82 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit
83 ; EPILOG: exit1.loopexit:
84 ; EPILOG-NEXT: br label %exit1
85 ; EPILOG: exit1.loopexit1:
86 ; EPILOG-NEXT: br label %exit1
88 ; EPILOG-NEXT: ret void
89 ; EPILOG: exit2.loopexit.unr-lcssa.loopexit:
90 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
91 ; EPILOG-NEXT: br label %exit2.loopexit.unr-lcssa
92 ; EPILOG: exit2.loopexit.unr-lcssa:
93 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
94 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
95 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
96 ; EPILOG: loop_header.epil.preheader:
97 ; EPILOG-NEXT: br label %loop_header.epil
98 ; EPILOG: loop_header.epil:
99 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
100 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
101 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting_bb1.epil
102 ; EPILOG: loop_exiting_bb1.epil:
103 ; EPILOG-NEXT: br i1 false, label %loop_exiting_bb2.epil, label %exit1.loopexit1
104 ; EPILOG: loop_exiting_bb2.epil:
105 ; EPILOG-NEXT: br i1 false, label %loop_latch.epil, label %exit3.loopexit2
106 ; EPILOG: loop_latch.epil:
107 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
108 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
109 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
110 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
111 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.loopexit.epilog-lcssa, !llvm.loop !0
112 ; EPILOG: exit2.loopexit.epilog-lcssa:
113 ; EPILOG-NEXT: br label %exit2.loopexit
114 ; EPILOG: exit2.loopexit:
115 ; EPILOG-NEXT: ret void
117 ; EPILOG-BLOCK-LABEL: @test1(
118 ; EPILOG-BLOCK-NEXT: entry:
119 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
120 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
121 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
122 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
123 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit2.loopexit.unr-lcssa, label %entry.new
124 ; EPILOG-BLOCK: entry.new:
125 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
126 ; EPILOG-BLOCK-NEXT: br label %loop_header
127 ; EPILOG-BLOCK: loop_header:
128 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
129 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
130 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
131 ; EPILOG-BLOCK: loop_exiting_bb1:
132 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
133 ; EPILOG-BLOCK: loop_exiting_bb2:
134 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
135 ; EPILOG-BLOCK: exit3.loopexit:
136 ; EPILOG-BLOCK-NEXT: br label %exit3
137 ; EPILOG-BLOCK: exit3:
138 ; EPILOG-BLOCK-NEXT: ret void
139 ; EPILOG-BLOCK: loop_latch:
140 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
141 ; EPILOG-BLOCK: loop_exiting_bb1.1:
142 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
143 ; EPILOG-BLOCK: loop_exiting_bb2.1:
144 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
145 ; EPILOG-BLOCK: loop_latch.1:
146 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
147 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
148 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
149 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit, !llvm.loop !0
150 ; EPILOG-BLOCK: exit1.loopexit:
151 ; EPILOG-BLOCK-NEXT: br label %exit1
152 ; EPILOG-BLOCK: exit1:
153 ; EPILOG-BLOCK-NEXT: ret void
154 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa.loopexit:
155 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit.unr-lcssa
156 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa:
157 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
158 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
159 ; EPILOG-BLOCK: loop_header.epil.preheader:
160 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
161 ; EPILOG-BLOCK: loop_header.epil:
162 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting_bb1.epil
163 ; EPILOG-BLOCK: loop_exiting_bb1.epil:
164 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.epil, label %exit1
165 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
166 ; EPILOG-BLOCK-NEXT: br i1 false, label %loop_latch.epil, label %exit3
167 ; EPILOG-BLOCK: loop_latch.epil:
168 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit
169 ; EPILOG-BLOCK: exit2.loopexit:
170 ; EPILOG-BLOCK-NEXT: ret void
172 ; PROLOG-LABEL: @test1(
173 ; PROLOG-NEXT: entry:
174 ; PROLOG-NEXT: %0 = freeze i64 %trip
175 ; PROLOG-NEXT: %1 = add i64 %0, -1
176 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
177 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
178 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
179 ; PROLOG: loop_header.prol.preheader:
180 ; PROLOG-NEXT: br label %loop_header.prol
181 ; PROLOG: loop_header.prol:
182 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
183 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
184 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting_bb1.prol
185 ; PROLOG: loop_exiting_bb1.prol:
186 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.prol, label %exit1.loopexit1
187 ; PROLOG: loop_exiting_bb2.prol:
188 ; PROLOG-NEXT: br i1 false, label %loop_latch.prol, label %exit3.loopexit2
189 ; PROLOG: loop_latch.prol:
190 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
191 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
192 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
193 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
194 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !0
195 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
196 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
197 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
198 ; PROLOG: loop_header.prol.loopexit:
199 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
200 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
201 ; PROLOG-NEXT: br i1 %2, label %exit2.loopexit, label %entry.new
203 ; PROLOG-NEXT: br label %loop_header
204 ; PROLOG: loop_header:
205 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
206 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
207 ; PROLOG: loop_exiting_bb1:
208 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
209 ; PROLOG: loop_exiting_bb2:
210 ; PROLOG-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
211 ; PROLOG: exit3.loopexit:
212 ; PROLOG-NEXT: br label %exit3
213 ; PROLOG: exit3.loopexit2:
214 ; PROLOG-NEXT: br label %exit3
216 ; PROLOG-NEXT: ret void
217 ; PROLOG: loop_latch:
218 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
219 ; PROLOG: loop_exiting_bb1.1:
220 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
221 ; PROLOG: loop_exiting_bb2.1:
222 ; PROLOG-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
223 ; PROLOG: loop_latch.1:
224 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting_bb1.2
225 ; PROLOG: loop_exiting_bb1.2:
226 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.2, label %exit1.loopexit
227 ; PROLOG: loop_exiting_bb2.2:
228 ; PROLOG-NEXT: br i1 false, label %loop_latch.2, label %exit3.loopexit
229 ; PROLOG: loop_latch.2:
230 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting_bb1.3
231 ; PROLOG: loop_exiting_bb1.3:
232 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.3, label %exit1.loopexit
233 ; PROLOG: loop_exiting_bb2.3:
234 ; PROLOG-NEXT: br i1 false, label %loop_latch.3, label %exit3.loopexit
235 ; PROLOG: loop_latch.3:
236 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting_bb1.4
237 ; PROLOG: loop_exiting_bb1.4:
238 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.4, label %exit1.loopexit
239 ; PROLOG: loop_exiting_bb2.4:
240 ; PROLOG-NEXT: br i1 false, label %loop_latch.4, label %exit3.loopexit
241 ; PROLOG: loop_latch.4:
242 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting_bb1.5
243 ; PROLOG: loop_exiting_bb1.5:
244 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.5, label %exit1.loopexit
245 ; PROLOG: loop_exiting_bb2.5:
246 ; PROLOG-NEXT: br i1 false, label %loop_latch.5, label %exit3.loopexit
247 ; PROLOG: loop_latch.5:
248 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting_bb1.6
249 ; PROLOG: loop_exiting_bb1.6:
250 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.6, label %exit1.loopexit
251 ; PROLOG: loop_exiting_bb2.6:
252 ; PROLOG-NEXT: br i1 false, label %loop_latch.6, label %exit3.loopexit
253 ; PROLOG: loop_latch.6:
254 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting_bb1.7
255 ; PROLOG: loop_exiting_bb1.7:
256 ; PROLOG-NEXT: br i1 false, label %loop_exiting_bb2.7, label %exit1.loopexit
257 ; PROLOG: loop_exiting_bb2.7:
258 ; PROLOG-NEXT: br i1 false, label %loop_latch.7, label %exit3.loopexit
259 ; PROLOG: loop_latch.7:
260 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv, 8
261 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
262 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa
263 ; PROLOG: exit1.loopexit:
264 ; PROLOG-NEXT: br label %exit1
265 ; PROLOG: exit1.loopexit1:
266 ; PROLOG-NEXT: br label %exit1
268 ; PROLOG-NEXT: ret void
269 ; PROLOG: exit2.loopexit.unr-lcssa:
270 ; PROLOG-NEXT: br label %exit2.loopexit
271 ; PROLOG: exit2.loopexit:
272 ; PROLOG-NEXT: ret void
274 ; PROLOG-BLOCK-LABEL: @test1(
275 ; PROLOG-BLOCK-NEXT: entry:
276 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
277 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
278 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
279 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
280 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
281 ; PROLOG-BLOCK: loop_header.prol.preheader:
282 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
283 ; PROLOG-BLOCK: loop_header.prol:
284 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting_bb1.prol
285 ; PROLOG-BLOCK: loop_exiting_bb1.prol:
286 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.prol, label %exit1
287 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
288 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_latch.prol, label %exit3
289 ; PROLOG-BLOCK: loop_latch.prol:
290 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
291 ; PROLOG-BLOCK: loop_header.prol.loopexit:
292 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
293 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
294 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit2.loopexit, label %entry.new
295 ; PROLOG-BLOCK: entry.new:
296 ; PROLOG-BLOCK-NEXT: br label %loop_header
297 ; PROLOG-BLOCK: loop_header:
298 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
299 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting_bb1
300 ; PROLOG-BLOCK: loop_exiting_bb1:
301 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2, label %exit1.loopexit
302 ; PROLOG-BLOCK: loop_exiting_bb2:
303 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_latch, label %exit3.loopexit
304 ; PROLOG-BLOCK: exit3.loopexit:
305 ; PROLOG-BLOCK-NEXT: br label %exit3
306 ; PROLOG-BLOCK: exit3:
307 ; PROLOG-BLOCK-NEXT: ret void
308 ; PROLOG-BLOCK: loop_latch:
309 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting_bb1.1
310 ; PROLOG-BLOCK: loop_exiting_bb1.1:
311 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_exiting_bb2.1, label %exit1.loopexit
312 ; PROLOG-BLOCK: loop_exiting_bb2.1:
313 ; PROLOG-BLOCK-NEXT: br i1 false, label %loop_latch.1, label %exit3.loopexit
314 ; PROLOG-BLOCK: loop_latch.1:
315 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
316 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
317 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa, !llvm.loop !0
318 ; PROLOG-BLOCK: exit1.loopexit:
319 ; PROLOG-BLOCK-NEXT: br label %exit1
320 ; PROLOG-BLOCK: exit1:
321 ; PROLOG-BLOCK-NEXT: ret void
322 ; PROLOG-BLOCK: exit2.loopexit.unr-lcssa:
323 ; PROLOG-BLOCK-NEXT: br label %exit2.loopexit
324 ; PROLOG-BLOCK: exit2.loopexit:
325 ; PROLOG-BLOCK-NEXT: ret void
329 br label %loop_header
332 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
333 br i1 %cond, label %loop_latch, label %loop_exiting_bb1
336 br i1 false, label %loop_exiting_bb2, label %exit1
339 br i1 false, label %loop_latch, label %exit3
345 %iv_next = add i64 %iv, 1
346 %cmp = icmp ne i64 %iv_next, %trip
347 br i1 %cmp, label %loop_header, label %exit2.loopexit
357 ; test with three exiting and two exit blocks.
358 ; The non-latch exit block has 2 unique predecessors.
359 ; There are 2 values passed to the exit blocks that are calculated at every iteration.
360 ; %sum.02 and %add. Both of these are incoming values for phi from every exiting
362 define i32 @test2(ptr nocapture %a, i64 %n) {
363 ; EPILOG-LABEL: @test2(
364 ; EPILOG-NEXT: entry:
365 ; EPILOG-NEXT: %0 = freeze i64 %n
366 ; EPILOG-NEXT: %1 = add i64 %0, -1
367 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
368 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
369 ; EPILOG-NEXT: br i1 %2, label %for.end.unr-lcssa, label %entry.new
371 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
372 ; EPILOG-NEXT: br label %header
374 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %for.body.7 ]
375 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %for.body.7 ]
376 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %for.body.7 ]
377 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
378 ; EPILOG: for.exiting_block:
379 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
380 ; EPILOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
382 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
383 ; EPILOG-NEXT: %3 = load i32, ptr %arrayidx, align 4
384 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
385 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
386 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
387 ; EPILOG: for.exiting_block.1:
388 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
389 ; EPILOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
390 ; EPILOG: for.body.1:
391 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
392 ; EPILOG-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
393 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
394 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
395 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
396 ; EPILOG: for.exiting_block.2:
397 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
398 ; EPILOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %for.body.2
399 ; EPILOG: for.body.2:
400 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
401 ; EPILOG-NEXT: %5 = load i32, ptr %arrayidx.2, align 4
402 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
403 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
404 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
405 ; EPILOG: for.exiting_block.3:
406 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
407 ; EPILOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %for.body.3
408 ; EPILOG: for.body.3:
409 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
410 ; EPILOG-NEXT: %6 = load i32, ptr %arrayidx.3, align 4
411 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
412 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
413 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
414 ; EPILOG: for.exiting_block.4:
415 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
416 ; EPILOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %for.body.4
417 ; EPILOG: for.body.4:
418 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
419 ; EPILOG-NEXT: %7 = load i32, ptr %arrayidx.4, align 4
420 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
421 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
422 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
423 ; EPILOG: for.exiting_block.5:
424 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
425 ; EPILOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %for.body.5
426 ; EPILOG: for.body.5:
427 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
428 ; EPILOG-NEXT: %8 = load i32, ptr %arrayidx.5, align 4
429 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
430 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv, 6
431 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
432 ; EPILOG: for.exiting_block.6:
433 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
434 ; EPILOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %for.body.6
435 ; EPILOG: for.body.6:
436 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
437 ; EPILOG-NEXT: %9 = load i32, ptr %arrayidx.6, align 4
438 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
439 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv, 7
440 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
441 ; EPILOG: for.exiting_block.7:
442 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
443 ; EPILOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %for.body.7
444 ; EPILOG: for.body.7:
445 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
446 ; EPILOG-NEXT: %10 = load i32, ptr %arrayidx.7, align 4
447 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
448 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
449 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
450 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
451 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %for.end.unr-lcssa.loopexit, label %header
452 ; EPILOG: for.end.unr-lcssa.loopexit:
453 ; EPILOG-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.7, %for.body.7 ]
454 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %for.body.7 ]
455 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %for.body.7 ]
456 ; EPILOG-NEXT: br label %for.end.unr-lcssa
457 ; EPILOG: for.end.unr-lcssa:
458 ; EPILOG-NEXT: %sum.0.lcssa.ph = phi i32 [ poison, %entry ], [ %sum.0.lcssa.ph.ph, %for.end.unr-lcssa.loopexit ]
459 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %for.end.unr-lcssa.loopexit ]
460 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %for.end.unr-lcssa.loopexit ]
461 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
462 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %for.end
463 ; EPILOG: header.epil.preheader:
464 ; EPILOG-NEXT: br label %header.epil
465 ; EPILOG: header.epil:
466 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %for.body.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
467 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %for.body.epil ], [ %sum.02.unr, %header.epil.preheader ]
468 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %for.body.epil ]
469 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit2, label %for.exiting_block.epil
470 ; EPILOG: for.exiting_block.epil:
471 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
472 ; EPILOG-NEXT: br i1 %cmp.epil, label %for.exit2.loopexit2, label %for.body.epil
473 ; EPILOG: for.body.epil:
474 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.epil
475 ; EPILOG-NEXT: %11 = load i32, ptr %arrayidx.epil, align 4
476 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
477 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
478 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
479 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
480 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
481 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %for.end.epilog-lcssa, !llvm.loop !2
482 ; EPILOG: for.end.epilog-lcssa:
483 ; EPILOG-NEXT: %sum.0.lcssa.ph1 = phi i32 [ %add.epil, %for.body.epil ]
484 ; EPILOG-NEXT: br label %for.end
486 ; EPILOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %for.end.unr-lcssa ], [ %sum.0.lcssa.ph1, %for.end.epilog-lcssa ]
487 ; EPILOG-NEXT: ret i32 %sum.0.lcssa
488 ; EPILOG: for.exit2.loopexit:
489 ; 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 ]
490 ; EPILOG-NEXT: br label %for.exit2
491 ; EPILOG: for.exit2.loopexit2:
492 ; EPILOG-NEXT: %retval.ph3 = phi i32 [ 42, %for.exiting_block.epil ], [ %sum.02.epil, %header.epil ]
493 ; EPILOG-NEXT: br label %for.exit2
495 ; EPILOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph3, %for.exit2.loopexit2 ]
496 ; EPILOG-NEXT: ret i32 %retval
498 ; EPILOG-BLOCK-LABEL: @test2(
499 ; EPILOG-BLOCK-NEXT: entry:
500 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
501 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
502 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
503 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
504 ; EPILOG-BLOCK-NEXT: br i1 %2, label %for.end.unr-lcssa, label %entry.new
505 ; EPILOG-BLOCK: entry.new:
506 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
507 ; EPILOG-BLOCK-NEXT: br label %header
508 ; EPILOG-BLOCK: header:
509 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %for.body.1 ]
510 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %for.body.1 ]
511 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %for.body.1 ]
512 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
513 ; EPILOG-BLOCK: for.exiting_block:
514 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
515 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
516 ; EPILOG-BLOCK: for.body:
517 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
518 ; EPILOG-BLOCK-NEXT: %3 = load i32, ptr %arrayidx, align 4
519 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
520 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
521 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
522 ; EPILOG-BLOCK: for.exiting_block.1:
523 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
524 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
525 ; EPILOG-BLOCK: for.body.1:
526 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
527 ; EPILOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
528 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
529 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
530 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
531 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
532 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %for.end.unr-lcssa.loopexit, label %header, !llvm.loop !2
533 ; EPILOG-BLOCK: for.end.unr-lcssa.loopexit:
534 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.1, %for.body.1 ]
535 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %for.body.1 ]
536 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %for.body.1 ]
537 ; EPILOG-BLOCK-NEXT: br label %for.end.unr-lcssa
538 ; EPILOG-BLOCK: for.end.unr-lcssa:
539 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ poison, %entry ], [ %sum.0.lcssa.ph.ph, %for.end.unr-lcssa.loopexit ]
540 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %for.end.unr-lcssa.loopexit ]
541 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %for.end.unr-lcssa.loopexit ]
542 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
543 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %for.end
544 ; EPILOG-BLOCK: header.epil.preheader:
545 ; EPILOG-BLOCK-NEXT: br label %header.epil
546 ; EPILOG-BLOCK: header.epil:
547 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.epil
548 ; EPILOG-BLOCK: for.exiting_block.epil:
549 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
550 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %for.exit2, label %for.body.epil
551 ; EPILOG-BLOCK: for.body.epil:
552 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.unr
553 ; EPILOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.epil, align 4
554 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
555 ; EPILOG-BLOCK-NEXT: br label %for.end
556 ; EPILOG-BLOCK: for.end:
557 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %for.end.unr-lcssa ], [ %add.epil, %for.body.epil ]
558 ; EPILOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
559 ; EPILOG-BLOCK: for.exit2.loopexit:
560 ; EPILOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %for.body ], [ 42, %for.exiting_block.1 ]
561 ; EPILOG-BLOCK-NEXT: br label %for.exit2
562 ; EPILOG-BLOCK: for.exit2:
563 ; EPILOG-BLOCK-NEXT: %retval = phi i32 [ %sum.02.unr, %header.epil ], [ 42, %for.exiting_block.epil ], [ %retval.ph, %for.exit2.loopexit ]
564 ; EPILOG-BLOCK-NEXT: ret i32 %retval
566 ; PROLOG-LABEL: @test2(
567 ; PROLOG-NEXT: entry:
568 ; PROLOG-NEXT: %0 = freeze i64 %n
569 ; PROLOG-NEXT: %1 = add i64 %0, -1
570 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
571 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
572 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
573 ; PROLOG: header.prol.preheader:
574 ; PROLOG-NEXT: br label %header.prol
575 ; PROLOG: header.prol:
576 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %for.body.prol ], [ 0, %header.prol.preheader ]
577 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %for.body.prol ], [ 0, %header.prol.preheader ]
578 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %for.body.prol ]
579 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit1, label %for.exiting_block.prol
580 ; PROLOG: for.exiting_block.prol:
581 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
582 ; PROLOG-NEXT: br i1 %cmp.prol, label %for.exit2.loopexit1, label %for.body.prol
583 ; PROLOG: for.body.prol:
584 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.prol
585 ; PROLOG-NEXT: %2 = load i32, ptr %arrayidx.prol, align 4
586 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
587 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
588 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
589 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
590 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
591 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !2
592 ; PROLOG: header.prol.loopexit.unr-lcssa:
593 ; PROLOG-NEXT: %sum.0.lcssa.unr.ph = phi i32 [ %add.prol, %for.body.prol ]
594 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %for.body.prol ]
595 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %for.body.prol ]
596 ; PROLOG-NEXT: br label %header.prol.loopexit
597 ; PROLOG: header.prol.loopexit:
598 ; PROLOG-NEXT: %sum.0.lcssa.unr = phi i32 [ poison, %entry ], [ %sum.0.lcssa.unr.ph, %header.prol.loopexit.unr-lcssa ]
599 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
600 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
601 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
602 ; PROLOG-NEXT: br i1 %3, label %for.end, label %entry.new
604 ; PROLOG-NEXT: br label %header
606 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %for.body.7 ]
607 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %for.body.7 ]
608 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
609 ; PROLOG: for.exiting_block:
610 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
611 ; PROLOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
613 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
614 ; PROLOG-NEXT: %4 = load i32, ptr %arrayidx, align 4
615 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
616 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
617 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
618 ; PROLOG: for.exiting_block.1:
619 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
620 ; PROLOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
621 ; PROLOG: for.body.1:
622 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
623 ; PROLOG-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
624 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
625 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
626 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
627 ; PROLOG: for.exiting_block.2:
628 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
629 ; PROLOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %for.body.2
630 ; PROLOG: for.body.2:
631 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
632 ; PROLOG-NEXT: %6 = load i32, ptr %arrayidx.2, align 4
633 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
634 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv, 3
635 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
636 ; PROLOG: for.exiting_block.3:
637 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
638 ; PROLOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %for.body.3
639 ; PROLOG: for.body.3:
640 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
641 ; PROLOG-NEXT: %7 = load i32, ptr %arrayidx.3, align 4
642 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
643 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv, 4
644 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
645 ; PROLOG: for.exiting_block.4:
646 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
647 ; PROLOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %for.body.4
648 ; PROLOG: for.body.4:
649 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
650 ; PROLOG-NEXT: %8 = load i32, ptr %arrayidx.4, align 4
651 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
652 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv, 5
653 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
654 ; PROLOG: for.exiting_block.5:
655 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
656 ; PROLOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %for.body.5
657 ; PROLOG: for.body.5:
658 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
659 ; PROLOG-NEXT: %9 = load i32, ptr %arrayidx.5, align 4
660 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
661 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv, 6
662 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
663 ; PROLOG: for.exiting_block.6:
664 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
665 ; PROLOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %for.body.6
666 ; PROLOG: for.body.6:
667 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
668 ; PROLOG-NEXT: %10 = load i32, ptr %arrayidx.6, align 4
669 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
670 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv, 7
671 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
672 ; PROLOG: for.exiting_block.7:
673 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
674 ; PROLOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %for.body.7
675 ; PROLOG: for.body.7:
676 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
677 ; PROLOG-NEXT: %11 = load i32, ptr %arrayidx.7, align 4
678 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
679 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
680 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
681 ; PROLOG-NEXT: br i1 %exitcond.7, label %for.end.unr-lcssa, label %header
682 ; PROLOG: for.end.unr-lcssa:
683 ; PROLOG-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.7, %for.body.7 ]
684 ; PROLOG-NEXT: br label %for.end
686 ; PROLOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %for.end.unr-lcssa ]
687 ; PROLOG-NEXT: ret i32 %sum.0.lcssa
688 ; PROLOG: for.exit2.loopexit:
689 ; 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 ]
690 ; PROLOG-NEXT: br label %for.exit2
691 ; PROLOG: for.exit2.loopexit1:
692 ; PROLOG-NEXT: %retval.ph2 = phi i32 [ 42, %for.exiting_block.prol ], [ %sum.02.prol, %header.prol ]
693 ; PROLOG-NEXT: br label %for.exit2
695 ; PROLOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph2, %for.exit2.loopexit1 ]
696 ; PROLOG-NEXT: ret i32 %retval
698 ; PROLOG-BLOCK-LABEL: @test2(
699 ; PROLOG-BLOCK-NEXT: entry:
700 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
701 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
702 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
703 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
704 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
705 ; PROLOG-BLOCK: header.prol.preheader:
706 ; PROLOG-BLOCK-NEXT: br label %header.prol
707 ; PROLOG-BLOCK: header.prol:
708 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.prol
709 ; PROLOG-BLOCK: for.exiting_block.prol:
710 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
711 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %for.exit2, label %for.body.prol
712 ; PROLOG-BLOCK: for.body.prol:
713 ; PROLOG-BLOCK-NEXT: %2 = load i32, ptr %a, align 4
714 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
715 ; PROLOG-BLOCK: header.prol.loopexit:
716 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.unr = phi i32 [ poison, %entry ], [ %2, %for.body.prol ]
717 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %for.body.prol ]
718 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %for.body.prol ]
719 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
720 ; PROLOG-BLOCK-NEXT: br i1 %3, label %for.end, label %entry.new
721 ; PROLOG-BLOCK: entry.new:
722 ; PROLOG-BLOCK-NEXT: br label %header
723 ; PROLOG-BLOCK: header:
724 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %for.body.1 ]
725 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %for.body.1 ]
726 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
727 ; PROLOG-BLOCK: for.exiting_block:
728 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
729 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %for.body
730 ; PROLOG-BLOCK: for.body:
731 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
732 ; PROLOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx, align 4
733 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
734 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
735 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
736 ; PROLOG-BLOCK: for.exiting_block.1:
737 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
738 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %for.body.1
739 ; PROLOG-BLOCK: for.body.1:
740 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
741 ; PROLOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
742 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
743 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
744 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
745 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %for.end.unr-lcssa, label %header, !llvm.loop !2
746 ; PROLOG-BLOCK: for.end.unr-lcssa:
747 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.1, %for.body.1 ]
748 ; PROLOG-BLOCK-NEXT: br label %for.end
749 ; PROLOG-BLOCK: for.end:
750 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %for.end.unr-lcssa ]
751 ; PROLOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
752 ; PROLOG-BLOCK: for.exit2.loopexit:
753 ; PROLOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %for.body ], [ 42, %for.exiting_block.1 ]
754 ; PROLOG-BLOCK-NEXT: br label %for.exit2
755 ; PROLOG-BLOCK: for.exit2:
756 ; PROLOG-BLOCK-NEXT: %retval = phi i32 [ 0, %header.prol ], [ 42, %for.exiting_block.prol ], [ %retval.ph, %for.exit2.loopexit ]
757 ; PROLOG-BLOCK-NEXT: ret i32 %retval
765 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
766 %sum.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
767 br i1 false, label %for.exit2, label %for.exiting_block
770 %cmp = icmp eq i64 %n, 42
771 br i1 %cmp, label %for.exit2, label %for.body
774 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
775 %0 = load i32, ptr %arrayidx, align 4
776 %add = add nsw i32 %0, %sum.02
777 %indvars.iv.next = add i64 %indvars.iv, 1
778 %exitcond = icmp eq i64 %indvars.iv.next, %n
779 br i1 %exitcond, label %for.end, label %header
781 for.end: ; preds = %for.body
782 %sum.0.lcssa = phi i32 [ %add, %for.body ]
786 %retval = phi i32 [ %sum.02, %header ], [ 42, %for.exiting_block ]
790 ; test with two exiting and three exit blocks.
791 ; the non-latch exiting block has a switch.
792 define void @test3(i64 %trip, i64 %add, i1 %arg) {
793 ; EPILOG-LABEL: @test3(
794 ; EPILOG-NEXT: entry:
795 ; EPILOG-NEXT: %0 = freeze i64 %trip
796 ; EPILOG-NEXT: %1 = add i64 %0, -1
797 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
798 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
799 ; EPILOG-NEXT: br i1 %2, label %exit2.loopexit.unr-lcssa, label %entry.new
801 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
802 ; EPILOG-NEXT: br label %loop_header
803 ; EPILOG: loop_header:
804 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
805 ; EPILOG-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
806 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
807 ; EPILOG-NEXT: br i1 %arg, label %loop_latch, label %loop_exiting_bb1
808 ; EPILOG: loop_exiting_bb1:
809 ; EPILOG-NEXT: switch i64 %sum, label %loop_latch [
810 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
811 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
813 ; EPILOG: exit3.loopexit:
814 ; EPILOG-NEXT: br label %exit3
815 ; EPILOG: exit3.loopexit2:
816 ; EPILOG-NEXT: br label %exit3
818 ; EPILOG-NEXT: ret void
819 ; EPILOG: loop_latch:
820 ; EPILOG-NEXT: %sum.next = add i64 %sum, %add
821 ; EPILOG-NEXT: br i1 %arg, label %loop_latch.1, label %loop_exiting_bb1.1
822 ; EPILOG: loop_exiting_bb1.1:
823 ; EPILOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
824 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
825 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
827 ; EPILOG: loop_latch.1:
828 ; EPILOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
829 ; EPILOG-NEXT: br i1 %arg, label %loop_latch.2, label %loop_exiting_bb1.2
830 ; EPILOG: loop_exiting_bb1.2:
831 ; EPILOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
832 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
833 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
835 ; EPILOG: loop_latch.2:
836 ; EPILOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
837 ; EPILOG-NEXT: br i1 %arg, label %loop_latch.3, label %loop_exiting_bb1.3
838 ; EPILOG: loop_exiting_bb1.3:
839 ; EPILOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
840 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
841 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
843 ; EPILOG: loop_latch.3:
844 ; EPILOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
845 ; EPILOG-NEXT: br i1 %arg, label %loop_latch.4, label %loop_exiting_bb1.4
846 ; EPILOG: loop_exiting_bb1.4:
847 ; EPILOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
848 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
849 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
851 ; EPILOG: loop_latch.4:
852 ; EPILOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
853 ; EPILOG-NEXT: br i1 %arg, label %loop_latch.5, label %loop_exiting_bb1.5
854 ; EPILOG: loop_exiting_bb1.5:
855 ; EPILOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
856 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
857 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
859 ; EPILOG: loop_latch.5:
860 ; EPILOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
861 ; EPILOG-NEXT: br i1 %arg, label %loop_latch.6, label %loop_exiting_bb1.6
862 ; EPILOG: loop_exiting_bb1.6:
863 ; EPILOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
864 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
865 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
867 ; EPILOG: loop_latch.6:
868 ; EPILOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
869 ; EPILOG-NEXT: br i1 %arg, label %loop_latch.7, label %loop_exiting_bb1.7
870 ; EPILOG: loop_exiting_bb1.7:
871 ; EPILOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
872 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
873 ; EPILOG-NEXT: i64 42, label %exit3.loopexit
875 ; EPILOG: loop_latch.7:
876 ; EPILOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv, 8
877 ; EPILOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
878 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
879 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
880 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit
881 ; EPILOG: exit1.loopexit:
882 ; EPILOG-NEXT: br label %exit1
883 ; EPILOG: exit1.loopexit1:
884 ; EPILOG-NEXT: br label %exit1
886 ; EPILOG-NEXT: ret void
887 ; EPILOG: exit2.loopexit.unr-lcssa.loopexit:
888 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
889 ; EPILOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
890 ; EPILOG-NEXT: br label %exit2.loopexit.unr-lcssa
891 ; EPILOG: exit2.loopexit.unr-lcssa:
892 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
893 ; EPILOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
894 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
895 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
896 ; EPILOG: loop_header.epil.preheader:
897 ; EPILOG-NEXT: br label %loop_header.epil
898 ; EPILOG: loop_header.epil:
899 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
900 ; EPILOG-NEXT: %sum.epil = phi i64 [ %sum.unr, %loop_header.epil.preheader ], [ %sum.next.epil, %loop_latch.epil ]
901 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
902 ; EPILOG-NEXT: br i1 %arg, label %loop_latch.epil, label %loop_exiting_bb1.epil
903 ; EPILOG: loop_exiting_bb1.epil:
904 ; EPILOG-NEXT: switch i64 %sum.epil, label %loop_latch.epil [
905 ; EPILOG-NEXT: i64 24, label %exit1.loopexit1
906 ; EPILOG-NEXT: i64 42, label %exit3.loopexit2
908 ; EPILOG: loop_latch.epil:
909 ; EPILOG-NEXT: %iv_next.epil = add nuw nsw i64 %iv.epil, 1
910 ; EPILOG-NEXT: %sum.next.epil = add i64 %sum.epil, %add
911 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
912 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
913 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
914 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.loopexit.epilog-lcssa, !llvm.loop !3
915 ; EPILOG: exit2.loopexit.epilog-lcssa:
916 ; EPILOG-NEXT: br label %exit2.loopexit
917 ; EPILOG: exit2.loopexit:
918 ; EPILOG-NEXT: ret void
920 ; EPILOG-BLOCK-LABEL: @test3(
921 ; EPILOG-BLOCK-NEXT: entry:
922 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
923 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
924 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
925 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
926 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit2.loopexit.unr-lcssa, label %entry.new
927 ; EPILOG-BLOCK: entry.new:
928 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
929 ; EPILOG-BLOCK-NEXT: br label %loop_header
930 ; EPILOG-BLOCK: loop_header:
931 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
932 ; EPILOG-BLOCK-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
933 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
934 ; EPILOG-BLOCK-NEXT: br i1 %arg, label %loop_latch, label %loop_exiting_bb1
935 ; EPILOG-BLOCK: loop_exiting_bb1:
936 ; EPILOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
937 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
938 ; EPILOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
939 ; EPILOG-BLOCK-NEXT: ]
940 ; EPILOG-BLOCK: exit3.loopexit:
941 ; EPILOG-BLOCK-NEXT: br label %exit3
942 ; EPILOG-BLOCK: exit3:
943 ; EPILOG-BLOCK-NEXT: ret void
944 ; EPILOG-BLOCK: loop_latch:
945 ; EPILOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
946 ; EPILOG-BLOCK-NEXT: br i1 %arg, label %loop_latch.1, label %loop_exiting_bb1.1
947 ; EPILOG-BLOCK: loop_exiting_bb1.1:
948 ; EPILOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
949 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
950 ; EPILOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
951 ; EPILOG-BLOCK-NEXT: ]
952 ; EPILOG-BLOCK: loop_latch.1:
953 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv, 2
954 ; EPILOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
955 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
956 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
957 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa.loopexit, !llvm.loop !3
958 ; EPILOG-BLOCK: exit1.loopexit:
959 ; EPILOG-BLOCK-NEXT: br label %exit1
960 ; EPILOG-BLOCK: exit1:
961 ; EPILOG-BLOCK-NEXT: ret void
962 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa.loopexit:
963 ; EPILOG-BLOCK-NEXT: %sum.unr.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
964 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit.unr-lcssa
965 ; EPILOG-BLOCK: exit2.loopexit.unr-lcssa:
966 ; EPILOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %exit2.loopexit.unr-lcssa.loopexit ]
967 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
968 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2.loopexit
969 ; EPILOG-BLOCK: loop_header.epil.preheader:
970 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
971 ; EPILOG-BLOCK: loop_header.epil:
972 ; EPILOG-BLOCK-NEXT: br i1 %arg, label %loop_latch.epil, label %loop_exiting_bb1.epil
973 ; EPILOG-BLOCK: loop_exiting_bb1.epil:
974 ; EPILOG-BLOCK-NEXT: switch i64 %sum.unr, label %loop_latch.epil [
975 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1
976 ; EPILOG-BLOCK-NEXT: i64 42, label %exit3
977 ; EPILOG-BLOCK-NEXT: ]
978 ; EPILOG-BLOCK: loop_latch.epil:
979 ; EPILOG-BLOCK-NEXT: br label %exit2.loopexit
980 ; EPILOG-BLOCK: exit2.loopexit:
981 ; EPILOG-BLOCK-NEXT: ret void
983 ; PROLOG-LABEL: @test3(
984 ; PROLOG-NEXT: entry:
985 ; PROLOG-NEXT: %0 = freeze i64 %trip
986 ; PROLOG-NEXT: %1 = add i64 %0, -1
987 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
988 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
989 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
990 ; PROLOG: loop_header.prol.preheader:
991 ; PROLOG-NEXT: br label %loop_header.prol
992 ; PROLOG: loop_header.prol:
993 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
994 ; PROLOG-NEXT: %sum.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %sum.next.prol, %loop_latch.prol ]
995 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
996 ; PROLOG-NEXT: br i1 %arg, label %loop_latch.prol, label %loop_exiting_bb1.prol
997 ; PROLOG: loop_exiting_bb1.prol:
998 ; PROLOG-NEXT: switch i64 %sum.prol, label %loop_latch.prol [
999 ; PROLOG-NEXT: i64 24, label %exit1.loopexit1
1000 ; PROLOG-NEXT: i64 42, label %exit3.loopexit2
1002 ; PROLOG: loop_latch.prol:
1003 ; PROLOG-NEXT: %iv_next.prol = add nuw nsw i64 %iv.prol, 1
1004 ; PROLOG-NEXT: %sum.next.prol = add i64 %sum.prol, %add
1005 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
1006 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
1007 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
1008 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !3
1009 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
1010 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
1011 ; PROLOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.prol, %loop_latch.prol ]
1012 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
1013 ; PROLOG: loop_header.prol.loopexit:
1014 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
1015 ; PROLOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
1016 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
1017 ; PROLOG-NEXT: br i1 %2, label %exit2.loopexit, label %entry.new
1018 ; PROLOG: entry.new:
1019 ; PROLOG-NEXT: br label %loop_header
1020 ; PROLOG: loop_header:
1021 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
1022 ; PROLOG-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
1023 ; PROLOG-NEXT: br i1 %arg, label %loop_latch, label %loop_exiting_bb1
1024 ; PROLOG: loop_exiting_bb1:
1025 ; PROLOG-NEXT: switch i64 %sum, label %loop_latch [
1026 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1027 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1029 ; PROLOG: exit3.loopexit:
1030 ; PROLOG-NEXT: br label %exit3
1031 ; PROLOG: exit3.loopexit2:
1032 ; PROLOG-NEXT: br label %exit3
1034 ; PROLOG-NEXT: ret void
1035 ; PROLOG: loop_latch:
1036 ; PROLOG-NEXT: %sum.next = add i64 %sum, %add
1037 ; PROLOG-NEXT: br i1 %arg, label %loop_latch.1, label %loop_exiting_bb1.1
1038 ; PROLOG: loop_exiting_bb1.1:
1039 ; PROLOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
1040 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1041 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1043 ; PROLOG: loop_latch.1:
1044 ; PROLOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
1045 ; PROLOG-NEXT: br i1 %arg, label %loop_latch.2, label %loop_exiting_bb1.2
1046 ; PROLOG: loop_exiting_bb1.2:
1047 ; PROLOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
1048 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1049 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1051 ; PROLOG: loop_latch.2:
1052 ; PROLOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
1053 ; PROLOG-NEXT: br i1 %arg, label %loop_latch.3, label %loop_exiting_bb1.3
1054 ; PROLOG: loop_exiting_bb1.3:
1055 ; PROLOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
1056 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1057 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1059 ; PROLOG: loop_latch.3:
1060 ; PROLOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
1061 ; PROLOG-NEXT: br i1 %arg, label %loop_latch.4, label %loop_exiting_bb1.4
1062 ; PROLOG: loop_exiting_bb1.4:
1063 ; PROLOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
1064 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1065 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1067 ; PROLOG: loop_latch.4:
1068 ; PROLOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
1069 ; PROLOG-NEXT: br i1 %arg, label %loop_latch.5, label %loop_exiting_bb1.5
1070 ; PROLOG: loop_exiting_bb1.5:
1071 ; PROLOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
1072 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1073 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1075 ; PROLOG: loop_latch.5:
1076 ; PROLOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
1077 ; PROLOG-NEXT: br i1 %arg, label %loop_latch.6, label %loop_exiting_bb1.6
1078 ; PROLOG: loop_exiting_bb1.6:
1079 ; PROLOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
1080 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1081 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1083 ; PROLOG: loop_latch.6:
1084 ; PROLOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
1085 ; PROLOG-NEXT: br i1 %arg, label %loop_latch.7, label %loop_exiting_bb1.7
1086 ; PROLOG: loop_exiting_bb1.7:
1087 ; PROLOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
1088 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
1089 ; PROLOG-NEXT: i64 42, label %exit3.loopexit
1091 ; PROLOG: loop_latch.7:
1092 ; PROLOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv, 8
1093 ; PROLOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
1094 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
1095 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.loopexit.unr-lcssa
1096 ; PROLOG: exit1.loopexit:
1097 ; PROLOG-NEXT: br label %exit1
1098 ; PROLOG: exit1.loopexit1:
1099 ; PROLOG-NEXT: br label %exit1
1101 ; PROLOG-NEXT: ret void
1102 ; PROLOG: exit2.loopexit.unr-lcssa:
1103 ; PROLOG-NEXT: br label %exit2.loopexit
1104 ; PROLOG: exit2.loopexit:
1105 ; PROLOG-NEXT: ret void
1107 ; PROLOG-BLOCK-LABEL: @test3(
1108 ; PROLOG-BLOCK-NEXT: entry:
1109 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
1110 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
1111 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
1112 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1113 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
1114 ; PROLOG-BLOCK: loop_header.prol.preheader:
1115 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
1116 ; PROLOG-BLOCK: loop_header.prol:
1117 ; PROLOG-BLOCK-NEXT: br i1 %arg, label %loop_latch.prol, label %loop_exiting_bb1.prol
1118 ; PROLOG-BLOCK: loop_exiting_bb1.prol:
1119 ; PROLOG-BLOCK-NEXT: switch i64 0, label %loop_latch.prol [
1120 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1
1121 ; PROLOG-BLOCK-NEXT: i64 42, label %exit3
1122 ; PROLOG-BLOCK-NEXT: ]
1123 ; PROLOG-BLOCK: loop_latch.prol:
1124 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
1125 ; PROLOG-BLOCK: loop_header.prol.loopexit:
1126 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
1127 ; PROLOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %add, %loop_latch.prol ]
1128 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
1129 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit2.loopexit, label %entry.new
1130 ; PROLOG-BLOCK: entry.new:
1131 ; PROLOG-BLOCK-NEXT: br label %loop_header
1132 ; PROLOG-BLOCK: loop_header:
1133 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
1134 ; PROLOG-BLOCK-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
1135 ; PROLOG-BLOCK-NEXT: br i1 %arg, label %loop_latch, label %loop_exiting_bb1
1136 ; PROLOG-BLOCK: loop_exiting_bb1:
1137 ; PROLOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
1138 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
1139 ; PROLOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
1140 ; PROLOG-BLOCK-NEXT: ]
1141 ; PROLOG-BLOCK: exit3.loopexit:
1142 ; PROLOG-BLOCK-NEXT: br label %exit3
1143 ; PROLOG-BLOCK: exit3:
1144 ; PROLOG-BLOCK-NEXT: ret void
1145 ; PROLOG-BLOCK: loop_latch:
1146 ; PROLOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
1147 ; PROLOG-BLOCK-NEXT: br i1 %arg, label %loop_latch.1, label %loop_exiting_bb1.1
1148 ; PROLOG-BLOCK: loop_exiting_bb1.1:
1149 ; PROLOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
1150 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
1151 ; PROLOG-BLOCK-NEXT: i64 42, label %exit3.loopexit
1152 ; PROLOG-BLOCK-NEXT: ]
1153 ; PROLOG-BLOCK: loop_latch.1:
1154 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv, 2
1155 ; PROLOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
1156 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
1157 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.loopexit.unr-lcssa, !llvm.loop !3
1158 ; PROLOG-BLOCK: exit1.loopexit:
1159 ; PROLOG-BLOCK-NEXT: br label %exit1
1160 ; PROLOG-BLOCK: exit1:
1161 ; PROLOG-BLOCK-NEXT: ret void
1162 ; PROLOG-BLOCK: exit2.loopexit.unr-lcssa:
1163 ; PROLOG-BLOCK-NEXT: br label %exit2.loopexit
1164 ; PROLOG-BLOCK: exit2.loopexit:
1165 ; PROLOG-BLOCK-NEXT: ret void
1169 br label %loop_header
1172 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
1173 %sum = phi i64 [ 0, %entry ], [ %sum.next, %loop_latch ]
1174 br i1 %arg, label %loop_latch, label %loop_exiting_bb1
1177 switch i64 %sum, label %loop_latch [
1178 i64 24, label %exit1
1179 i64 42, label %exit3
1186 %iv_next = add nuw nsw i64 %iv, 1
1187 %sum.next = add i64 %sum, %add
1188 %cmp = icmp ne i64 %iv_next, %trip
1189 br i1 %cmp, label %loop_header, label %exit2.loopexit
1198 ; FIXME: Support multiple exiting blocks to the same latch exit block.
1199 ; Three exiting blocks where header and latch exit to same LatchExit.
1200 define i32 @hdr_latch_same_exit(ptr nocapture %a, i64 %n, i1 %cond) {
1201 ; EPILOG-LABEL: @hdr_latch_same_exit(
1202 ; EPILOG-NEXT: entry:
1203 ; EPILOG-NEXT: %0 = freeze i64 %n
1204 ; EPILOG-NEXT: %1 = add i64 %0, -1
1205 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
1206 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
1207 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
1208 ; EPILOG: entry.new:
1209 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
1210 ; EPILOG-NEXT: br label %header
1212 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1213 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
1214 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
1215 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block
1216 ; EPILOG: for.exiting_block:
1217 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
1218 ; EPILOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1220 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
1221 ; EPILOG-NEXT: %3 = load i32, ptr %arrayidx, align 4
1222 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
1223 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1224 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.1
1225 ; EPILOG: for.exiting_block.1:
1226 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1227 ; EPILOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1229 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
1230 ; EPILOG-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
1231 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
1232 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
1233 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.2
1234 ; EPILOG: for.exiting_block.2:
1235 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1236 ; EPILOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
1238 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
1239 ; EPILOG-NEXT: %5 = load i32, ptr %arrayidx.2, align 4
1240 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
1241 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
1242 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.3
1243 ; EPILOG: for.exiting_block.3:
1244 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1245 ; EPILOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
1247 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
1248 ; EPILOG-NEXT: %6 = load i32, ptr %arrayidx.3, align 4
1249 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
1250 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
1251 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.4
1252 ; EPILOG: for.exiting_block.4:
1253 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1254 ; EPILOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
1256 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
1257 ; EPILOG-NEXT: %7 = load i32, ptr %arrayidx.4, align 4
1258 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
1259 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
1260 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.5
1261 ; EPILOG: for.exiting_block.5:
1262 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1263 ; EPILOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
1265 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
1266 ; EPILOG-NEXT: %8 = load i32, ptr %arrayidx.5, align 4
1267 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
1268 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv, 6
1269 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.6
1270 ; EPILOG: for.exiting_block.6:
1271 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1272 ; EPILOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
1274 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
1275 ; EPILOG-NEXT: %9 = load i32, ptr %arrayidx.6, align 4
1276 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
1277 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv, 7
1278 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.7
1279 ; EPILOG: for.exiting_block.7:
1280 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1281 ; EPILOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
1283 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
1284 ; EPILOG-NEXT: %10 = load i32, ptr %arrayidx.7, align 4
1285 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
1286 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
1287 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
1288 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
1289 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
1290 ; EPILOG: latchExit.unr-lcssa.loopexit:
1291 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
1292 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
1293 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
1294 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
1295 ; EPILOG: latchExit.unr-lcssa:
1296 ; EPILOG-NEXT: %result.ph = phi i32 [ poison, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1297 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1298 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1299 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1300 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1301 ; EPILOG: header.epil.preheader:
1302 ; EPILOG-NEXT: br label %header.epil
1303 ; EPILOG: header.epil:
1304 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
1305 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
1306 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
1307 ; EPILOG-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit2, label %for.exiting_block.epil
1308 ; EPILOG: for.exiting_block.epil:
1309 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
1310 ; EPILOG-NEXT: br i1 %cmp.epil, label %for.exit2.loopexit4, label %latch.epil
1311 ; EPILOG: latch.epil:
1312 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.epil
1313 ; EPILOG-NEXT: %11 = load i32, ptr %arrayidx.epil, align 4
1314 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
1315 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
1316 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
1317 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
1318 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
1319 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit2, !llvm.loop !4
1320 ; EPILOG: latchExit.epilog-lcssa.loopexit:
1321 ; 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 ]
1322 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1323 ; EPILOG: latchExit.epilog-lcssa.loopexit2:
1324 ; EPILOG-NEXT: %result.ph1.ph3 = phi i32 [ 0, %header.epil ], [ %add.epil, %latch.epil ]
1325 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1326 ; EPILOG: latchExit.epilog-lcssa:
1327 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph3, %latchExit.epilog-lcssa.loopexit2 ]
1328 ; EPILOG-NEXT: br label %latchExit
1329 ; EPILOG: latchExit:
1330 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1331 ; EPILOG-NEXT: ret i32 %result
1332 ; EPILOG: for.exit2.loopexit:
1333 ; EPILOG-NEXT: br label %for.exit2
1334 ; EPILOG: for.exit2.loopexit4:
1335 ; EPILOG-NEXT: br label %for.exit2
1336 ; EPILOG: for.exit2:
1337 ; EPILOG-NEXT: ret i32 42
1339 ; EPILOG-BLOCK-LABEL: @hdr_latch_same_exit(
1340 ; EPILOG-BLOCK-NEXT: entry:
1341 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
1342 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
1343 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
1344 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
1345 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
1346 ; EPILOG-BLOCK: entry.new:
1347 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
1348 ; EPILOG-BLOCK-NEXT: br label %header
1349 ; EPILOG-BLOCK: header:
1350 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
1351 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
1352 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
1353 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block
1354 ; EPILOG-BLOCK: for.exiting_block:
1355 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
1356 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1357 ; EPILOG-BLOCK: latch:
1358 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
1359 ; EPILOG-BLOCK-NEXT: %3 = load i32, ptr %arrayidx, align 4
1360 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
1361 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1362 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %latchExit.epilog-lcssa.loopexit, label %for.exiting_block.1
1363 ; EPILOG-BLOCK: for.exiting_block.1:
1364 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
1365 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1366 ; EPILOG-BLOCK: latch.1:
1367 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
1368 ; EPILOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
1369 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
1370 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
1371 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
1372 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
1373 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !4
1374 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
1375 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
1376 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
1377 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
1378 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
1379 ; EPILOG-BLOCK: latchExit.unr-lcssa:
1380 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ poison, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1381 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1382 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1383 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1384 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1385 ; EPILOG-BLOCK: header.epil.preheader:
1386 ; EPILOG-BLOCK-NEXT: br label %header.epil
1387 ; EPILOG-BLOCK: header.epil:
1388 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %latchExit.epilog-lcssa, label %for.exiting_block.epil
1389 ; EPILOG-BLOCK: for.exiting_block.epil:
1390 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
1391 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %for.exit2, label %latch.epil
1392 ; EPILOG-BLOCK: latch.epil:
1393 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.unr
1394 ; EPILOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.epil, align 4
1395 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
1396 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1397 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
1398 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ 0, %header ], [ 0, %latch ]
1399 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1400 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
1401 ; EPILOG-BLOCK-NEXT: %result.ph1 = phi i32 [ %add.epil, %latch.epil ], [ 0, %header.epil ], [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
1402 ; EPILOG-BLOCK-NEXT: br label %latchExit
1403 ; EPILOG-BLOCK: latchExit:
1404 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1405 ; EPILOG-BLOCK-NEXT: ret i32 %result
1406 ; EPILOG-BLOCK: for.exit2.loopexit:
1407 ; EPILOG-BLOCK-NEXT: br label %for.exit2
1408 ; EPILOG-BLOCK: for.exit2:
1409 ; EPILOG-BLOCK-NEXT: ret i32 42
1411 ; PROLOG-LABEL: @hdr_latch_same_exit(
1412 ; PROLOG-NEXT: entry:
1413 ; PROLOG-NEXT: %0 = freeze i64 %n
1414 ; PROLOG-NEXT: %1 = add i64 %0, -1
1415 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
1416 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1417 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1418 ; PROLOG: header.prol.preheader:
1419 ; PROLOG-NEXT: br label %header.prol
1420 ; PROLOG: header.prol:
1421 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1422 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1423 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
1424 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit1, label %for.exiting_block.prol
1425 ; PROLOG: for.exiting_block.prol:
1426 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
1427 ; PROLOG-NEXT: br i1 %cmp.prol, label %for.exit2.loopexit3, label %latch.prol
1428 ; PROLOG: latch.prol:
1429 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.prol
1430 ; PROLOG-NEXT: %2 = load i32, ptr %arrayidx.prol, align 4
1431 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
1432 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
1433 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
1434 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
1435 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
1436 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !4
1437 ; PROLOG: header.prol.loopexit.unr-lcssa:
1438 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1439 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
1440 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1441 ; PROLOG-NEXT: br label %header.prol.loopexit
1442 ; PROLOG: header.prol.loopexit:
1443 ; PROLOG-NEXT: %result.unr = phi i32 [ poison, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
1444 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
1445 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
1446 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
1447 ; PROLOG-NEXT: br i1 %3, label %latchExit, label %entry.new
1448 ; PROLOG: entry.new:
1449 ; PROLOG-NEXT: br label %header
1451 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1452 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
1453 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block
1454 ; PROLOG: for.exiting_block:
1455 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
1456 ; PROLOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1458 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
1459 ; PROLOG-NEXT: %4 = load i32, ptr %arrayidx, align 4
1460 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
1461 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
1462 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.1
1463 ; PROLOG: for.exiting_block.1:
1464 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1465 ; PROLOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1467 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
1468 ; PROLOG-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
1469 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
1470 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
1471 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.2
1472 ; PROLOG: for.exiting_block.2:
1473 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1474 ; PROLOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
1476 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
1477 ; PROLOG-NEXT: %6 = load i32, ptr %arrayidx.2, align 4
1478 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
1479 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv, 3
1480 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.3
1481 ; PROLOG: for.exiting_block.3:
1482 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1483 ; PROLOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
1485 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
1486 ; PROLOG-NEXT: %7 = load i32, ptr %arrayidx.3, align 4
1487 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
1488 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv, 4
1489 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.4
1490 ; PROLOG: for.exiting_block.4:
1491 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1492 ; PROLOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
1494 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
1495 ; PROLOG-NEXT: %8 = load i32, ptr %arrayidx.4, align 4
1496 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
1497 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv, 5
1498 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.5
1499 ; PROLOG: for.exiting_block.5:
1500 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1501 ; PROLOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
1503 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
1504 ; PROLOG-NEXT: %9 = load i32, ptr %arrayidx.5, align 4
1505 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
1506 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv, 6
1507 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.6
1508 ; PROLOG: for.exiting_block.6:
1509 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1510 ; PROLOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
1512 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
1513 ; PROLOG-NEXT: %10 = load i32, ptr %arrayidx.6, align 4
1514 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
1515 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv, 7
1516 ; PROLOG-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.7
1517 ; PROLOG: for.exiting_block.7:
1518 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1519 ; PROLOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
1521 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
1522 ; PROLOG-NEXT: %11 = load i32, ptr %arrayidx.7, align 4
1523 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
1524 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
1525 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
1526 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
1527 ; PROLOG: latchExit.unr-lcssa.loopexit:
1528 ; 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 ]
1529 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
1530 ; PROLOG: latchExit.unr-lcssa.loopexit1:
1531 ; PROLOG-NEXT: %result.ph.ph2 = phi i32 [ 0, %header.prol ]
1532 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
1533 ; PROLOG: latchExit.unr-lcssa:
1534 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph2, %latchExit.unr-lcssa.loopexit1 ]
1535 ; PROLOG-NEXT: br label %latchExit
1536 ; PROLOG: latchExit:
1537 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
1538 ; PROLOG-NEXT: ret i32 %result
1539 ; PROLOG: for.exit2.loopexit:
1540 ; PROLOG-NEXT: br label %for.exit2
1541 ; PROLOG: for.exit2.loopexit3:
1542 ; PROLOG-NEXT: br label %for.exit2
1543 ; PROLOG: for.exit2:
1544 ; PROLOG-NEXT: ret i32 42
1546 ; PROLOG-BLOCK-LABEL: @hdr_latch_same_exit(
1547 ; PROLOG-BLOCK-NEXT: entry:
1548 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
1549 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
1550 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
1551 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1552 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1553 ; PROLOG-BLOCK: header.prol.preheader:
1554 ; PROLOG-BLOCK-NEXT: br label %header.prol
1555 ; PROLOG-BLOCK: header.prol:
1556 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %latchExit.unr-lcssa, label %for.exiting_block.prol
1557 ; PROLOG-BLOCK: for.exiting_block.prol:
1558 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
1559 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %for.exit2, label %latch.prol
1560 ; PROLOG-BLOCK: latch.prol:
1561 ; PROLOG-BLOCK-NEXT: %2 = load i32, ptr %a, align 4
1562 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
1563 ; PROLOG-BLOCK: header.prol.loopexit:
1564 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ poison, %entry ], [ %2, %latch.prol ]
1565 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
1566 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %latch.prol ]
1567 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
1568 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchExit, label %entry.new
1569 ; PROLOG-BLOCK: entry.new:
1570 ; PROLOG-BLOCK-NEXT: br label %header
1571 ; PROLOG-BLOCK: header:
1572 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
1573 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
1574 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block
1575 ; PROLOG-BLOCK: for.exiting_block:
1576 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
1577 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
1578 ; PROLOG-BLOCK: latch:
1579 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
1580 ; PROLOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx, align 4
1581 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
1582 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
1583 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %latchExit.unr-lcssa.loopexit, label %for.exiting_block.1
1584 ; PROLOG-BLOCK: for.exiting_block.1:
1585 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
1586 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
1587 ; PROLOG-BLOCK: latch.1:
1588 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
1589 ; PROLOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
1590 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
1591 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
1592 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
1593 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !4
1594 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
1595 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ 0, %header ], [ 0, %latch ], [ %add.1, %latch.1 ]
1596 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
1597 ; PROLOG-BLOCK: latchExit.unr-lcssa:
1598 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 0, %header.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1599 ; PROLOG-BLOCK-NEXT: br label %latchExit
1600 ; PROLOG-BLOCK: latchExit:
1601 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
1602 ; PROLOG-BLOCK-NEXT: ret i32 %result
1603 ; PROLOG-BLOCK: for.exit2.loopexit:
1604 ; PROLOG-BLOCK-NEXT: br label %for.exit2
1605 ; PROLOG-BLOCK: for.exit2:
1606 ; PROLOG-BLOCK-NEXT: ret i32 42
1613 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
1614 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
1615 br i1 %cond, label %latchExit, label %for.exiting_block
1618 %cmp = icmp eq i64 %n, 42
1619 br i1 %cmp, label %for.exit2, label %latch
1621 latch: ; preds = %latch, %entry
1622 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
1623 %0 = load i32, ptr %arrayidx, align 4
1624 %add = add nsw i32 %0, %sum.02
1625 %indvars.iv.next = add i64 %indvars.iv, 1
1626 %exitcond = icmp eq i64 %indvars.iv.next, %n
1627 br i1 %exitcond, label %latchExit, label %header
1629 latchExit: ; preds = %latch, %entry
1630 %result = phi i32 [ 0, %header ], [ %add, %latch ]
1637 ; Two exiting blocks to latch where the exiting blocks are Latch and a
1639 ; FIXME: We should unroll this loop.
1640 define i32 @otherblock_latch_same_exit(ptr nocapture %a, i64 %n, i1 %cond) {
1641 ; EPILOG-LABEL: @otherblock_latch_same_exit(
1642 ; EPILOG-NEXT: entry:
1643 ; EPILOG-NEXT: %0 = freeze i64 %n
1644 ; EPILOG-NEXT: %1 = add i64 %0, -1
1645 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
1646 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
1647 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
1648 ; EPILOG: entry.new:
1649 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
1650 ; EPILOG-NEXT: br label %header
1652 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1653 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
1654 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
1655 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
1656 ; EPILOG: for.exiting_block:
1657 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
1658 ; EPILOG-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
1660 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
1661 ; EPILOG-NEXT: %3 = load i32, ptr %arrayidx, align 4
1662 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
1663 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1664 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
1665 ; EPILOG: for.exiting_block.1:
1666 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1667 ; EPILOG-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
1669 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
1670 ; EPILOG-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
1671 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
1672 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
1673 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
1674 ; EPILOG: for.exiting_block.2:
1675 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1676 ; EPILOG-NEXT: br i1 %cmp.2, label %latchExit.epilog-lcssa.loopexit, label %latch.2
1678 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
1679 ; EPILOG-NEXT: %5 = load i32, ptr %arrayidx.2, align 4
1680 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
1681 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
1682 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
1683 ; EPILOG: for.exiting_block.3:
1684 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1685 ; EPILOG-NEXT: br i1 %cmp.3, label %latchExit.epilog-lcssa.loopexit, label %latch.3
1687 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
1688 ; EPILOG-NEXT: %6 = load i32, ptr %arrayidx.3, align 4
1689 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
1690 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
1691 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
1692 ; EPILOG: for.exiting_block.4:
1693 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1694 ; EPILOG-NEXT: br i1 %cmp.4, label %latchExit.epilog-lcssa.loopexit, label %latch.4
1696 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
1697 ; EPILOG-NEXT: %7 = load i32, ptr %arrayidx.4, align 4
1698 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
1699 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
1700 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
1701 ; EPILOG: for.exiting_block.5:
1702 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1703 ; EPILOG-NEXT: br i1 %cmp.5, label %latchExit.epilog-lcssa.loopexit, label %latch.5
1705 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
1706 ; EPILOG-NEXT: %8 = load i32, ptr %arrayidx.5, align 4
1707 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
1708 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv, 6
1709 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
1710 ; EPILOG: for.exiting_block.6:
1711 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1712 ; EPILOG-NEXT: br i1 %cmp.6, label %latchExit.epilog-lcssa.loopexit, label %latch.6
1714 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
1715 ; EPILOG-NEXT: %9 = load i32, ptr %arrayidx.6, align 4
1716 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
1717 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv, 7
1718 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
1719 ; EPILOG: for.exiting_block.7:
1720 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1721 ; EPILOG-NEXT: br i1 %cmp.7, label %latchExit.epilog-lcssa.loopexit, label %latch.7
1723 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
1724 ; EPILOG-NEXT: %10 = load i32, ptr %arrayidx.7, align 4
1725 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
1726 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
1727 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
1728 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
1729 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
1730 ; EPILOG: latchExit.unr-lcssa.loopexit:
1731 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
1732 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
1733 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
1734 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
1735 ; EPILOG: latchExit.unr-lcssa:
1736 ; EPILOG-NEXT: %result.ph = phi i32 [ poison, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1737 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1738 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1739 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1740 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1741 ; EPILOG: header.epil.preheader:
1742 ; EPILOG-NEXT: br label %header.epil
1743 ; EPILOG: header.epil:
1744 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
1745 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
1746 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
1747 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit2, label %for.exiting_block.epil
1748 ; EPILOG: for.exiting_block.epil:
1749 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
1750 ; EPILOG-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa.loopexit3, label %latch.epil
1751 ; EPILOG: latch.epil:
1752 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.epil
1753 ; EPILOG-NEXT: %11 = load i32, ptr %arrayidx.epil, align 4
1754 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
1755 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
1756 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
1757 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
1758 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
1759 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit3, !llvm.loop !5
1760 ; EPILOG: latchExit.epilog-lcssa.loopexit:
1761 ; 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 ]
1762 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1763 ; EPILOG: latchExit.epilog-lcssa.loopexit3:
1764 ; EPILOG-NEXT: %result.ph1.ph4 = phi i32 [ 2, %for.exiting_block.epil ], [ %add.epil, %latch.epil ]
1765 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
1766 ; EPILOG: latchExit.epilog-lcssa:
1767 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph4, %latchExit.epilog-lcssa.loopexit3 ]
1768 ; EPILOG-NEXT: br label %latchExit
1769 ; EPILOG: latchExit:
1770 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1771 ; EPILOG-NEXT: ret i32 %result
1772 ; EPILOG: for.exit2.loopexit:
1773 ; EPILOG-NEXT: br label %for.exit2
1774 ; EPILOG: for.exit2.loopexit2:
1775 ; EPILOG-NEXT: br label %for.exit2
1776 ; EPILOG: for.exit2:
1777 ; EPILOG-NEXT: ret i32 42
1779 ; EPILOG-BLOCK-LABEL: @otherblock_latch_same_exit(
1780 ; EPILOG-BLOCK-NEXT: entry:
1781 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
1782 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
1783 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
1784 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
1785 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
1786 ; EPILOG-BLOCK: entry.new:
1787 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
1788 ; EPILOG-BLOCK-NEXT: br label %header
1789 ; EPILOG-BLOCK: header:
1790 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
1791 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
1792 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
1793 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
1794 ; EPILOG-BLOCK: for.exiting_block:
1795 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
1796 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
1797 ; EPILOG-BLOCK: latch:
1798 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
1799 ; EPILOG-BLOCK-NEXT: %3 = load i32, ptr %arrayidx, align 4
1800 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
1801 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
1802 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
1803 ; EPILOG-BLOCK: for.exiting_block.1:
1804 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
1805 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
1806 ; EPILOG-BLOCK: latch.1:
1807 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
1808 ; EPILOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
1809 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
1810 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
1811 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
1812 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
1813 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !5
1814 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
1815 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
1816 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
1817 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
1818 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
1819 ; EPILOG-BLOCK: latchExit.unr-lcssa:
1820 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ poison, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
1821 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
1822 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
1823 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1824 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
1825 ; EPILOG-BLOCK: header.epil.preheader:
1826 ; EPILOG-BLOCK-NEXT: br label %header.epil
1827 ; EPILOG-BLOCK: header.epil:
1828 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.epil
1829 ; EPILOG-BLOCK: for.exiting_block.epil:
1830 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
1831 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa, label %latch.epil
1832 ; EPILOG-BLOCK: latch.epil:
1833 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.unr
1834 ; EPILOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.epil, align 4
1835 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
1836 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1837 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
1838 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ 2, %for.exiting_block ], [ 2, %for.exiting_block.1 ]
1839 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
1840 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
1841 ; EPILOG-BLOCK-NEXT: %result.ph1 = phi i32 [ %add.epil, %latch.epil ], [ 2, %for.exiting_block.epil ], [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
1842 ; EPILOG-BLOCK-NEXT: br label %latchExit
1843 ; EPILOG-BLOCK: latchExit:
1844 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
1845 ; EPILOG-BLOCK-NEXT: ret i32 %result
1846 ; EPILOG-BLOCK: for.exit2.loopexit:
1847 ; EPILOG-BLOCK-NEXT: br label %for.exit2
1848 ; EPILOG-BLOCK: for.exit2:
1849 ; EPILOG-BLOCK-NEXT: ret i32 42
1851 ; PROLOG-LABEL: @otherblock_latch_same_exit(
1852 ; PROLOG-NEXT: entry:
1853 ; PROLOG-NEXT: %0 = freeze i64 %n
1854 ; PROLOG-NEXT: %1 = add i64 %0, -1
1855 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
1856 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1857 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1858 ; PROLOG: header.prol.preheader:
1859 ; PROLOG-NEXT: br label %header.prol
1860 ; PROLOG: header.prol:
1861 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1862 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
1863 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
1864 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit1, label %for.exiting_block.prol
1865 ; PROLOG: for.exiting_block.prol:
1866 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
1867 ; PROLOG-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa.loopexit2, label %latch.prol
1868 ; PROLOG: latch.prol:
1869 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.prol
1870 ; PROLOG-NEXT: %2 = load i32, ptr %arrayidx.prol, align 4
1871 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
1872 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
1873 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
1874 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
1875 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
1876 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !5
1877 ; PROLOG: header.prol.loopexit.unr-lcssa:
1878 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1879 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
1880 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
1881 ; PROLOG-NEXT: br label %header.prol.loopexit
1882 ; PROLOG: header.prol.loopexit:
1883 ; PROLOG-NEXT: %result.unr = phi i32 [ poison, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
1884 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
1885 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
1886 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
1887 ; PROLOG-NEXT: br i1 %3, label %latchExit, label %entry.new
1888 ; PROLOG: entry.new:
1889 ; PROLOG-NEXT: br label %header
1891 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
1892 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
1893 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
1894 ; PROLOG: for.exiting_block:
1895 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
1896 ; PROLOG-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
1898 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
1899 ; PROLOG-NEXT: %4 = load i32, ptr %arrayidx, align 4
1900 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
1901 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
1902 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
1903 ; PROLOG: for.exiting_block.1:
1904 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
1905 ; PROLOG-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
1907 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
1908 ; PROLOG-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
1909 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
1910 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
1911 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
1912 ; PROLOG: for.exiting_block.2:
1913 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
1914 ; PROLOG-NEXT: br i1 %cmp.2, label %latchExit.unr-lcssa.loopexit, label %latch.2
1916 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
1917 ; PROLOG-NEXT: %6 = load i32, ptr %arrayidx.2, align 4
1918 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
1919 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv, 3
1920 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
1921 ; PROLOG: for.exiting_block.3:
1922 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
1923 ; PROLOG-NEXT: br i1 %cmp.3, label %latchExit.unr-lcssa.loopexit, label %latch.3
1925 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
1926 ; PROLOG-NEXT: %7 = load i32, ptr %arrayidx.3, align 4
1927 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
1928 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv, 4
1929 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
1930 ; PROLOG: for.exiting_block.4:
1931 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
1932 ; PROLOG-NEXT: br i1 %cmp.4, label %latchExit.unr-lcssa.loopexit, label %latch.4
1934 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
1935 ; PROLOG-NEXT: %8 = load i32, ptr %arrayidx.4, align 4
1936 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
1937 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv, 5
1938 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
1939 ; PROLOG: for.exiting_block.5:
1940 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
1941 ; PROLOG-NEXT: br i1 %cmp.5, label %latchExit.unr-lcssa.loopexit, label %latch.5
1943 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
1944 ; PROLOG-NEXT: %9 = load i32, ptr %arrayidx.5, align 4
1945 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
1946 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv, 6
1947 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
1948 ; PROLOG: for.exiting_block.6:
1949 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
1950 ; PROLOG-NEXT: br i1 %cmp.6, label %latchExit.unr-lcssa.loopexit, label %latch.6
1952 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
1953 ; PROLOG-NEXT: %10 = load i32, ptr %arrayidx.6, align 4
1954 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
1955 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv, 7
1956 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
1957 ; PROLOG: for.exiting_block.7:
1958 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
1959 ; PROLOG-NEXT: br i1 %cmp.7, label %latchExit.unr-lcssa.loopexit, label %latch.7
1961 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
1962 ; PROLOG-NEXT: %11 = load i32, ptr %arrayidx.7, align 4
1963 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
1964 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
1965 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
1966 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
1967 ; PROLOG: latchExit.unr-lcssa.loopexit:
1968 ; 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 ]
1969 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
1970 ; PROLOG: latchExit.unr-lcssa.loopexit2:
1971 ; PROLOG-NEXT: %result.ph.ph3 = phi i32 [ 2, %for.exiting_block.prol ]
1972 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
1973 ; PROLOG: latchExit.unr-lcssa:
1974 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph3, %latchExit.unr-lcssa.loopexit2 ]
1975 ; PROLOG-NEXT: br label %latchExit
1976 ; PROLOG: latchExit:
1977 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
1978 ; PROLOG-NEXT: ret i32 %result
1979 ; PROLOG: for.exit2.loopexit:
1980 ; PROLOG-NEXT: br label %for.exit2
1981 ; PROLOG: for.exit2.loopexit1:
1982 ; PROLOG-NEXT: br label %for.exit2
1983 ; PROLOG: for.exit2:
1984 ; PROLOG-NEXT: ret i32 42
1986 ; PROLOG-BLOCK-LABEL: @otherblock_latch_same_exit(
1987 ; PROLOG-BLOCK-NEXT: entry:
1988 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
1989 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
1990 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
1991 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
1992 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
1993 ; PROLOG-BLOCK: header.prol.preheader:
1994 ; PROLOG-BLOCK-NEXT: br label %header.prol
1995 ; PROLOG-BLOCK: header.prol:
1996 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.prol
1997 ; PROLOG-BLOCK: for.exiting_block.prol:
1998 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
1999 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa, label %latch.prol
2000 ; PROLOG-BLOCK: latch.prol:
2001 ; PROLOG-BLOCK-NEXT: %2 = load i32, ptr %a, align 4
2002 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
2003 ; PROLOG-BLOCK: header.prol.loopexit:
2004 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ poison, %entry ], [ %2, %latch.prol ]
2005 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
2006 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %latch.prol ]
2007 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
2008 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchExit, label %entry.new
2009 ; PROLOG-BLOCK: entry.new:
2010 ; PROLOG-BLOCK-NEXT: br label %header
2011 ; PROLOG-BLOCK: header:
2012 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2013 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
2014 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2015 ; PROLOG-BLOCK: for.exiting_block:
2016 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2017 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2018 ; PROLOG-BLOCK: latch:
2019 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2020 ; PROLOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx, align 4
2021 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
2022 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2023 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2024 ; PROLOG-BLOCK: for.exiting_block.1:
2025 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2026 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2027 ; PROLOG-BLOCK: latch.1:
2028 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
2029 ; PROLOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
2030 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
2031 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
2032 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
2033 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !5
2034 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
2035 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ 2, %for.exiting_block ], [ 2, %for.exiting_block.1 ], [ %add.1, %latch.1 ]
2036 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2037 ; PROLOG-BLOCK: latchExit.unr-lcssa:
2038 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 2, %for.exiting_block.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2039 ; PROLOG-BLOCK-NEXT: br label %latchExit
2040 ; PROLOG-BLOCK: latchExit:
2041 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2042 ; PROLOG-BLOCK-NEXT: ret i32 %result
2043 ; PROLOG-BLOCK: for.exit2.loopexit:
2044 ; PROLOG-BLOCK-NEXT: br label %for.exit2
2045 ; PROLOG-BLOCK: for.exit2:
2046 ; PROLOG-BLOCK-NEXT: ret i32 42
2053 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
2054 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
2055 br i1 %cond, label %for.exit2, label %for.exiting_block
2058 %cmp = icmp eq i64 %n, 42
2059 br i1 %cmp, label %latchExit, label %latch
2061 latch: ; preds = %latch, %entry
2062 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2063 %0 = load i32, ptr %arrayidx, align 4
2064 %add = add nsw i32 %0, %sum.02
2065 %indvars.iv.next = add i64 %indvars.iv, 1
2066 %exitcond = icmp eq i64 %indvars.iv.next, %n
2067 br i1 %exitcond, label %latchExit, label %header
2069 latchExit: ; preds = %latch, %entry
2070 %result = phi i32 [ 2, %for.exiting_block ], [ %add, %latch ]
2077 ; Two exiting blocks to latch where the exiting blocks are Latch and a
2079 ; Same as above test except the incoming value for latch Phi is from the header
2080 ; FIXME: We should be able to runtime unroll.
2081 define i32 @otherblock_latch_same_exit2(ptr nocapture %a, i64 %n, i1 %cond) {
2082 ; EPILOG-LABEL: @otherblock_latch_same_exit2(
2083 ; EPILOG-NEXT: entry:
2084 ; EPILOG-NEXT: %0 = freeze i64 %n
2085 ; EPILOG-NEXT: %1 = add i64 %0, -1
2086 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
2087 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
2088 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
2089 ; EPILOG: entry.new:
2090 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
2091 ; EPILOG-NEXT: br label %header
2093 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2094 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
2095 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
2096 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2097 ; EPILOG: for.exiting_block:
2098 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
2099 ; EPILOG-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2101 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2102 ; EPILOG-NEXT: %3 = load i32, ptr %arrayidx, align 4
2103 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
2104 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2105 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2106 ; EPILOG: for.exiting_block.1:
2107 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2108 ; EPILOG-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2110 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
2111 ; EPILOG-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
2112 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
2113 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
2114 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2115 ; EPILOG: for.exiting_block.2:
2116 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2117 ; EPILOG-NEXT: br i1 %cmp.2, label %latchExit.epilog-lcssa.loopexit, label %latch.2
2119 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
2120 ; EPILOG-NEXT: %5 = load i32, ptr %arrayidx.2, align 4
2121 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
2122 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
2123 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2124 ; EPILOG: for.exiting_block.3:
2125 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2126 ; EPILOG-NEXT: br i1 %cmp.3, label %latchExit.epilog-lcssa.loopexit, label %latch.3
2128 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
2129 ; EPILOG-NEXT: %6 = load i32, ptr %arrayidx.3, align 4
2130 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
2131 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
2132 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2133 ; EPILOG: for.exiting_block.4:
2134 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2135 ; EPILOG-NEXT: br i1 %cmp.4, label %latchExit.epilog-lcssa.loopexit, label %latch.4
2137 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
2138 ; EPILOG-NEXT: %7 = load i32, ptr %arrayidx.4, align 4
2139 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
2140 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
2141 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2142 ; EPILOG: for.exiting_block.5:
2143 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2144 ; EPILOG-NEXT: br i1 %cmp.5, label %latchExit.epilog-lcssa.loopexit, label %latch.5
2146 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
2147 ; EPILOG-NEXT: %8 = load i32, ptr %arrayidx.5, align 4
2148 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
2149 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv, 6
2150 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2151 ; EPILOG: for.exiting_block.6:
2152 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2153 ; EPILOG-NEXT: br i1 %cmp.6, label %latchExit.epilog-lcssa.loopexit, label %latch.6
2155 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
2156 ; EPILOG-NEXT: %9 = load i32, ptr %arrayidx.6, align 4
2157 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
2158 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv, 7
2159 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2160 ; EPILOG: for.exiting_block.7:
2161 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2162 ; EPILOG-NEXT: br i1 %cmp.7, label %latchExit.epilog-lcssa.loopexit, label %latch.7
2164 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
2165 ; EPILOG-NEXT: %10 = load i32, ptr %arrayidx.7, align 4
2166 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
2167 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
2168 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
2169 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
2170 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
2171 ; EPILOG: latchExit.unr-lcssa.loopexit:
2172 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
2173 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
2174 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
2175 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
2176 ; EPILOG: latchExit.unr-lcssa:
2177 ; EPILOG-NEXT: %result.ph = phi i32 [ poison, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2178 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2179 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2180 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2181 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2182 ; EPILOG: header.epil.preheader:
2183 ; EPILOG-NEXT: br label %header.epil
2184 ; EPILOG: header.epil:
2185 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
2186 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
2187 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
2188 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit2, label %for.exiting_block.epil
2189 ; EPILOG: for.exiting_block.epil:
2190 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
2191 ; EPILOG-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa.loopexit3, label %latch.epil
2192 ; EPILOG: latch.epil:
2193 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.epil
2194 ; EPILOG-NEXT: %11 = load i32, ptr %arrayidx.epil, align 4
2195 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
2196 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
2197 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
2198 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
2199 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
2200 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit3, !llvm.loop !6
2201 ; EPILOG: latchExit.epilog-lcssa.loopexit:
2202 ; 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 ]
2203 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2204 ; EPILOG: latchExit.epilog-lcssa.loopexit3:
2205 ; EPILOG-NEXT: %result.ph1.ph4 = phi i32 [ %sum.02.epil, %for.exiting_block.epil ], [ %add.epil, %latch.epil ]
2206 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2207 ; EPILOG: latchExit.epilog-lcssa:
2208 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph4, %latchExit.epilog-lcssa.loopexit3 ]
2209 ; EPILOG-NEXT: br label %latchExit
2210 ; EPILOG: latchExit:
2211 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2212 ; EPILOG-NEXT: ret i32 %result
2213 ; EPILOG: for.exit2.loopexit:
2214 ; EPILOG-NEXT: br label %for.exit2
2215 ; EPILOG: for.exit2.loopexit2:
2216 ; EPILOG-NEXT: br label %for.exit2
2217 ; EPILOG: for.exit2:
2218 ; EPILOG-NEXT: ret i32 42
2220 ; EPILOG-BLOCK-LABEL: @otherblock_latch_same_exit2(
2221 ; EPILOG-BLOCK-NEXT: entry:
2222 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
2223 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
2224 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
2225 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
2226 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
2227 ; EPILOG-BLOCK: entry.new:
2228 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
2229 ; EPILOG-BLOCK-NEXT: br label %header
2230 ; EPILOG-BLOCK: header:
2231 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2232 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
2233 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
2234 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2235 ; EPILOG-BLOCK: for.exiting_block:
2236 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2237 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2238 ; EPILOG-BLOCK: latch:
2239 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2240 ; EPILOG-BLOCK-NEXT: %3 = load i32, ptr %arrayidx, align 4
2241 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
2242 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2243 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2244 ; EPILOG-BLOCK: for.exiting_block.1:
2245 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2246 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2247 ; EPILOG-BLOCK: latch.1:
2248 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
2249 ; EPILOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
2250 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
2251 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
2252 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
2253 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
2254 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !6
2255 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
2256 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
2257 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
2258 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
2259 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2260 ; EPILOG-BLOCK: latchExit.unr-lcssa:
2261 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ poison, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2262 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2263 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2264 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2265 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2266 ; EPILOG-BLOCK: header.epil.preheader:
2267 ; EPILOG-BLOCK-NEXT: br label %header.epil
2268 ; EPILOG-BLOCK: header.epil:
2269 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.epil
2270 ; EPILOG-BLOCK: for.exiting_block.epil:
2271 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
2272 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa, label %latch.epil
2273 ; EPILOG-BLOCK: latch.epil:
2274 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.unr
2275 ; EPILOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.epil, align 4
2276 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
2277 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2278 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
2279 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ]
2280 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2281 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
2282 ; 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 ]
2283 ; EPILOG-BLOCK-NEXT: br label %latchExit
2284 ; EPILOG-BLOCK: latchExit:
2285 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2286 ; EPILOG-BLOCK-NEXT: ret i32 %result
2287 ; EPILOG-BLOCK: for.exit2.loopexit:
2288 ; EPILOG-BLOCK-NEXT: br label %for.exit2
2289 ; EPILOG-BLOCK: for.exit2:
2290 ; EPILOG-BLOCK-NEXT: ret i32 42
2292 ; PROLOG-LABEL: @otherblock_latch_same_exit2(
2293 ; PROLOG-NEXT: entry:
2294 ; PROLOG-NEXT: %0 = freeze i64 %n
2295 ; PROLOG-NEXT: %1 = add i64 %0, -1
2296 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
2297 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2298 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2299 ; PROLOG: header.prol.preheader:
2300 ; PROLOG-NEXT: br label %header.prol
2301 ; PROLOG: header.prol:
2302 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2303 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2304 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
2305 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit1, label %for.exiting_block.prol
2306 ; PROLOG: for.exiting_block.prol:
2307 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
2308 ; PROLOG-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa.loopexit2, label %latch.prol
2309 ; PROLOG: latch.prol:
2310 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.prol
2311 ; PROLOG-NEXT: %2 = load i32, ptr %arrayidx.prol, align 4
2312 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
2313 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
2314 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
2315 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
2316 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
2317 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !6
2318 ; PROLOG: header.prol.loopexit.unr-lcssa:
2319 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2320 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
2321 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2322 ; PROLOG-NEXT: br label %header.prol.loopexit
2323 ; PROLOG: header.prol.loopexit:
2324 ; PROLOG-NEXT: %result.unr = phi i32 [ poison, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
2325 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
2326 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
2327 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
2328 ; PROLOG-NEXT: br i1 %3, label %latchExit, label %entry.new
2329 ; PROLOG: entry.new:
2330 ; PROLOG-NEXT: br label %header
2332 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2333 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
2334 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2335 ; PROLOG: for.exiting_block:
2336 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
2337 ; PROLOG-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2339 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2340 ; PROLOG-NEXT: %4 = load i32, ptr %arrayidx, align 4
2341 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
2342 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2343 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2344 ; PROLOG: for.exiting_block.1:
2345 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2346 ; PROLOG-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2348 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
2349 ; PROLOG-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
2350 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
2351 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
2352 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2353 ; PROLOG: for.exiting_block.2:
2354 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2355 ; PROLOG-NEXT: br i1 %cmp.2, label %latchExit.unr-lcssa.loopexit, label %latch.2
2357 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
2358 ; PROLOG-NEXT: %6 = load i32, ptr %arrayidx.2, align 4
2359 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
2360 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv, 3
2361 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2362 ; PROLOG: for.exiting_block.3:
2363 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2364 ; PROLOG-NEXT: br i1 %cmp.3, label %latchExit.unr-lcssa.loopexit, label %latch.3
2366 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
2367 ; PROLOG-NEXT: %7 = load i32, ptr %arrayidx.3, align 4
2368 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
2369 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv, 4
2370 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2371 ; PROLOG: for.exiting_block.4:
2372 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2373 ; PROLOG-NEXT: br i1 %cmp.4, label %latchExit.unr-lcssa.loopexit, label %latch.4
2375 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
2376 ; PROLOG-NEXT: %8 = load i32, ptr %arrayidx.4, align 4
2377 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
2378 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv, 5
2379 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2380 ; PROLOG: for.exiting_block.5:
2381 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2382 ; PROLOG-NEXT: br i1 %cmp.5, label %latchExit.unr-lcssa.loopexit, label %latch.5
2384 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
2385 ; PROLOG-NEXT: %9 = load i32, ptr %arrayidx.5, align 4
2386 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
2387 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv, 6
2388 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2389 ; PROLOG: for.exiting_block.6:
2390 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2391 ; PROLOG-NEXT: br i1 %cmp.6, label %latchExit.unr-lcssa.loopexit, label %latch.6
2393 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
2394 ; PROLOG-NEXT: %10 = load i32, ptr %arrayidx.6, align 4
2395 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
2396 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv, 7
2397 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2398 ; PROLOG: for.exiting_block.7:
2399 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2400 ; PROLOG-NEXT: br i1 %cmp.7, label %latchExit.unr-lcssa.loopexit, label %latch.7
2402 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
2403 ; PROLOG-NEXT: %11 = load i32, ptr %arrayidx.7, align 4
2404 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
2405 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
2406 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
2407 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
2408 ; PROLOG: latchExit.unr-lcssa.loopexit:
2409 ; 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 ]
2410 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2411 ; PROLOG: latchExit.unr-lcssa.loopexit2:
2412 ; PROLOG-NEXT: %result.ph.ph3 = phi i32 [ %sum.02.prol, %for.exiting_block.prol ]
2413 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2414 ; PROLOG: latchExit.unr-lcssa:
2415 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph3, %latchExit.unr-lcssa.loopexit2 ]
2416 ; PROLOG-NEXT: br label %latchExit
2417 ; PROLOG: latchExit:
2418 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2419 ; PROLOG-NEXT: ret i32 %result
2420 ; PROLOG: for.exit2.loopexit:
2421 ; PROLOG-NEXT: br label %for.exit2
2422 ; PROLOG: for.exit2.loopexit1:
2423 ; PROLOG-NEXT: br label %for.exit2
2424 ; PROLOG: for.exit2:
2425 ; PROLOG-NEXT: ret i32 42
2427 ; PROLOG-BLOCK-LABEL: @otherblock_latch_same_exit2(
2428 ; PROLOG-BLOCK-NEXT: entry:
2429 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
2430 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
2431 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
2432 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2433 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2434 ; PROLOG-BLOCK: header.prol.preheader:
2435 ; PROLOG-BLOCK-NEXT: br label %header.prol
2436 ; PROLOG-BLOCK: header.prol:
2437 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.prol
2438 ; PROLOG-BLOCK: for.exiting_block.prol:
2439 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
2440 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa, label %latch.prol
2441 ; PROLOG-BLOCK: latch.prol:
2442 ; PROLOG-BLOCK-NEXT: %2 = load i32, ptr %a, align 4
2443 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
2444 ; PROLOG-BLOCK: header.prol.loopexit:
2445 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ poison, %entry ], [ %2, %latch.prol ]
2446 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
2447 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %latch.prol ]
2448 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
2449 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchExit, label %entry.new
2450 ; PROLOG-BLOCK: entry.new:
2451 ; PROLOG-BLOCK-NEXT: br label %header
2452 ; PROLOG-BLOCK: header:
2453 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2454 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
2455 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2456 ; PROLOG-BLOCK: for.exiting_block:
2457 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2458 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2459 ; PROLOG-BLOCK: latch:
2460 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2461 ; PROLOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx, align 4
2462 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
2463 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2464 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2465 ; PROLOG-BLOCK: for.exiting_block.1:
2466 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2467 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2468 ; PROLOG-BLOCK: latch.1:
2469 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
2470 ; PROLOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
2471 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
2472 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
2473 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
2474 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !6
2475 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
2476 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %latch.1 ]
2477 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2478 ; PROLOG-BLOCK: latchExit.unr-lcssa:
2479 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 0, %for.exiting_block.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2480 ; PROLOG-BLOCK-NEXT: br label %latchExit
2481 ; PROLOG-BLOCK: latchExit:
2482 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2483 ; PROLOG-BLOCK-NEXT: ret i32 %result
2484 ; PROLOG-BLOCK: for.exit2.loopexit:
2485 ; PROLOG-BLOCK-NEXT: br label %for.exit2
2486 ; PROLOG-BLOCK: for.exit2:
2487 ; PROLOG-BLOCK-NEXT: ret i32 42
2494 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
2495 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
2496 br i1 %cond, label %for.exit2, label %for.exiting_block
2499 %cmp = icmp eq i64 %n, 42
2500 br i1 %cmp, label %latchExit, label %latch
2502 latch: ; preds = %latch, %entry
2503 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2504 %0 = load i32, ptr %arrayidx, align 4
2505 %add = add nsw i32 %0, %sum.02
2506 %indvars.iv.next = add i64 %indvars.iv, 1
2507 %exitcond = icmp eq i64 %indvars.iv.next, %n
2508 br i1 %exitcond, label %latchExit, label %header
2510 latchExit: ; preds = %latch, %entry
2511 %result = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %latch ]
2518 ; Two exiting blocks to latch where the exiting blocks are Latch and a
2520 ; Same as above test except the incoming value for cloned latch Phi is from the
2521 ; for.exiting_block.
2522 ; FIXME: We should be able to runtime unroll.
2523 define i32 @otherblock_latch_same_exit3(ptr nocapture %a, i64 %n, i1 %cond) {
2524 ; EPILOG-LABEL: @otherblock_latch_same_exit3(
2525 ; EPILOG-NEXT: entry:
2526 ; EPILOG-NEXT: %0 = freeze i64 %n
2527 ; EPILOG-NEXT: %1 = add i64 %0, -1
2528 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
2529 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
2530 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
2531 ; EPILOG: entry.new:
2532 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
2533 ; EPILOG-NEXT: br label %header
2535 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2536 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
2537 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
2538 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2539 ; EPILOG: for.exiting_block:
2540 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2541 ; EPILOG-NEXT: %3 = load i32, ptr %arrayidx, align 4
2542 ; EPILOG-NEXT: %add = add nsw i32 %3, %sum.02
2543 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
2544 ; EPILOG-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2546 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2547 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2548 ; EPILOG: for.exiting_block.1:
2549 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
2550 ; EPILOG-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
2551 ; EPILOG-NEXT: %add.1 = add nsw i32 %4, %add
2552 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2553 ; EPILOG-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2555 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
2556 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2557 ; EPILOG: for.exiting_block.2:
2558 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
2559 ; EPILOG-NEXT: %5 = load i32, ptr %arrayidx.2, align 4
2560 ; EPILOG-NEXT: %add.2 = add nsw i32 %5, %add.1
2561 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2562 ; EPILOG-NEXT: br i1 %cmp.2, label %latchExit.epilog-lcssa.loopexit, label %latch.2
2564 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
2565 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2566 ; EPILOG: for.exiting_block.3:
2567 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
2568 ; EPILOG-NEXT: %6 = load i32, ptr %arrayidx.3, align 4
2569 ; EPILOG-NEXT: %add.3 = add nsw i32 %6, %add.2
2570 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2571 ; EPILOG-NEXT: br i1 %cmp.3, label %latchExit.epilog-lcssa.loopexit, label %latch.3
2573 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
2574 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2575 ; EPILOG: for.exiting_block.4:
2576 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
2577 ; EPILOG-NEXT: %7 = load i32, ptr %arrayidx.4, align 4
2578 ; EPILOG-NEXT: %add.4 = add nsw i32 %7, %add.3
2579 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2580 ; EPILOG-NEXT: br i1 %cmp.4, label %latchExit.epilog-lcssa.loopexit, label %latch.4
2582 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
2583 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2584 ; EPILOG: for.exiting_block.5:
2585 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
2586 ; EPILOG-NEXT: %8 = load i32, ptr %arrayidx.5, align 4
2587 ; EPILOG-NEXT: %add.5 = add nsw i32 %8, %add.4
2588 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2589 ; EPILOG-NEXT: br i1 %cmp.5, label %latchExit.epilog-lcssa.loopexit, label %latch.5
2591 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv, 6
2592 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2593 ; EPILOG: for.exiting_block.6:
2594 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
2595 ; EPILOG-NEXT: %9 = load i32, ptr %arrayidx.6, align 4
2596 ; EPILOG-NEXT: %add.6 = add nsw i32 %9, %add.5
2597 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2598 ; EPILOG-NEXT: br i1 %cmp.6, label %latchExit.epilog-lcssa.loopexit, label %latch.6
2600 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv, 7
2601 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2602 ; EPILOG: for.exiting_block.7:
2603 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
2604 ; EPILOG-NEXT: %10 = load i32, ptr %arrayidx.7, align 4
2605 ; EPILOG-NEXT: %add.7 = add nsw i32 %10, %add.6
2606 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2607 ; EPILOG-NEXT: br i1 %cmp.7, label %latchExit.epilog-lcssa.loopexit, label %latch.7
2609 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
2610 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
2611 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
2612 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latchExit.unr-lcssa.loopexit, label %header
2613 ; EPILOG: latchExit.unr-lcssa.loopexit:
2614 ; EPILOG-NEXT: %result.ph.ph = phi i32 [ %add.7, %latch.7 ]
2615 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
2616 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
2617 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
2618 ; EPILOG: latchExit.unr-lcssa:
2619 ; EPILOG-NEXT: %result.ph = phi i32 [ poison, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2620 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2621 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2622 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2623 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2624 ; EPILOG: header.epil.preheader:
2625 ; EPILOG-NEXT: br label %header.epil
2626 ; EPILOG: header.epil:
2627 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
2628 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
2629 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
2630 ; EPILOG-NEXT: br i1 %cond, label %for.exit2.loopexit2, label %for.exiting_block.epil
2631 ; EPILOG: for.exiting_block.epil:
2632 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.epil
2633 ; EPILOG-NEXT: %11 = load i32, ptr %arrayidx.epil, align 4
2634 ; EPILOG-NEXT: %add.epil = add nsw i32 %11, %sum.02.epil
2635 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
2636 ; EPILOG-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa.loopexit3, label %latch.epil
2637 ; EPILOG: latch.epil:
2638 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
2639 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
2640 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
2641 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
2642 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit3, !llvm.loop !7
2643 ; EPILOG: latchExit.epilog-lcssa.loopexit:
2644 ; 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 ]
2645 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2646 ; EPILOG: latchExit.epilog-lcssa.loopexit3:
2647 ; EPILOG-NEXT: %result.ph1.ph4 = phi i32 [ %sum.02.epil, %for.exiting_block.epil ], [ %add.epil, %latch.epil ]
2648 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
2649 ; EPILOG: latchExit.epilog-lcssa:
2650 ; EPILOG-NEXT: %result.ph1 = phi i32 [ %result.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %result.ph1.ph4, %latchExit.epilog-lcssa.loopexit3 ]
2651 ; EPILOG-NEXT: br label %latchExit
2652 ; EPILOG: latchExit:
2653 ; EPILOG-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2654 ; EPILOG-NEXT: ret i32 %result
2655 ; EPILOG: for.exit2.loopexit:
2656 ; EPILOG-NEXT: br label %for.exit2
2657 ; EPILOG: for.exit2.loopexit2:
2658 ; EPILOG-NEXT: br label %for.exit2
2659 ; EPILOG: for.exit2:
2660 ; EPILOG-NEXT: ret i32 42
2662 ; EPILOG-BLOCK-LABEL: @otherblock_latch_same_exit3(
2663 ; EPILOG-BLOCK-NEXT: entry:
2664 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
2665 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
2666 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
2667 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
2668 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %entry.new
2669 ; EPILOG-BLOCK: entry.new:
2670 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
2671 ; EPILOG-BLOCK-NEXT: br label %header
2672 ; EPILOG-BLOCK: header:
2673 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2674 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
2675 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
2676 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2677 ; EPILOG-BLOCK: for.exiting_block:
2678 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2679 ; EPILOG-BLOCK-NEXT: %3 = load i32, ptr %arrayidx, align 4
2680 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %3, %sum.02
2681 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2682 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.epilog-lcssa.loopexit, label %latch
2683 ; EPILOG-BLOCK: latch:
2684 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
2685 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2686 ; EPILOG-BLOCK: for.exiting_block.1:
2687 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
2688 ; EPILOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx.1, align 4
2689 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %4, %add
2690 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2691 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.epilog-lcssa.loopexit, label %latch.1
2692 ; EPILOG-BLOCK: latch.1:
2693 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
2694 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
2695 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
2696 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !7
2697 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
2698 ; EPILOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %add.1, %latch.1 ]
2699 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
2700 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
2701 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2702 ; EPILOG-BLOCK: latchExit.unr-lcssa:
2703 ; EPILOG-BLOCK-NEXT: %result.ph = phi i32 [ poison, %entry ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2704 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latchExit.unr-lcssa.loopexit ]
2705 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latchExit.unr-lcssa.loopexit ]
2706 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2707 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
2708 ; EPILOG-BLOCK: header.epil.preheader:
2709 ; EPILOG-BLOCK-NEXT: br label %header.epil
2710 ; EPILOG-BLOCK: header.epil:
2711 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.epil
2712 ; EPILOG-BLOCK: for.exiting_block.epil:
2713 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.unr
2714 ; EPILOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.epil, align 4
2715 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %5, %sum.02.unr
2716 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
2717 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %latchExit.epilog-lcssa, label %latch.epil
2718 ; EPILOG-BLOCK: latch.epil:
2719 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2720 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
2721 ; EPILOG-BLOCK-NEXT: %result.ph1.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ]
2722 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
2723 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
2724 ; 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 ]
2725 ; EPILOG-BLOCK-NEXT: br label %latchExit
2726 ; EPILOG-BLOCK: latchExit:
2727 ; EPILOG-BLOCK-NEXT: %result = phi i32 [ %result.ph, %latchExit.unr-lcssa ], [ %result.ph1, %latchExit.epilog-lcssa ]
2728 ; EPILOG-BLOCK-NEXT: ret i32 %result
2729 ; EPILOG-BLOCK: for.exit2.loopexit:
2730 ; EPILOG-BLOCK-NEXT: br label %for.exit2
2731 ; EPILOG-BLOCK: for.exit2:
2732 ; EPILOG-BLOCK-NEXT: ret i32 42
2734 ; PROLOG-LABEL: @otherblock_latch_same_exit3(
2735 ; PROLOG-NEXT: entry:
2736 ; PROLOG-NEXT: %0 = freeze i64 %n
2737 ; PROLOG-NEXT: %1 = add i64 %0, -1
2738 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
2739 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2740 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2741 ; PROLOG: header.prol.preheader:
2742 ; PROLOG-NEXT: br label %header.prol
2743 ; PROLOG: header.prol:
2744 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2745 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
2746 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
2747 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit1, label %for.exiting_block.prol
2748 ; PROLOG: for.exiting_block.prol:
2749 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.prol
2750 ; PROLOG-NEXT: %2 = load i32, ptr %arrayidx.prol, align 4
2751 ; PROLOG-NEXT: %add.prol = add nsw i32 %2, %sum.02.prol
2752 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
2753 ; PROLOG-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa.loopexit2, label %latch.prol
2754 ; PROLOG: latch.prol:
2755 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
2756 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
2757 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
2758 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
2759 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !7
2760 ; PROLOG: header.prol.loopexit.unr-lcssa:
2761 ; PROLOG-NEXT: %result.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2762 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
2763 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
2764 ; PROLOG-NEXT: br label %header.prol.loopexit
2765 ; PROLOG: header.prol.loopexit:
2766 ; PROLOG-NEXT: %result.unr = phi i32 [ poison, %entry ], [ %result.unr.ph, %header.prol.loopexit.unr-lcssa ]
2767 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
2768 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
2769 ; PROLOG-NEXT: %3 = icmp ult i64 %1, 7
2770 ; PROLOG-NEXT: br i1 %3, label %latchExit, label %entry.new
2771 ; PROLOG: entry.new:
2772 ; PROLOG-NEXT: br label %header
2774 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
2775 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
2776 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2777 ; PROLOG: for.exiting_block:
2778 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2779 ; PROLOG-NEXT: %4 = load i32, ptr %arrayidx, align 4
2780 ; PROLOG-NEXT: %add = add nsw i32 %4, %sum.02
2781 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
2782 ; PROLOG-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2784 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2785 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2786 ; PROLOG: for.exiting_block.1:
2787 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
2788 ; PROLOG-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
2789 ; PROLOG-NEXT: %add.1 = add nsw i32 %5, %add
2790 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
2791 ; PROLOG-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2793 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
2794 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.2
2795 ; PROLOG: for.exiting_block.2:
2796 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
2797 ; PROLOG-NEXT: %6 = load i32, ptr %arrayidx.2, align 4
2798 ; PROLOG-NEXT: %add.2 = add nsw i32 %6, %add.1
2799 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
2800 ; PROLOG-NEXT: br i1 %cmp.2, label %latchExit.unr-lcssa.loopexit, label %latch.2
2802 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv, 3
2803 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.3
2804 ; PROLOG: for.exiting_block.3:
2805 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
2806 ; PROLOG-NEXT: %7 = load i32, ptr %arrayidx.3, align 4
2807 ; PROLOG-NEXT: %add.3 = add nsw i32 %7, %add.2
2808 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
2809 ; PROLOG-NEXT: br i1 %cmp.3, label %latchExit.unr-lcssa.loopexit, label %latch.3
2811 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv, 4
2812 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.4
2813 ; PROLOG: for.exiting_block.4:
2814 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
2815 ; PROLOG-NEXT: %8 = load i32, ptr %arrayidx.4, align 4
2816 ; PROLOG-NEXT: %add.4 = add nsw i32 %8, %add.3
2817 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
2818 ; PROLOG-NEXT: br i1 %cmp.4, label %latchExit.unr-lcssa.loopexit, label %latch.4
2820 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv, 5
2821 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.5
2822 ; PROLOG: for.exiting_block.5:
2823 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
2824 ; PROLOG-NEXT: %9 = load i32, ptr %arrayidx.5, align 4
2825 ; PROLOG-NEXT: %add.5 = add nsw i32 %9, %add.4
2826 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
2827 ; PROLOG-NEXT: br i1 %cmp.5, label %latchExit.unr-lcssa.loopexit, label %latch.5
2829 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv, 6
2830 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.6
2831 ; PROLOG: for.exiting_block.6:
2832 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
2833 ; PROLOG-NEXT: %10 = load i32, ptr %arrayidx.6, align 4
2834 ; PROLOG-NEXT: %add.6 = add nsw i32 %10, %add.5
2835 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
2836 ; PROLOG-NEXT: br i1 %cmp.6, label %latchExit.unr-lcssa.loopexit, label %latch.6
2838 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv, 7
2839 ; PROLOG-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.7
2840 ; PROLOG: for.exiting_block.7:
2841 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
2842 ; PROLOG-NEXT: %11 = load i32, ptr %arrayidx.7, align 4
2843 ; PROLOG-NEXT: %add.7 = add nsw i32 %11, %add.6
2844 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
2845 ; PROLOG-NEXT: br i1 %cmp.7, label %latchExit.unr-lcssa.loopexit, label %latch.7
2847 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
2848 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
2849 ; PROLOG-NEXT: br i1 %exitcond.7, label %latchExit.unr-lcssa.loopexit, label %header
2850 ; PROLOG: latchExit.unr-lcssa.loopexit:
2851 ; 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 ]
2852 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2853 ; PROLOG: latchExit.unr-lcssa.loopexit2:
2854 ; PROLOG-NEXT: %result.ph.ph3 = phi i32 [ %sum.02.prol, %for.exiting_block.prol ]
2855 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
2856 ; PROLOG: latchExit.unr-lcssa:
2857 ; PROLOG-NEXT: %result.ph = phi i32 [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %result.ph.ph3, %latchExit.unr-lcssa.loopexit2 ]
2858 ; PROLOG-NEXT: br label %latchExit
2859 ; PROLOG: latchExit:
2860 ; PROLOG-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2861 ; PROLOG-NEXT: ret i32 %result
2862 ; PROLOG: for.exit2.loopexit:
2863 ; PROLOG-NEXT: br label %for.exit2
2864 ; PROLOG: for.exit2.loopexit1:
2865 ; PROLOG-NEXT: br label %for.exit2
2866 ; PROLOG: for.exit2:
2867 ; PROLOG-NEXT: ret i32 42
2869 ; PROLOG-BLOCK-LABEL: @otherblock_latch_same_exit3(
2870 ; PROLOG-BLOCK-NEXT: entry:
2871 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
2872 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
2873 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
2874 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
2875 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
2876 ; PROLOG-BLOCK: header.prol.preheader:
2877 ; PROLOG-BLOCK-NEXT: br label %header.prol
2878 ; PROLOG-BLOCK: header.prol:
2879 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2, label %for.exiting_block.prol
2880 ; PROLOG-BLOCK: for.exiting_block.prol:
2881 ; PROLOG-BLOCK-NEXT: %2 = load i32, ptr %a, align 4
2882 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
2883 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %latchExit.unr-lcssa, label %latch.prol
2884 ; PROLOG-BLOCK: latch.prol:
2885 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
2886 ; PROLOG-BLOCK: header.prol.loopexit:
2887 ; PROLOG-BLOCK-NEXT: %result.unr = phi i32 [ poison, %entry ], [ %2, %latch.prol ]
2888 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
2889 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %2, %latch.prol ]
2890 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %1, 1
2891 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchExit, label %entry.new
2892 ; PROLOG-BLOCK: entry.new:
2893 ; PROLOG-BLOCK-NEXT: br label %header
2894 ; PROLOG-BLOCK: header:
2895 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
2896 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
2897 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block
2898 ; PROLOG-BLOCK: for.exiting_block:
2899 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2900 ; PROLOG-BLOCK-NEXT: %4 = load i32, ptr %arrayidx, align 4
2901 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %4, %sum.02
2902 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
2903 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %latchExit.unr-lcssa.loopexit, label %latch
2904 ; PROLOG-BLOCK: latch:
2905 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
2906 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %for.exit2.loopexit, label %for.exiting_block.1
2907 ; PROLOG-BLOCK: for.exiting_block.1:
2908 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
2909 ; PROLOG-BLOCK-NEXT: %5 = load i32, ptr %arrayidx.1, align 4
2910 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %5, %add
2911 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
2912 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %latchExit.unr-lcssa.loopexit, label %latch.1
2913 ; PROLOG-BLOCK: latch.1:
2914 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
2915 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
2916 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latchExit.unr-lcssa.loopexit, label %header, !llvm.loop !7
2917 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
2918 ; PROLOG-BLOCK-NEXT: %result.ph.ph = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %for.exiting_block.1 ], [ %add.1, %latch.1 ]
2919 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
2920 ; PROLOG-BLOCK: latchExit.unr-lcssa:
2921 ; PROLOG-BLOCK-NEXT: %result.ph = phi i32 [ 0, %for.exiting_block.prol ], [ %result.ph.ph, %latchExit.unr-lcssa.loopexit ]
2922 ; PROLOG-BLOCK-NEXT: br label %latchExit
2923 ; PROLOG-BLOCK: latchExit:
2924 ; PROLOG-BLOCK-NEXT: %result = phi i32 [ %result.unr, %header.prol.loopexit ], [ %result.ph, %latchExit.unr-lcssa ]
2925 ; PROLOG-BLOCK-NEXT: ret i32 %result
2926 ; PROLOG-BLOCK: for.exit2.loopexit:
2927 ; PROLOG-BLOCK-NEXT: br label %for.exit2
2928 ; PROLOG-BLOCK: for.exit2:
2929 ; PROLOG-BLOCK-NEXT: ret i32 42
2936 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
2937 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
2938 br i1 %cond, label %for.exit2, label %for.exiting_block
2941 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
2942 %0 = load i32, ptr %arrayidx, align 4
2943 %add = add nsw i32 %0, %sum.02
2944 %cmp = icmp eq i64 %n, 42
2945 br i1 %cmp, label %latchExit, label %latch
2947 latch: ; preds = %latch, %entry
2948 %indvars.iv.next = add i64 %indvars.iv, 1
2949 %exitcond = icmp eq i64 %indvars.iv.next, %n
2950 br i1 %exitcond, label %latchExit, label %header
2952 latchExit: ; preds = %latch, %entry
2953 %result = phi i32 [ %sum.02, %for.exiting_block ], [ %add, %latch ]
2960 ; Show a case where we have multiple exits, but (provably) exit on the
2961 ; first iteration and thus have nothing to unroll
2962 define void @non_loop(i32 %arg) {
2963 ; CHECK-LABEL: @non_loop(
2964 ; CHECK-NEXT: entry:
2965 ; CHECK-NEXT: %i = icmp sgt i32 undef, %arg
2966 ; CHECK-NEXT: br i1 %i, label %preheader, label %returnblock
2968 ; CHECK-NEXT: br label %header
2970 ; CHECK-NEXT: br i1 true, label %latchExit, label %latch
2972 ; CHECK-NEXT: br label %latchExit
2974 ; CHECK-NEXT: %i2.ph = phi i32 [ %arg, %header ], [ -1, %latch ]
2975 ; CHECK-NEXT: br label %returnblock
2976 ; CHECK: returnblock:
2977 ; CHECK-NEXT: %i2 = phi i32 [ -1, %entry ], [ %i2.ph, %latchExit ]
2978 ; CHECK-NEXT: ret void
2982 %i = icmp sgt i32 undef, %arg
2983 br i1 %i, label %preheader, label %returnblock
2985 preheader: ; preds = %entry
2988 header: ; preds = %preheader, %latch
2989 %i4 = phi i32 [ %inc, %latch ], [ %arg, %preheader ]
2990 %inc = add nsw i32 %i4, 1
2991 br i1 true, label %latchExit, label %latch
2993 latch: ; preds = %header
2994 %cmp = icmp slt i32 %inc, undef
2995 br i1 %cmp, label %header, label %latchExit
2997 latchExit: ; preds = %header, %latch
2998 %i2.ph = phi i32 [ %i4, %header ], [ -1, %latch ]
2999 br label %returnblock
3001 returnblock: ; preds = %latchExit, %entry
3002 %i2 = phi i32 [ -1, %entry ], [ %i2.ph, %latchExit ]
3006 ; Latch exit is shared by all exiting blocks
3007 define void @unique_exit(i32 %N, i32 %M) {
3008 ; EPILOG-LABEL: @unique_exit(
3009 ; EPILOG-NEXT: preheader:
3010 ; EPILOG-NEXT: %M.shifted = shl i32 %M, 3
3011 ; EPILOG-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3012 ; EPILOG-NEXT: %0 = freeze i32 %umax
3013 ; EPILOG-NEXT: %1 = add i32 %0, -1
3014 ; EPILOG-NEXT: %xtraiter = and i32 %0, 7
3015 ; EPILOG-NEXT: %2 = icmp ult i32 %1, 7
3016 ; EPILOG-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %preheader.new
3017 ; EPILOG: preheader.new:
3018 ; EPILOG-NEXT: %unroll_iter = sub i32 %0, %xtraiter
3019 ; EPILOG-NEXT: br label %header
3021 ; EPILOG-NEXT: %i4 = phi i32 [ 0, %preheader.new ], [ %inc.7, %latch.7 ]
3022 ; EPILOG-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.7, %latch.7 ]
3023 ; EPILOG-NEXT: %inc = add nuw nsw i32 %i4, 1
3024 ; EPILOG-NEXT: %cmp1 = icmp ult i32 %inc, %N
3025 ; EPILOG-NEXT: br i1 %cmp1, label %latch, label %latchExit.epilog-lcssa.loopexit
3027 ; EPILOG-NEXT: %inc.1 = add nuw nsw i32 %i4, 2
3028 ; EPILOG-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3029 ; EPILOG-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.epilog-lcssa.loopexit
3031 ; EPILOG-NEXT: %inc.2 = add nuw nsw i32 %i4, 3
3032 ; EPILOG-NEXT: %cmp1.2 = icmp ult i32 %inc.2, %N
3033 ; EPILOG-NEXT: br i1 %cmp1.2, label %latch.2, label %latchExit.epilog-lcssa.loopexit
3035 ; EPILOG-NEXT: %inc.3 = add nuw nsw i32 %i4, 4
3036 ; EPILOG-NEXT: %cmp1.3 = icmp ult i32 %inc.3, %N
3037 ; EPILOG-NEXT: br i1 %cmp1.3, label %latch.3, label %latchExit.epilog-lcssa.loopexit
3039 ; EPILOG-NEXT: %inc.4 = add nuw nsw i32 %i4, 5
3040 ; EPILOG-NEXT: %cmp1.4 = icmp ult i32 %inc.4, %N
3041 ; EPILOG-NEXT: br i1 %cmp1.4, label %latch.4, label %latchExit.epilog-lcssa.loopexit
3043 ; EPILOG-NEXT: %inc.5 = add nuw nsw i32 %i4, 6
3044 ; EPILOG-NEXT: %cmp1.5 = icmp ult i32 %inc.5, %N
3045 ; EPILOG-NEXT: br i1 %cmp1.5, label %latch.5, label %latchExit.epilog-lcssa.loopexit
3047 ; EPILOG-NEXT: %inc.6 = add nuw nsw i32 %i4, 7
3048 ; EPILOG-NEXT: %cmp1.6 = icmp ult i32 %inc.6, %N
3049 ; EPILOG-NEXT: br i1 %cmp1.6, label %latch.6, label %latchExit.epilog-lcssa.loopexit
3051 ; EPILOG-NEXT: %inc.7 = add nuw i32 %i4, 8
3052 ; EPILOG-NEXT: %cmp1.7 = icmp ult i32 %inc.7, %N
3053 ; EPILOG-NEXT: br i1 %cmp1.7, label %latch.7, label %latchExit.epilog-lcssa.loopexit
3055 ; EPILOG-NEXT: %niter.next.7 = add nuw i32 %niter, 8
3056 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i32 %niter.next.7, %unroll_iter
3057 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %header, label %latchExit.unr-lcssa.loopexit
3058 ; EPILOG: latchExit.unr-lcssa.loopexit:
3059 ; EPILOG-NEXT: %i2.ph.ph.ph = phi i32 [ -1, %latch.7 ]
3060 ; EPILOG-NEXT: %i4.unr.ph = phi i32 [ %inc.7, %latch.7 ]
3061 ; EPILOG-NEXT: br label %latchExit.unr-lcssa
3062 ; EPILOG: latchExit.unr-lcssa:
3063 ; EPILOG-NEXT: %i2.ph.ph = phi i32 [ poison, %preheader ], [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ]
3064 ; EPILOG-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ %i4.unr.ph, %latchExit.unr-lcssa.loopexit ]
3065 ; EPILOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3066 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
3067 ; EPILOG: header.epil.preheader:
3068 ; EPILOG-NEXT: br label %header.epil
3069 ; EPILOG: header.epil:
3070 ; EPILOG-NEXT: %i4.epil = phi i32 [ %inc.epil, %latch.epil ], [ %i4.unr, %header.epil.preheader ]
3071 ; EPILOG-NEXT: %epil.iter = phi i32 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
3072 ; EPILOG-NEXT: %inc.epil = add nuw i32 %i4.epil, 1
3073 ; EPILOG-NEXT: %cmp1.epil = icmp ult i32 %inc.epil, %N
3074 ; EPILOG-NEXT: br i1 %cmp1.epil, label %latch.epil, label %latchExit.epilog-lcssa.loopexit2
3075 ; EPILOG: latch.epil:
3076 ; EPILOG-NEXT: %cmp.epil = icmp ult i32 %inc.epil, %M.shifted
3077 ; EPILOG-NEXT: %epil.iter.next = add i32 %epil.iter, 1
3078 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i32 %epil.iter.next, %xtraiter
3079 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchExit.epilog-lcssa.loopexit2, !llvm.loop !8
3080 ; EPILOG: latchExit.epilog-lcssa.loopexit:
3081 ; 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 ]
3082 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
3083 ; EPILOG: latchExit.epilog-lcssa.loopexit2:
3084 ; EPILOG-NEXT: %i2.ph.ph1.ph3 = phi i32 [ %i4.epil, %header.epil ], [ -1, %latch.epil ]
3085 ; EPILOG-NEXT: br label %latchExit.epilog-lcssa
3086 ; EPILOG: latchExit.epilog-lcssa:
3087 ; EPILOG-NEXT: %i2.ph.ph1 = phi i32 [ %i2.ph.ph1.ph, %latchExit.epilog-lcssa.loopexit ], [ %i2.ph.ph1.ph3, %latchExit.epilog-lcssa.loopexit2 ]
3088 ; EPILOG-NEXT: br label %latchExit
3089 ; EPILOG: latchExit:
3090 ; EPILOG-NEXT: %i2.ph = phi i32 [ %i2.ph.ph, %latchExit.unr-lcssa ], [ %i2.ph.ph1, %latchExit.epilog-lcssa ]
3091 ; EPILOG-NEXT: ret void
3093 ; EPILOG-BLOCK-LABEL: @unique_exit(
3094 ; EPILOG-BLOCK-NEXT: preheader:
3095 ; EPILOG-BLOCK-NEXT: %M.shifted = shl i32 %M, 3
3096 ; EPILOG-BLOCK-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3097 ; EPILOG-BLOCK-NEXT: %0 = freeze i32 %umax
3098 ; EPILOG-BLOCK-NEXT: %1 = add i32 %0, -1
3099 ; EPILOG-BLOCK-NEXT: %xtraiter = and i32 %0, 1
3100 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i32 %1, 1
3101 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchExit.unr-lcssa, label %preheader.new
3102 ; EPILOG-BLOCK: preheader.new:
3103 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i32 %0, %xtraiter
3104 ; EPILOG-BLOCK-NEXT: br label %header
3105 ; EPILOG-BLOCK: header:
3106 ; EPILOG-BLOCK-NEXT: %i4 = phi i32 [ 0, %preheader.new ], [ %inc.1, %latch.1 ]
3107 ; EPILOG-BLOCK-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.1, %latch.1 ]
3108 ; EPILOG-BLOCK-NEXT: %inc = add nuw nsw i32 %i4, 1
3109 ; EPILOG-BLOCK-NEXT: %cmp1 = icmp ult i32 %inc, %N
3110 ; EPILOG-BLOCK-NEXT: br i1 %cmp1, label %latch, label %latchExit.epilog-lcssa.loopexit
3111 ; EPILOG-BLOCK: latch:
3112 ; EPILOG-BLOCK-NEXT: %inc.1 = add nuw i32 %i4, 2
3113 ; EPILOG-BLOCK-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3114 ; EPILOG-BLOCK-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.epilog-lcssa.loopexit
3115 ; EPILOG-BLOCK: latch.1:
3116 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add nuw i32 %niter, 2
3117 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i32 %niter.next.1, %unroll_iter
3118 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %header, label %latchExit.unr-lcssa.loopexit, !llvm.loop !8
3119 ; EPILOG-BLOCK: latchExit.unr-lcssa.loopexit:
3120 ; EPILOG-BLOCK-NEXT: %i2.ph.ph.ph = phi i32 [ -1, %latch.1 ]
3121 ; EPILOG-BLOCK-NEXT: %i4.unr.ph = phi i32 [ %inc.1, %latch.1 ]
3122 ; EPILOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
3123 ; EPILOG-BLOCK: latchExit.unr-lcssa:
3124 ; EPILOG-BLOCK-NEXT: %i2.ph.ph = phi i32 [ poison, %preheader ], [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ]
3125 ; EPILOG-BLOCK-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ %i4.unr.ph, %latchExit.unr-lcssa.loopexit ]
3126 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3127 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchExit
3128 ; EPILOG-BLOCK: header.epil.preheader:
3129 ; EPILOG-BLOCK-NEXT: br label %header.epil
3130 ; EPILOG-BLOCK: header.epil:
3131 ; EPILOG-BLOCK-NEXT: %inc.epil = add nuw i32 %i4.unr, 1
3132 ; EPILOG-BLOCK-NEXT: %cmp1.epil = icmp ult i32 %inc.epil, %N
3133 ; EPILOG-BLOCK-NEXT: br i1 %cmp1.epil, label %latch.epil, label %latchExit.epilog-lcssa
3134 ; EPILOG-BLOCK: latch.epil:
3135 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
3136 ; EPILOG-BLOCK: latchExit.epilog-lcssa.loopexit:
3137 ; EPILOG-BLOCK-NEXT: %i2.ph.ph1.ph = phi i32 [ %i4, %header ], [ %inc, %latch ]
3138 ; EPILOG-BLOCK-NEXT: br label %latchExit.epilog-lcssa
3139 ; EPILOG-BLOCK: latchExit.epilog-lcssa:
3140 ; EPILOG-BLOCK-NEXT: %i2.ph.ph1 = phi i32 [ -1, %latch.epil ], [ %i4.unr, %header.epil ], [ %i2.ph.ph1.ph, %latchExit.epilog-lcssa.loopexit ]
3141 ; EPILOG-BLOCK-NEXT: br label %latchExit
3142 ; EPILOG-BLOCK: latchExit:
3143 ; EPILOG-BLOCK-NEXT: %i2.ph = phi i32 [ %i2.ph.ph, %latchExit.unr-lcssa ], [ %i2.ph.ph1, %latchExit.epilog-lcssa ]
3144 ; EPILOG-BLOCK-NEXT: ret void
3146 ; PROLOG-LABEL: @unique_exit(
3147 ; PROLOG-NEXT: preheader:
3148 ; PROLOG-NEXT: %M.shifted = shl i32 %M, 3
3149 ; PROLOG-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3150 ; PROLOG-NEXT: %0 = freeze i32 %umax
3151 ; PROLOG-NEXT: %1 = add i32 %0, -1
3152 ; PROLOG-NEXT: %xtraiter = and i32 %0, 7
3153 ; PROLOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3154 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
3155 ; PROLOG: header.prol.preheader:
3156 ; PROLOG-NEXT: br label %header.prol
3157 ; PROLOG: header.prol:
3158 ; PROLOG-NEXT: %i4.prol = phi i32 [ %inc.prol, %latch.prol ], [ 0, %header.prol.preheader ]
3159 ; PROLOG-NEXT: %prol.iter = phi i32 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
3160 ; PROLOG-NEXT: %inc.prol = add nuw i32 %i4.prol, 1
3161 ; PROLOG-NEXT: %cmp1.prol = icmp ult i32 %inc.prol, %N
3162 ; PROLOG-NEXT: br i1 %cmp1.prol, label %latch.prol, label %latchExit.unr-lcssa.loopexit1
3163 ; PROLOG: latch.prol:
3164 ; PROLOG-NEXT: %cmp.prol = icmp ult i32 %inc.prol, %M.shifted
3165 ; PROLOG-NEXT: %prol.iter.next = add i32 %prol.iter, 1
3166 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i32 %prol.iter.next, %xtraiter
3167 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !8
3168 ; PROLOG: header.prol.loopexit.unr-lcssa:
3169 ; PROLOG-NEXT: %i4.unr.ph = phi i32 [ %inc.prol, %latch.prol ]
3170 ; PROLOG-NEXT: %i2.ph.unr.ph = phi i32 [ -1, %latch.prol ]
3171 ; PROLOG-NEXT: br label %header.prol.loopexit
3172 ; PROLOG: header.prol.loopexit:
3173 ; PROLOG-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ %i4.unr.ph, %header.prol.loopexit.unr-lcssa ]
3174 ; PROLOG-NEXT: %i2.ph.unr = phi i32 [ poison, %preheader ], [ %i2.ph.unr.ph, %header.prol.loopexit.unr-lcssa ]
3175 ; PROLOG-NEXT: %2 = icmp ult i32 %1, 7
3176 ; PROLOG-NEXT: br i1 %2, label %latchExit, label %preheader.new
3177 ; PROLOG: preheader.new:
3178 ; PROLOG-NEXT: br label %header
3180 ; PROLOG-NEXT: %i4 = phi i32 [ %i4.unr, %preheader.new ], [ %inc.7, %latch.7 ]
3181 ; PROLOG-NEXT: %inc = add nuw i32 %i4, 1
3182 ; PROLOG-NEXT: %cmp1 = icmp ult i32 %inc, %N
3183 ; PROLOG-NEXT: br i1 %cmp1, label %latch, label %latchExit.unr-lcssa.loopexit
3185 ; PROLOG-NEXT: %inc.1 = add nuw i32 %i4, 2
3186 ; PROLOG-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3187 ; PROLOG-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.unr-lcssa.loopexit
3189 ; PROLOG-NEXT: %inc.2 = add nuw i32 %i4, 3
3190 ; PROLOG-NEXT: %cmp1.2 = icmp ult i32 %inc.2, %N
3191 ; PROLOG-NEXT: br i1 %cmp1.2, label %latch.2, label %latchExit.unr-lcssa.loopexit
3193 ; PROLOG-NEXT: %inc.3 = add nuw i32 %i4, 4
3194 ; PROLOG-NEXT: %cmp1.3 = icmp ult i32 %inc.3, %N
3195 ; PROLOG-NEXT: br i1 %cmp1.3, label %latch.3, label %latchExit.unr-lcssa.loopexit
3197 ; PROLOG-NEXT: %inc.4 = add nuw i32 %i4, 5
3198 ; PROLOG-NEXT: %cmp1.4 = icmp ult i32 %inc.4, %N
3199 ; PROLOG-NEXT: br i1 %cmp1.4, label %latch.4, label %latchExit.unr-lcssa.loopexit
3201 ; PROLOG-NEXT: %inc.5 = add nuw i32 %i4, 6
3202 ; PROLOG-NEXT: %cmp1.5 = icmp ult i32 %inc.5, %N
3203 ; PROLOG-NEXT: br i1 %cmp1.5, label %latch.5, label %latchExit.unr-lcssa.loopexit
3205 ; PROLOG-NEXT: %inc.6 = add nuw i32 %i4, 7
3206 ; PROLOG-NEXT: %cmp1.6 = icmp ult i32 %inc.6, %N
3207 ; PROLOG-NEXT: br i1 %cmp1.6, label %latch.6, label %latchExit.unr-lcssa.loopexit
3209 ; PROLOG-NEXT: %inc.7 = add nuw i32 %i4, 8
3210 ; PROLOG-NEXT: %cmp1.7 = icmp ult i32 %inc.7, %N
3211 ; PROLOG-NEXT: br i1 %cmp1.7, label %latch.7, label %latchExit.unr-lcssa.loopexit
3213 ; PROLOG-NEXT: %cmp.7 = icmp ult i32 %inc.7, %M.shifted
3214 ; PROLOG-NEXT: br i1 %cmp.7, label %header, label %latchExit.unr-lcssa.loopexit
3215 ; PROLOG: latchExit.unr-lcssa.loopexit:
3216 ; 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 ]
3217 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
3218 ; PROLOG: latchExit.unr-lcssa.loopexit1:
3219 ; PROLOG-NEXT: %i2.ph.ph.ph2 = phi i32 [ %i4.prol, %header.prol ]
3220 ; PROLOG-NEXT: br label %latchExit.unr-lcssa
3221 ; PROLOG: latchExit.unr-lcssa:
3222 ; PROLOG-NEXT: %i2.ph.ph = phi i32 [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ], [ %i2.ph.ph.ph2, %latchExit.unr-lcssa.loopexit1 ]
3223 ; PROLOG-NEXT: br label %latchExit
3224 ; PROLOG: latchExit:
3225 ; PROLOG-NEXT: %i2.ph = phi i32 [ %i2.ph.unr, %header.prol.loopexit ], [ %i2.ph.ph, %latchExit.unr-lcssa ]
3226 ; PROLOG-NEXT: ret void
3228 ; PROLOG-BLOCK-LABEL: @unique_exit(
3229 ; PROLOG-BLOCK-NEXT: preheader:
3230 ; PROLOG-BLOCK-NEXT: %M.shifted = shl i32 %M, 3
3231 ; PROLOG-BLOCK-NEXT: %umax = call i32 @llvm.umax.i32(i32 %M.shifted, i32 1)
3232 ; PROLOG-BLOCK-NEXT: %0 = freeze i32 %umax
3233 ; PROLOG-BLOCK-NEXT: %1 = add i32 %0, -1
3234 ; PROLOG-BLOCK-NEXT: %xtraiter = and i32 %0, 1
3235 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
3236 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
3237 ; PROLOG-BLOCK: header.prol.preheader:
3238 ; PROLOG-BLOCK-NEXT: br label %header.prol
3239 ; PROLOG-BLOCK: header.prol:
3240 ; PROLOG-BLOCK-NEXT: %cmp1.prol = icmp ult i32 1, %N
3241 ; PROLOG-BLOCK-NEXT: br i1 %cmp1.prol, label %latch.prol, label %latchExit.unr-lcssa
3242 ; PROLOG-BLOCK: latch.prol:
3243 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
3244 ; PROLOG-BLOCK: header.prol.loopexit:
3245 ; PROLOG-BLOCK-NEXT: %i4.unr = phi i32 [ 0, %preheader ], [ 1, %latch.prol ]
3246 ; PROLOG-BLOCK-NEXT: %i2.ph.unr = phi i32 [ poison, %preheader ], [ -1, %latch.prol ]
3247 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i32 %1, 1
3248 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latchExit, label %preheader.new
3249 ; PROLOG-BLOCK: preheader.new:
3250 ; PROLOG-BLOCK-NEXT: br label %header
3251 ; PROLOG-BLOCK: header:
3252 ; PROLOG-BLOCK-NEXT: %i4 = phi i32 [ %i4.unr, %preheader.new ], [ %inc.1, %latch.1 ]
3253 ; PROLOG-BLOCK-NEXT: %inc = add nuw i32 %i4, 1
3254 ; PROLOG-BLOCK-NEXT: %cmp1 = icmp ult i32 %inc, %N
3255 ; PROLOG-BLOCK-NEXT: br i1 %cmp1, label %latch, label %latchExit.unr-lcssa.loopexit
3256 ; PROLOG-BLOCK: latch:
3257 ; PROLOG-BLOCK-NEXT: %inc.1 = add nuw i32 %i4, 2
3258 ; PROLOG-BLOCK-NEXT: %cmp1.1 = icmp ult i32 %inc.1, %N
3259 ; PROLOG-BLOCK-NEXT: br i1 %cmp1.1, label %latch.1, label %latchExit.unr-lcssa.loopexit
3260 ; PROLOG-BLOCK: latch.1:
3261 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ult i32 %inc.1, %M.shifted
3262 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %header, label %latchExit.unr-lcssa.loopexit, !llvm.loop !8
3263 ; PROLOG-BLOCK: latchExit.unr-lcssa.loopexit:
3264 ; PROLOG-BLOCK-NEXT: %i2.ph.ph.ph = phi i32 [ %i4, %header ], [ %inc, %latch ], [ -1, %latch.1 ]
3265 ; PROLOG-BLOCK-NEXT: br label %latchExit.unr-lcssa
3266 ; PROLOG-BLOCK: latchExit.unr-lcssa:
3267 ; PROLOG-BLOCK-NEXT: %i2.ph.ph = phi i32 [ 0, %header.prol ], [ %i2.ph.ph.ph, %latchExit.unr-lcssa.loopexit ]
3268 ; PROLOG-BLOCK-NEXT: br label %latchExit
3269 ; PROLOG-BLOCK: latchExit:
3270 ; PROLOG-BLOCK-NEXT: %i2.ph = phi i32 [ %i2.ph.unr, %header.prol.loopexit ], [ %i2.ph.ph, %latchExit.unr-lcssa ]
3271 ; PROLOG-BLOCK-NEXT: ret void
3275 %M.shifted = shl nuw i32 %M, 3
3278 header: ; preds = %preheader, %latch
3279 %i4 = phi i32 [ %inc, %latch ], [ 0, %preheader ]
3280 %inc = add nuw i32 %i4, 1
3281 %cmp1 = icmp ult i32 %inc, %N
3282 br i1 %cmp1, label %latch, label %latchExit
3284 latch: ; preds = %header
3285 %cmp = icmp ult i32 %inc, %M.shifted
3286 br i1 %cmp, label %header, label %latchExit
3288 latchExit: ; preds = %header, %latch
3289 %i2.ph = phi i32 [ %i4, %header ], [ -1, %latch ]
3294 ; two exiting and two exit blocks.
3295 ; the non-latch exiting block has duplicate edges to the non-latch exit block.
3296 define i64 @test5(i64 %trip, i64 %add, i1 %cond) {
3297 ; EPILOG-LABEL: @test5(
3298 ; EPILOG-NEXT: entry:
3299 ; EPILOG-NEXT: %0 = freeze i64 %trip
3300 ; EPILOG-NEXT: %1 = add i64 %0, -1
3301 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
3302 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
3303 ; EPILOG-NEXT: br i1 %2, label %latchexit.unr-lcssa, label %entry.new
3304 ; EPILOG: entry.new:
3305 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
3306 ; EPILOG-NEXT: br label %loop_header
3307 ; EPILOG: loop_header:
3308 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
3309 ; EPILOG-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
3310 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
3311 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3312 ; EPILOG: loop_exiting:
3313 ; EPILOG-NEXT: %ivy = add i64 %iv, %add
3314 ; EPILOG-NEXT: switch i64 %sum, label %loop_latch [
3315 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3316 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3318 ; EPILOG: loop_latch:
3319 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3320 ; EPILOG-NEXT: %sum.next = add i64 %sum, %add
3321 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3322 ; EPILOG: loop_exiting.1:
3323 ; EPILOG-NEXT: %ivy.1 = add i64 %iv_next, %add
3324 ; EPILOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3325 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3326 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3328 ; EPILOG: loop_latch.1:
3329 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv, 2
3330 ; EPILOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
3331 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting.2
3332 ; EPILOG: loop_exiting.2:
3333 ; EPILOG-NEXT: %ivy.2 = add i64 %iv_next.1, %add
3334 ; EPILOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
3335 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3336 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3338 ; EPILOG: loop_latch.2:
3339 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv, 3
3340 ; EPILOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
3341 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting.3
3342 ; EPILOG: loop_exiting.3:
3343 ; EPILOG-NEXT: %ivy.3 = add i64 %iv_next.2, %add
3344 ; EPILOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
3345 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3346 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3348 ; EPILOG: loop_latch.3:
3349 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv, 4
3350 ; EPILOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
3351 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting.4
3352 ; EPILOG: loop_exiting.4:
3353 ; EPILOG-NEXT: %ivy.4 = add i64 %iv_next.3, %add
3354 ; EPILOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
3355 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3356 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3358 ; EPILOG: loop_latch.4:
3359 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv, 5
3360 ; EPILOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
3361 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting.5
3362 ; EPILOG: loop_exiting.5:
3363 ; EPILOG-NEXT: %ivy.5 = add i64 %iv_next.4, %add
3364 ; EPILOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
3365 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3366 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3368 ; EPILOG: loop_latch.5:
3369 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv, 6
3370 ; EPILOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
3371 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting.6
3372 ; EPILOG: loop_exiting.6:
3373 ; EPILOG-NEXT: %ivy.6 = add i64 %iv_next.5, %add
3374 ; EPILOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
3375 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3376 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3378 ; EPILOG: loop_latch.6:
3379 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv, 7
3380 ; EPILOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
3381 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting.7
3382 ; EPILOG: loop_exiting.7:
3383 ; EPILOG-NEXT: %ivy.7 = add i64 %iv_next.6, %add
3384 ; EPILOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
3385 ; EPILOG-NEXT: i64 24, label %exit1.loopexit
3386 ; EPILOG-NEXT: i64 42, label %exit1.loopexit
3388 ; EPILOG: loop_latch.7:
3389 ; EPILOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv, 8
3390 ; EPILOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
3391 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
3392 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
3393 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %latchexit.unr-lcssa.loopexit
3394 ; EPILOG: exit1.loopexit:
3395 ; 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 ]
3396 ; EPILOG-NEXT: br label %exit1
3397 ; EPILOG: exit1.loopexit2:
3398 ; EPILOG-NEXT: %result.ph3 = phi i64 [ %ivy.epil, %loop_exiting.epil ], [ %ivy.epil, %loop_exiting.epil ]
3399 ; EPILOG-NEXT: br label %exit1
3401 ; EPILOG-NEXT: %result = phi i64 [ %result.ph, %exit1.loopexit ], [ %result.ph3, %exit1.loopexit2 ]
3402 ; EPILOG-NEXT: ret i64 %result
3403 ; EPILOG: latchexit.unr-lcssa.loopexit:
3404 ; EPILOG-NEXT: %sum.next.lcssa.ph.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
3405 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
3406 ; EPILOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
3407 ; EPILOG-NEXT: br label %latchexit.unr-lcssa
3408 ; EPILOG: latchexit.unr-lcssa:
3409 ; EPILOG-NEXT: %sum.next.lcssa.ph = phi i64 [ poison, %entry ], [ %sum.next.lcssa.ph.ph, %latchexit.unr-lcssa.loopexit ]
3410 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %latchexit.unr-lcssa.loopexit ]
3411 ; EPILOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %latchexit.unr-lcssa.loopexit ]
3412 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3413 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %latchexit
3414 ; EPILOG: loop_header.epil.preheader:
3415 ; EPILOG-NEXT: br label %loop_header.epil
3416 ; EPILOG: loop_header.epil:
3417 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
3418 ; EPILOG-NEXT: %sum.epil = phi i64 [ %sum.unr, %loop_header.epil.preheader ], [ %sum.next.epil, %loop_latch.epil ]
3419 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
3420 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting.epil
3421 ; EPILOG: loop_exiting.epil:
3422 ; EPILOG-NEXT: %ivy.epil = add i64 %iv.epil, %add
3423 ; EPILOG-NEXT: switch i64 %sum.epil, label %loop_latch.epil [
3424 ; EPILOG-NEXT: i64 24, label %exit1.loopexit2
3425 ; EPILOG-NEXT: i64 42, label %exit1.loopexit2
3427 ; EPILOG: loop_latch.epil:
3428 ; EPILOG-NEXT: %iv_next.epil = add nuw nsw i64 %iv.epil, 1
3429 ; EPILOG-NEXT: %sum.next.epil = add i64 %sum.epil, %add
3430 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
3431 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
3432 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
3433 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %latchexit.epilog-lcssa, !llvm.loop !9
3434 ; EPILOG: latchexit.epilog-lcssa:
3435 ; EPILOG-NEXT: %sum.next.lcssa.ph1 = phi i64 [ %sum.next.epil, %loop_latch.epil ]
3436 ; EPILOG-NEXT: br label %latchexit
3437 ; EPILOG: latchexit:
3438 ; EPILOG-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ], [ %sum.next.lcssa.ph1, %latchexit.epilog-lcssa ]
3439 ; EPILOG-NEXT: ret i64 %sum.next.lcssa
3441 ; EPILOG-BLOCK-LABEL: @test5(
3442 ; EPILOG-BLOCK-NEXT: entry:
3443 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
3444 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
3445 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
3446 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
3447 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latchexit.unr-lcssa, label %entry.new
3448 ; EPILOG-BLOCK: entry.new:
3449 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
3450 ; EPILOG-BLOCK-NEXT: br label %loop_header
3451 ; EPILOG-BLOCK: loop_header:
3452 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
3453 ; EPILOG-BLOCK-NEXT: %sum = phi i64 [ 0, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
3454 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
3455 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3456 ; EPILOG-BLOCK: loop_exiting:
3457 ; EPILOG-BLOCK-NEXT: %ivy = add i64 %iv, %add
3458 ; EPILOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
3459 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3460 ; EPILOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3461 ; EPILOG-BLOCK-NEXT: ]
3462 ; EPILOG-BLOCK: loop_latch:
3463 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3464 ; EPILOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
3465 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3466 ; EPILOG-BLOCK: loop_exiting.1:
3467 ; EPILOG-BLOCK-NEXT: %ivy.1 = add i64 %iv_next, %add
3468 ; EPILOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3469 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3470 ; EPILOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3471 ; EPILOG-BLOCK-NEXT: ]
3472 ; EPILOG-BLOCK: loop_latch.1:
3473 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv, 2
3474 ; EPILOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
3475 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
3476 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
3477 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %latchexit.unr-lcssa.loopexit, !llvm.loop !9
3478 ; EPILOG-BLOCK: exit1.loopexit:
3479 ; EPILOG-BLOCK-NEXT: %result.ph = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.1, %loop_exiting.1 ]
3480 ; EPILOG-BLOCK-NEXT: br label %exit1
3481 ; EPILOG-BLOCK: exit1:
3482 ; EPILOG-BLOCK-NEXT: %result = phi i64 [ %ivy.epil, %loop_exiting.epil ], [ %ivy.epil, %loop_exiting.epil ], [ %result.ph, %exit1.loopexit ]
3483 ; EPILOG-BLOCK-NEXT: ret i64 %result
3484 ; EPILOG-BLOCK: latchexit.unr-lcssa.loopexit:
3485 ; EPILOG-BLOCK-NEXT: %sum.next.lcssa.ph.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
3486 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
3487 ; EPILOG-BLOCK-NEXT: %sum.unr.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
3488 ; EPILOG-BLOCK-NEXT: br label %latchexit.unr-lcssa
3489 ; EPILOG-BLOCK: latchexit.unr-lcssa:
3490 ; EPILOG-BLOCK-NEXT: %sum.next.lcssa.ph = phi i64 [ poison, %entry ], [ %sum.next.lcssa.ph.ph, %latchexit.unr-lcssa.loopexit ]
3491 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %latchexit.unr-lcssa.loopexit ]
3492 ; EPILOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %latchexit.unr-lcssa.loopexit ]
3493 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3494 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %latchexit
3495 ; EPILOG-BLOCK: loop_header.epil.preheader:
3496 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
3497 ; EPILOG-BLOCK: loop_header.epil:
3498 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %loop_exiting.epil
3499 ; EPILOG-BLOCK: loop_exiting.epil:
3500 ; EPILOG-BLOCK-NEXT: %ivy.epil = add i64 %iv.unr, %add
3501 ; EPILOG-BLOCK-NEXT: switch i64 %sum.unr, label %loop_latch.epil [
3502 ; EPILOG-BLOCK-NEXT: i64 24, label %exit1
3503 ; EPILOG-BLOCK-NEXT: i64 42, label %exit1
3504 ; EPILOG-BLOCK-NEXT: ]
3505 ; EPILOG-BLOCK: loop_latch.epil:
3506 ; EPILOG-BLOCK-NEXT: %sum.next.epil = add i64 %sum.unr, %add
3507 ; EPILOG-BLOCK-NEXT: br label %latchexit
3508 ; EPILOG-BLOCK: latchexit:
3509 ; EPILOG-BLOCK-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ], [ %sum.next.epil, %loop_latch.epil ]
3510 ; EPILOG-BLOCK-NEXT: ret i64 %sum.next.lcssa
3512 ; PROLOG-LABEL: @test5(
3513 ; PROLOG-NEXT: entry:
3514 ; PROLOG-NEXT: %0 = freeze i64 %trip
3515 ; PROLOG-NEXT: %1 = add i64 %0, -1
3516 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
3517 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3518 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
3519 ; PROLOG: loop_header.prol.preheader:
3520 ; PROLOG-NEXT: br label %loop_header.prol
3521 ; PROLOG: loop_header.prol:
3522 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
3523 ; PROLOG-NEXT: %sum.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %sum.next.prol, %loop_latch.prol ]
3524 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
3525 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting.prol
3526 ; PROLOG: loop_exiting.prol:
3527 ; PROLOG-NEXT: %ivy.prol = add i64 %iv.prol, %add
3528 ; PROLOG-NEXT: switch i64 %sum.prol, label %loop_latch.prol [
3529 ; PROLOG-NEXT: i64 24, label %exit1.loopexit1
3530 ; PROLOG-NEXT: i64 42, label %exit1.loopexit1
3532 ; PROLOG: loop_latch.prol:
3533 ; PROLOG-NEXT: %iv_next.prol = add nuw nsw i64 %iv.prol, 1
3534 ; PROLOG-NEXT: %sum.next.prol = add i64 %sum.prol, %add
3535 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
3536 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
3537 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
3538 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !9
3539 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
3540 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
3541 ; PROLOG-NEXT: %sum.unr.ph = phi i64 [ %sum.next.prol, %loop_latch.prol ]
3542 ; PROLOG-NEXT: %sum.next.lcssa.unr.ph = phi i64 [ %sum.next.prol, %loop_latch.prol ]
3543 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
3544 ; PROLOG: loop_header.prol.loopexit:
3545 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
3546 ; PROLOG-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %sum.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
3547 ; PROLOG-NEXT: %sum.next.lcssa.unr = phi i64 [ poison, %entry ], [ %sum.next.lcssa.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
3548 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
3549 ; PROLOG-NEXT: br i1 %2, label %latchexit, label %entry.new
3550 ; PROLOG: entry.new:
3551 ; PROLOG-NEXT: br label %loop_header
3552 ; PROLOG: loop_header:
3553 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
3554 ; PROLOG-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.7, %loop_latch.7 ]
3555 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3556 ; PROLOG: loop_exiting:
3557 ; PROLOG-NEXT: %ivy = add i64 %iv, %add
3558 ; PROLOG-NEXT: switch i64 %sum, label %loop_latch [
3559 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3560 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3562 ; PROLOG: loop_latch:
3563 ; PROLOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3564 ; PROLOG-NEXT: %sum.next = add i64 %sum, %add
3565 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3566 ; PROLOG: loop_exiting.1:
3567 ; PROLOG-NEXT: %ivy.1 = add i64 %iv_next, %add
3568 ; PROLOG-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3569 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3570 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3572 ; PROLOG: loop_latch.1:
3573 ; PROLOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv, 2
3574 ; PROLOG-NEXT: %sum.next.1 = add i64 %sum.next, %add
3575 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %loop_exiting.2
3576 ; PROLOG: loop_exiting.2:
3577 ; PROLOG-NEXT: %ivy.2 = add i64 %iv_next.1, %add
3578 ; PROLOG-NEXT: switch i64 %sum.next.1, label %loop_latch.2 [
3579 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3580 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3582 ; PROLOG: loop_latch.2:
3583 ; PROLOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv, 3
3584 ; PROLOG-NEXT: %sum.next.2 = add i64 %sum.next.1, %add
3585 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %loop_exiting.3
3586 ; PROLOG: loop_exiting.3:
3587 ; PROLOG-NEXT: %ivy.3 = add i64 %iv_next.2, %add
3588 ; PROLOG-NEXT: switch i64 %sum.next.2, label %loop_latch.3 [
3589 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3590 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3592 ; PROLOG: loop_latch.3:
3593 ; PROLOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv, 4
3594 ; PROLOG-NEXT: %sum.next.3 = add i64 %sum.next.2, %add
3595 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %loop_exiting.4
3596 ; PROLOG: loop_exiting.4:
3597 ; PROLOG-NEXT: %ivy.4 = add i64 %iv_next.3, %add
3598 ; PROLOG-NEXT: switch i64 %sum.next.3, label %loop_latch.4 [
3599 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3600 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3602 ; PROLOG: loop_latch.4:
3603 ; PROLOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv, 5
3604 ; PROLOG-NEXT: %sum.next.4 = add i64 %sum.next.3, %add
3605 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %loop_exiting.5
3606 ; PROLOG: loop_exiting.5:
3607 ; PROLOG-NEXT: %ivy.5 = add i64 %iv_next.4, %add
3608 ; PROLOG-NEXT: switch i64 %sum.next.4, label %loop_latch.5 [
3609 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3610 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3612 ; PROLOG: loop_latch.5:
3613 ; PROLOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv, 6
3614 ; PROLOG-NEXT: %sum.next.5 = add i64 %sum.next.4, %add
3615 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %loop_exiting.6
3616 ; PROLOG: loop_exiting.6:
3617 ; PROLOG-NEXT: %ivy.6 = add i64 %iv_next.5, %add
3618 ; PROLOG-NEXT: switch i64 %sum.next.5, label %loop_latch.6 [
3619 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3620 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3622 ; PROLOG: loop_latch.6:
3623 ; PROLOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv, 7
3624 ; PROLOG-NEXT: %sum.next.6 = add i64 %sum.next.5, %add
3625 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %loop_exiting.7
3626 ; PROLOG: loop_exiting.7:
3627 ; PROLOG-NEXT: %ivy.7 = add i64 %iv_next.6, %add
3628 ; PROLOG-NEXT: switch i64 %sum.next.6, label %loop_latch.7 [
3629 ; PROLOG-NEXT: i64 24, label %exit1.loopexit
3630 ; PROLOG-NEXT: i64 42, label %exit1.loopexit
3632 ; PROLOG: loop_latch.7:
3633 ; PROLOG-NEXT: %iv_next.7 = add nuw nsw i64 %iv, 8
3634 ; PROLOG-NEXT: %sum.next.7 = add i64 %sum.next.6, %add
3635 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
3636 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %latchexit.unr-lcssa
3637 ; PROLOG: exit1.loopexit:
3638 ; 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 ]
3639 ; PROLOG-NEXT: br label %exit1
3640 ; PROLOG: exit1.loopexit1:
3641 ; PROLOG-NEXT: %result.ph2 = phi i64 [ %ivy.prol, %loop_exiting.prol ], [ %ivy.prol, %loop_exiting.prol ]
3642 ; PROLOG-NEXT: br label %exit1
3644 ; PROLOG-NEXT: %result = phi i64 [ %result.ph, %exit1.loopexit ], [ %result.ph2, %exit1.loopexit1 ]
3645 ; PROLOG-NEXT: ret i64 %result
3646 ; PROLOG: latchexit.unr-lcssa:
3647 ; PROLOG-NEXT: %sum.next.lcssa.ph = phi i64 [ %sum.next.7, %loop_latch.7 ]
3648 ; PROLOG-NEXT: br label %latchexit
3649 ; PROLOG: latchexit:
3650 ; PROLOG-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.unr, %loop_header.prol.loopexit ], [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ]
3651 ; PROLOG-NEXT: ret i64 %sum.next.lcssa
3653 ; PROLOG-BLOCK-LABEL: @test5(
3654 ; PROLOG-BLOCK-NEXT: entry:
3655 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
3656 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
3657 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
3658 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3659 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
3660 ; PROLOG-BLOCK: loop_header.prol.preheader:
3661 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
3662 ; PROLOG-BLOCK: loop_header.prol:
3663 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %loop_exiting.prol
3664 ; PROLOG-BLOCK: loop_exiting.prol:
3665 ; PROLOG-BLOCK-NEXT: switch i64 0, label %loop_latch.prol [
3666 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1
3667 ; PROLOG-BLOCK-NEXT: i64 42, label %exit1
3668 ; PROLOG-BLOCK-NEXT: ]
3669 ; PROLOG-BLOCK: loop_latch.prol:
3670 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
3671 ; PROLOG-BLOCK: loop_header.prol.loopexit:
3672 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
3673 ; PROLOG-BLOCK-NEXT: %sum.unr = phi i64 [ 0, %entry ], [ %add, %loop_latch.prol ]
3674 ; PROLOG-BLOCK-NEXT: %sum.next.lcssa.unr = phi i64 [ poison, %entry ], [ %add, %loop_latch.prol ]
3675 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
3676 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latchexit, label %entry.new
3677 ; PROLOG-BLOCK: entry.new:
3678 ; PROLOG-BLOCK-NEXT: br label %loop_header
3679 ; PROLOG-BLOCK: loop_header:
3680 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
3681 ; PROLOG-BLOCK-NEXT: %sum = phi i64 [ %sum.unr, %entry.new ], [ %sum.next.1, %loop_latch.1 ]
3682 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %loop_exiting
3683 ; PROLOG-BLOCK: loop_exiting:
3684 ; PROLOG-BLOCK-NEXT: %ivy = add i64 %iv, %add
3685 ; PROLOG-BLOCK-NEXT: switch i64 %sum, label %loop_latch [
3686 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3687 ; PROLOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3688 ; PROLOG-BLOCK-NEXT: ]
3689 ; PROLOG-BLOCK: loop_latch:
3690 ; PROLOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
3691 ; PROLOG-BLOCK-NEXT: %sum.next = add i64 %sum, %add
3692 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %loop_exiting.1
3693 ; PROLOG-BLOCK: loop_exiting.1:
3694 ; PROLOG-BLOCK-NEXT: %ivy.1 = add i64 %iv_next, %add
3695 ; PROLOG-BLOCK-NEXT: switch i64 %sum.next, label %loop_latch.1 [
3696 ; PROLOG-BLOCK-NEXT: i64 24, label %exit1.loopexit
3697 ; PROLOG-BLOCK-NEXT: i64 42, label %exit1.loopexit
3698 ; PROLOG-BLOCK-NEXT: ]
3699 ; PROLOG-BLOCK: loop_latch.1:
3700 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add nuw nsw i64 %iv, 2
3701 ; PROLOG-BLOCK-NEXT: %sum.next.1 = add i64 %sum.next, %add
3702 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
3703 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %latchexit.unr-lcssa, !llvm.loop !9
3704 ; PROLOG-BLOCK: exit1.loopexit:
3705 ; PROLOG-BLOCK-NEXT: %result.ph = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ], [ %ivy.1, %loop_exiting.1 ], [ %ivy.1, %loop_exiting.1 ]
3706 ; PROLOG-BLOCK-NEXT: br label %exit1
3707 ; PROLOG-BLOCK: exit1:
3708 ; PROLOG-BLOCK-NEXT: %result = phi i64 [ %add, %loop_exiting.prol ], [ %add, %loop_exiting.prol ], [ %result.ph, %exit1.loopexit ]
3709 ; PROLOG-BLOCK-NEXT: ret i64 %result
3710 ; PROLOG-BLOCK: latchexit.unr-lcssa:
3711 ; PROLOG-BLOCK-NEXT: %sum.next.lcssa.ph = phi i64 [ %sum.next.1, %loop_latch.1 ]
3712 ; PROLOG-BLOCK-NEXT: br label %latchexit
3713 ; PROLOG-BLOCK: latchexit:
3714 ; PROLOG-BLOCK-NEXT: %sum.next.lcssa = phi i64 [ %sum.next.lcssa.unr, %loop_header.prol.loopexit ], [ %sum.next.lcssa.ph, %latchexit.unr-lcssa ]
3715 ; PROLOG-BLOCK-NEXT: ret i64 %sum.next.lcssa
3719 br label %loop_header
3722 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
3723 %sum = phi i64 [ 0, %entry ], [ %sum.next, %loop_latch ]
3724 br i1 %cond, label %loop_latch, label %loop_exiting
3727 %ivy = add i64 %iv, %add
3728 switch i64 %sum, label %loop_latch [
3729 i64 24, label %exit1
3730 i64 42, label %exit1
3734 %iv_next = add nuw nsw i64 %iv, 1
3735 %sum.next = add i64 %sum, %add
3736 %cmp = icmp ne i64 %iv_next, %trip
3737 br i1 %cmp, label %loop_header, label %latchexit
3740 %result = phi i64 [ %ivy, %loop_exiting ], [ %ivy, %loop_exiting ]
3747 ; test when exit blocks have successors.
3748 define i32 @test6(ptr nocapture %a, i64 %n, i1 %cond, i32 %x) {
3749 ; EPILOG-LABEL: @test6(
3750 ; EPILOG-NEXT: entry:
3751 ; EPILOG-NEXT: %0 = freeze i64 %n
3752 ; EPILOG-NEXT: %1 = add i64 %0, -1
3753 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
3754 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
3755 ; EPILOG-NEXT: br i1 %2, label %latch_exit.unr-lcssa, label %entry.new
3756 ; EPILOG: entry.new:
3757 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
3758 ; EPILOG-NEXT: br label %header
3760 ; EPILOG-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
3761 ; EPILOG-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.7, %latch.7 ]
3762 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %latch.7 ]
3763 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
3764 ; EPILOG: for.exiting_block:
3765 ; EPILOG-NEXT: %cmp = icmp eq i64 %n, 42
3766 ; EPILOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
3768 ; EPILOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
3769 ; EPILOG-NEXT: %load = load i32, ptr %arrayidx, align 4
3770 ; EPILOG-NEXT: %add = add nsw i32 %load, %sum.02
3771 ; EPILOG-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
3772 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
3773 ; EPILOG: for.exiting_block.1:
3774 ; EPILOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
3775 ; EPILOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
3777 ; EPILOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
3778 ; EPILOG-NEXT: %load.1 = load i32, ptr %arrayidx.1, align 4
3779 ; EPILOG-NEXT: %add.1 = add nsw i32 %load.1, %add
3780 ; EPILOG-NEXT: %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
3781 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
3782 ; EPILOG: for.exiting_block.2:
3783 ; EPILOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
3784 ; EPILOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
3786 ; EPILOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
3787 ; EPILOG-NEXT: %load.2 = load i32, ptr %arrayidx.2, align 4
3788 ; EPILOG-NEXT: %add.2 = add nsw i32 %load.2, %add.1
3789 ; EPILOG-NEXT: %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
3790 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
3791 ; EPILOG: for.exiting_block.3:
3792 ; EPILOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
3793 ; EPILOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
3795 ; EPILOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
3796 ; EPILOG-NEXT: %load.3 = load i32, ptr %arrayidx.3, align 4
3797 ; EPILOG-NEXT: %add.3 = add nsw i32 %load.3, %add.2
3798 ; EPILOG-NEXT: %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
3799 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
3800 ; EPILOG: for.exiting_block.4:
3801 ; EPILOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
3802 ; EPILOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
3804 ; EPILOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
3805 ; EPILOG-NEXT: %load.4 = load i32, ptr %arrayidx.4, align 4
3806 ; EPILOG-NEXT: %add.4 = add nsw i32 %load.4, %add.3
3807 ; EPILOG-NEXT: %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
3808 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
3809 ; EPILOG: for.exiting_block.5:
3810 ; EPILOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
3811 ; EPILOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
3813 ; EPILOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
3814 ; EPILOG-NEXT: %load.5 = load i32, ptr %arrayidx.5, align 4
3815 ; EPILOG-NEXT: %add.5 = add nsw i32 %load.5, %add.4
3816 ; EPILOG-NEXT: %indvars.iv.next.5 = add nuw nsw i64 %indvars.iv, 6
3817 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
3818 ; EPILOG: for.exiting_block.6:
3819 ; EPILOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
3820 ; EPILOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
3822 ; EPILOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
3823 ; EPILOG-NEXT: %load.6 = load i32, ptr %arrayidx.6, align 4
3824 ; EPILOG-NEXT: %add.6 = add nsw i32 %load.6, %add.5
3825 ; EPILOG-NEXT: %indvars.iv.next.6 = add nuw nsw i64 %indvars.iv, 7
3826 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
3827 ; EPILOG: for.exiting_block.7:
3828 ; EPILOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
3829 ; EPILOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
3831 ; EPILOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
3832 ; EPILOG-NEXT: %load.7 = load i32, ptr %arrayidx.7, align 4
3833 ; EPILOG-NEXT: %add.7 = add nsw i32 %load.7, %add.6
3834 ; EPILOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
3835 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
3836 ; EPILOG-NEXT: %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
3837 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %latch_exit.unr-lcssa.loopexit, label %header
3838 ; EPILOG: latch_exit.unr-lcssa.loopexit:
3839 ; EPILOG-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.7, %latch.7 ]
3840 ; EPILOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.7, %latch.7 ]
3841 ; EPILOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.7, %latch.7 ]
3842 ; EPILOG-NEXT: br label %latch_exit.unr-lcssa
3843 ; EPILOG: latch_exit.unr-lcssa:
3844 ; EPILOG-NEXT: %sum.0.lcssa.ph = phi i32 [ poison, %entry ], [ %sum.0.lcssa.ph.ph, %latch_exit.unr-lcssa.loopexit ]
3845 ; EPILOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latch_exit.unr-lcssa.loopexit ]
3846 ; EPILOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latch_exit.unr-lcssa.loopexit ]
3847 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3848 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latch_exit
3849 ; EPILOG: header.epil.preheader:
3850 ; EPILOG-NEXT: br label %header.epil
3851 ; EPILOG: header.epil:
3852 ; EPILOG-NEXT: %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %latch.epil ], [ %indvars.iv.unr, %header.epil.preheader ]
3853 ; EPILOG-NEXT: %sum.02.epil = phi i32 [ %add.epil, %latch.epil ], [ %sum.02.unr, %header.epil.preheader ]
3854 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
3855 ; EPILOG-NEXT: br i1 false, label %for.exit2.loopexit2, label %for.exiting_block.epil
3856 ; EPILOG: for.exiting_block.epil:
3857 ; EPILOG-NEXT: %cmp.epil = icmp eq i64 %n, 42
3858 ; EPILOG-NEXT: br i1 %cmp.epil, label %for.exit2.loopexit2, label %latch.epil
3859 ; EPILOG: latch.epil:
3860 ; EPILOG-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.epil
3861 ; EPILOG-NEXT: %load.epil = load i32, ptr %arrayidx.epil, align 4
3862 ; EPILOG-NEXT: %add.epil = add nsw i32 %load.epil, %sum.02.epil
3863 ; EPILOG-NEXT: %indvars.iv.next.epil = add i64 %indvars.iv.epil, 1
3864 ; EPILOG-NEXT: %exitcond.epil = icmp eq i64 %indvars.iv.next.epil, %n
3865 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
3866 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
3867 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latch_exit.epilog-lcssa, !llvm.loop !10
3868 ; EPILOG: latch_exit.epilog-lcssa:
3869 ; EPILOG-NEXT: %sum.0.lcssa.ph1 = phi i32 [ %add.epil, %latch.epil ]
3870 ; EPILOG-NEXT: br label %latch_exit
3871 ; EPILOG: latch_exit:
3872 ; EPILOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ], [ %sum.0.lcssa.ph1, %latch_exit.epilog-lcssa ]
3873 ; EPILOG-NEXT: ret i32 %sum.0.lcssa
3874 ; EPILOG: for.exit2.loopexit:
3875 ; 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 ]
3876 ; EPILOG-NEXT: br label %for.exit2
3877 ; EPILOG: for.exit2.loopexit2:
3878 ; EPILOG-NEXT: %retval.ph3 = phi i32 [ 42, %for.exiting_block.epil ], [ %sum.02.epil, %header.epil ]
3879 ; EPILOG-NEXT: br label %for.exit2
3880 ; EPILOG: for.exit2:
3881 ; EPILOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph3, %for.exit2.loopexit2 ]
3882 ; EPILOG-NEXT: %addx = add i32 %retval, %x
3883 ; EPILOG-NEXT: br i1 %cond, label %exit_true, label %exit_false
3884 ; EPILOG: exit_true:
3885 ; EPILOG-NEXT: ret i32 %retval
3886 ; EPILOG: exit_false:
3887 ; EPILOG-NEXT: ret i32 %addx
3889 ; EPILOG-BLOCK-LABEL: @test6(
3890 ; EPILOG-BLOCK-NEXT: entry:
3891 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %n
3892 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
3893 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
3894 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
3895 ; EPILOG-BLOCK-NEXT: br i1 %2, label %latch_exit.unr-lcssa, label %entry.new
3896 ; EPILOG-BLOCK: entry.new:
3897 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
3898 ; EPILOG-BLOCK-NEXT: br label %header
3899 ; EPILOG-BLOCK: header:
3900 ; EPILOG-BLOCK-NEXT: %indvars.iv = phi i64 [ 0, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
3901 ; EPILOG-BLOCK-NEXT: %sum.02 = phi i32 [ 0, %entry.new ], [ %add.1, %latch.1 ]
3902 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %latch.1 ]
3903 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
3904 ; EPILOG-BLOCK: for.exiting_block:
3905 ; EPILOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
3906 ; EPILOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
3907 ; EPILOG-BLOCK: latch:
3908 ; EPILOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
3909 ; EPILOG-BLOCK-NEXT: %load = load i32, ptr %arrayidx, align 4
3910 ; EPILOG-BLOCK-NEXT: %add = add nsw i32 %load, %sum.02
3911 ; EPILOG-BLOCK-NEXT: %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
3912 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
3913 ; EPILOG-BLOCK: for.exiting_block.1:
3914 ; EPILOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
3915 ; EPILOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
3916 ; EPILOG-BLOCK: latch.1:
3917 ; EPILOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
3918 ; EPILOG-BLOCK-NEXT: %load.1 = load i32, ptr %arrayidx.1, align 4
3919 ; EPILOG-BLOCK-NEXT: %add.1 = add nsw i32 %load.1, %add
3920 ; EPILOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
3921 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
3922 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
3923 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %latch_exit.unr-lcssa.loopexit, label %header, !llvm.loop !10
3924 ; EPILOG-BLOCK: latch_exit.unr-lcssa.loopexit:
3925 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph.ph = phi i32 [ %add.1, %latch.1 ]
3926 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.1, %latch.1 ]
3927 ; EPILOG-BLOCK-NEXT: %sum.02.unr.ph = phi i32 [ %add.1, %latch.1 ]
3928 ; EPILOG-BLOCK-NEXT: br label %latch_exit.unr-lcssa
3929 ; EPILOG-BLOCK: latch_exit.unr-lcssa:
3930 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ poison, %entry ], [ %sum.0.lcssa.ph.ph, %latch_exit.unr-lcssa.loopexit ]
3931 ; EPILOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %latch_exit.unr-lcssa.loopexit ]
3932 ; EPILOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %latch_exit.unr-lcssa.loopexit ]
3933 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3934 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latch_exit
3935 ; EPILOG-BLOCK: header.epil.preheader:
3936 ; EPILOG-BLOCK-NEXT: br label %header.epil
3937 ; EPILOG-BLOCK: header.epil:
3938 ; EPILOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.epil
3939 ; EPILOG-BLOCK: for.exiting_block.epil:
3940 ; EPILOG-BLOCK-NEXT: %cmp.epil = icmp eq i64 %n, 42
3941 ; EPILOG-BLOCK-NEXT: br i1 %cmp.epil, label %for.exit2, label %latch.epil
3942 ; EPILOG-BLOCK: latch.epil:
3943 ; EPILOG-BLOCK-NEXT: %arrayidx.epil = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.unr
3944 ; EPILOG-BLOCK-NEXT: %load.epil = load i32, ptr %arrayidx.epil, align 4
3945 ; EPILOG-BLOCK-NEXT: %add.epil = add nsw i32 %load.epil, %sum.02.unr
3946 ; EPILOG-BLOCK-NEXT: br label %latch_exit
3947 ; EPILOG-BLOCK: latch_exit:
3948 ; EPILOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ], [ %add.epil, %latch.epil ]
3949 ; EPILOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
3950 ; EPILOG-BLOCK: for.exit2.loopexit:
3951 ; EPILOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %latch ], [ 42, %for.exiting_block.1 ]
3952 ; EPILOG-BLOCK-NEXT: br label %for.exit2
3953 ; EPILOG-BLOCK: for.exit2:
3954 ; EPILOG-BLOCK-NEXT: %retval = phi i32 [ %sum.02.unr, %header.epil ], [ 42, %for.exiting_block.epil ], [ %retval.ph, %for.exit2.loopexit ]
3955 ; EPILOG-BLOCK-NEXT: %addx = add i32 %retval, %x
3956 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %exit_true, label %exit_false
3957 ; EPILOG-BLOCK: exit_true:
3958 ; EPILOG-BLOCK-NEXT: ret i32 %retval
3959 ; EPILOG-BLOCK: exit_false:
3960 ; EPILOG-BLOCK-NEXT: ret i32 %addx
3962 ; PROLOG-LABEL: @test6(
3963 ; PROLOG-NEXT: entry:
3964 ; PROLOG-NEXT: %0 = freeze i64 %n
3965 ; PROLOG-NEXT: %1 = add i64 %0, -1
3966 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
3967 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
3968 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
3969 ; PROLOG: header.prol.preheader:
3970 ; PROLOG-NEXT: br label %header.prol
3971 ; PROLOG: header.prol:
3972 ; PROLOG-NEXT: %indvars.iv.prol = phi i64 [ %indvars.iv.next.prol, %latch.prol ], [ 0, %header.prol.preheader ]
3973 ; PROLOG-NEXT: %sum.02.prol = phi i32 [ %add.prol, %latch.prol ], [ 0, %header.prol.preheader ]
3974 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
3975 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit1, label %for.exiting_block.prol
3976 ; PROLOG: for.exiting_block.prol:
3977 ; PROLOG-NEXT: %cmp.prol = icmp eq i64 %n, 42
3978 ; PROLOG-NEXT: br i1 %cmp.prol, label %for.exit2.loopexit1, label %latch.prol
3979 ; PROLOG: latch.prol:
3980 ; PROLOG-NEXT: %arrayidx.prol = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.prol
3981 ; PROLOG-NEXT: %load.prol = load i32, ptr %arrayidx.prol, align 4
3982 ; PROLOG-NEXT: %add.prol = add nsw i32 %load.prol, %sum.02.prol
3983 ; PROLOG-NEXT: %indvars.iv.next.prol = add i64 %indvars.iv.prol, 1
3984 ; PROLOG-NEXT: %exitcond.prol = icmp eq i64 %indvars.iv.next.prol, %n
3985 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
3986 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
3987 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !10
3988 ; PROLOG: header.prol.loopexit.unr-lcssa:
3989 ; PROLOG-NEXT: %sum.0.lcssa.unr.ph = phi i32 [ %add.prol, %latch.prol ]
3990 ; PROLOG-NEXT: %indvars.iv.unr.ph = phi i64 [ %indvars.iv.next.prol, %latch.prol ]
3991 ; PROLOG-NEXT: %sum.02.unr.ph = phi i32 [ %add.prol, %latch.prol ]
3992 ; PROLOG-NEXT: br label %header.prol.loopexit
3993 ; PROLOG: header.prol.loopexit:
3994 ; PROLOG-NEXT: %sum.0.lcssa.unr = phi i32 [ poison, %entry ], [ %sum.0.lcssa.unr.ph, %header.prol.loopexit.unr-lcssa ]
3995 ; PROLOG-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ %indvars.iv.unr.ph, %header.prol.loopexit.unr-lcssa ]
3996 ; PROLOG-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %sum.02.unr.ph, %header.prol.loopexit.unr-lcssa ]
3997 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
3998 ; PROLOG-NEXT: br i1 %2, label %latch_exit, label %entry.new
3999 ; PROLOG: entry.new:
4000 ; PROLOG-NEXT: br label %header
4002 ; PROLOG-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.7, %latch.7 ]
4003 ; PROLOG-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.7, %latch.7 ]
4004 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
4005 ; PROLOG: for.exiting_block:
4006 ; PROLOG-NEXT: %cmp = icmp eq i64 %n, 42
4007 ; PROLOG-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
4009 ; PROLOG-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
4010 ; PROLOG-NEXT: %load = load i32, ptr %arrayidx, align 4
4011 ; PROLOG-NEXT: %add = add nsw i32 %load, %sum.02
4012 ; PROLOG-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
4013 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
4014 ; PROLOG: for.exiting_block.1:
4015 ; PROLOG-NEXT: %cmp.1 = icmp eq i64 %n, 42
4016 ; PROLOG-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
4018 ; PROLOG-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
4019 ; PROLOG-NEXT: %load.1 = load i32, ptr %arrayidx.1, align 4
4020 ; PROLOG-NEXT: %add.1 = add nsw i32 %load.1, %add
4021 ; PROLOG-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
4022 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.2
4023 ; PROLOG: for.exiting_block.2:
4024 ; PROLOG-NEXT: %cmp.2 = icmp eq i64 %n, 42
4025 ; PROLOG-NEXT: br i1 %cmp.2, label %for.exit2.loopexit, label %latch.2
4027 ; PROLOG-NEXT: %arrayidx.2 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.1
4028 ; PROLOG-NEXT: %load.2 = load i32, ptr %arrayidx.2, align 4
4029 ; PROLOG-NEXT: %add.2 = add nsw i32 %load.2, %add.1
4030 ; PROLOG-NEXT: %indvars.iv.next.2 = add i64 %indvars.iv, 3
4031 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.3
4032 ; PROLOG: for.exiting_block.3:
4033 ; PROLOG-NEXT: %cmp.3 = icmp eq i64 %n, 42
4034 ; PROLOG-NEXT: br i1 %cmp.3, label %for.exit2.loopexit, label %latch.3
4036 ; PROLOG-NEXT: %arrayidx.3 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.2
4037 ; PROLOG-NEXT: %load.3 = load i32, ptr %arrayidx.3, align 4
4038 ; PROLOG-NEXT: %add.3 = add nsw i32 %load.3, %add.2
4039 ; PROLOG-NEXT: %indvars.iv.next.3 = add i64 %indvars.iv, 4
4040 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.4
4041 ; PROLOG: for.exiting_block.4:
4042 ; PROLOG-NEXT: %cmp.4 = icmp eq i64 %n, 42
4043 ; PROLOG-NEXT: br i1 %cmp.4, label %for.exit2.loopexit, label %latch.4
4045 ; PROLOG-NEXT: %arrayidx.4 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.3
4046 ; PROLOG-NEXT: %load.4 = load i32, ptr %arrayidx.4, align 4
4047 ; PROLOG-NEXT: %add.4 = add nsw i32 %load.4, %add.3
4048 ; PROLOG-NEXT: %indvars.iv.next.4 = add i64 %indvars.iv, 5
4049 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.5
4050 ; PROLOG: for.exiting_block.5:
4051 ; PROLOG-NEXT: %cmp.5 = icmp eq i64 %n, 42
4052 ; PROLOG-NEXT: br i1 %cmp.5, label %for.exit2.loopexit, label %latch.5
4054 ; PROLOG-NEXT: %arrayidx.5 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.4
4055 ; PROLOG-NEXT: %load.5 = load i32, ptr %arrayidx.5, align 4
4056 ; PROLOG-NEXT: %add.5 = add nsw i32 %load.5, %add.4
4057 ; PROLOG-NEXT: %indvars.iv.next.5 = add i64 %indvars.iv, 6
4058 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.6
4059 ; PROLOG: for.exiting_block.6:
4060 ; PROLOG-NEXT: %cmp.6 = icmp eq i64 %n, 42
4061 ; PROLOG-NEXT: br i1 %cmp.6, label %for.exit2.loopexit, label %latch.6
4063 ; PROLOG-NEXT: %arrayidx.6 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.5
4064 ; PROLOG-NEXT: %load.6 = load i32, ptr %arrayidx.6, align 4
4065 ; PROLOG-NEXT: %add.6 = add nsw i32 %load.6, %add.5
4066 ; PROLOG-NEXT: %indvars.iv.next.6 = add i64 %indvars.iv, 7
4067 ; PROLOG-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.7
4068 ; PROLOG: for.exiting_block.7:
4069 ; PROLOG-NEXT: %cmp.7 = icmp eq i64 %n, 42
4070 ; PROLOG-NEXT: br i1 %cmp.7, label %for.exit2.loopexit, label %latch.7
4072 ; PROLOG-NEXT: %arrayidx.7 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next.6
4073 ; PROLOG-NEXT: %load.7 = load i32, ptr %arrayidx.7, align 4
4074 ; PROLOG-NEXT: %add.7 = add nsw i32 %load.7, %add.6
4075 ; PROLOG-NEXT: %indvars.iv.next.7 = add i64 %indvars.iv, 8
4076 ; PROLOG-NEXT: %exitcond.7 = icmp eq i64 %indvars.iv.next.7, %n
4077 ; PROLOG-NEXT: br i1 %exitcond.7, label %latch_exit.unr-lcssa, label %header
4078 ; PROLOG: latch_exit.unr-lcssa:
4079 ; PROLOG-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.7, %latch.7 ]
4080 ; PROLOG-NEXT: br label %latch_exit
4081 ; PROLOG: latch_exit:
4082 ; PROLOG-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ]
4083 ; PROLOG-NEXT: ret i32 %sum.0.lcssa
4084 ; PROLOG: for.exit2.loopexit:
4085 ; 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 ]
4086 ; PROLOG-NEXT: br label %for.exit2
4087 ; PROLOG: for.exit2.loopexit1:
4088 ; PROLOG-NEXT: %retval.ph2 = phi i32 [ 42, %for.exiting_block.prol ], [ %sum.02.prol, %header.prol ]
4089 ; PROLOG-NEXT: br label %for.exit2
4090 ; PROLOG: for.exit2:
4091 ; PROLOG-NEXT: %retval = phi i32 [ %retval.ph, %for.exit2.loopexit ], [ %retval.ph2, %for.exit2.loopexit1 ]
4092 ; PROLOG-NEXT: %addx = add i32 %retval, %x
4093 ; PROLOG-NEXT: br i1 %cond, label %exit_true, label %exit_false
4094 ; PROLOG: exit_true:
4095 ; PROLOG-NEXT: ret i32 %retval
4096 ; PROLOG: exit_false:
4097 ; PROLOG-NEXT: ret i32 %addx
4099 ; PROLOG-BLOCK-LABEL: @test6(
4100 ; PROLOG-BLOCK-NEXT: entry:
4101 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %n
4102 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
4103 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4104 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4105 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4106 ; PROLOG-BLOCK: header.prol.preheader:
4107 ; PROLOG-BLOCK-NEXT: br label %header.prol
4108 ; PROLOG-BLOCK: header.prol:
4109 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2, label %for.exiting_block.prol
4110 ; PROLOG-BLOCK: for.exiting_block.prol:
4111 ; PROLOG-BLOCK-NEXT: %cmp.prol = icmp eq i64 %n, 42
4112 ; PROLOG-BLOCK-NEXT: br i1 %cmp.prol, label %for.exit2, label %latch.prol
4113 ; PROLOG-BLOCK: latch.prol:
4114 ; PROLOG-BLOCK-NEXT: %load.prol = load i32, ptr %a, align 4
4115 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
4116 ; PROLOG-BLOCK: header.prol.loopexit:
4117 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.unr = phi i32 [ poison, %entry ], [ %load.prol, %latch.prol ]
4118 ; PROLOG-BLOCK-NEXT: %indvars.iv.unr = phi i64 [ 0, %entry ], [ 1, %latch.prol ]
4119 ; PROLOG-BLOCK-NEXT: %sum.02.unr = phi i32 [ 0, %entry ], [ %load.prol, %latch.prol ]
4120 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4121 ; PROLOG-BLOCK-NEXT: br i1 %2, label %latch_exit, label %entry.new
4122 ; PROLOG-BLOCK: entry.new:
4123 ; PROLOG-BLOCK-NEXT: br label %header
4124 ; PROLOG-BLOCK: header:
4125 ; PROLOG-BLOCK-NEXT: %indvars.iv = phi i64 [ %indvars.iv.unr, %entry.new ], [ %indvars.iv.next.1, %latch.1 ]
4126 ; PROLOG-BLOCK-NEXT: %sum.02 = phi i32 [ %sum.02.unr, %entry.new ], [ %add.1, %latch.1 ]
4127 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block
4128 ; PROLOG-BLOCK: for.exiting_block:
4129 ; PROLOG-BLOCK-NEXT: %cmp = icmp eq i64 %n, 42
4130 ; PROLOG-BLOCK-NEXT: br i1 %cmp, label %for.exit2.loopexit, label %latch
4131 ; PROLOG-BLOCK: latch:
4132 ; PROLOG-BLOCK-NEXT: %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
4133 ; PROLOG-BLOCK-NEXT: %load = load i32, ptr %arrayidx, align 4
4134 ; PROLOG-BLOCK-NEXT: %add = add nsw i32 %load, %sum.02
4135 ; PROLOG-BLOCK-NEXT: %indvars.iv.next = add i64 %indvars.iv, 1
4136 ; PROLOG-BLOCK-NEXT: br i1 false, label %for.exit2.loopexit, label %for.exiting_block.1
4137 ; PROLOG-BLOCK: for.exiting_block.1:
4138 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp eq i64 %n, 42
4139 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %for.exit2.loopexit, label %latch.1
4140 ; PROLOG-BLOCK: latch.1:
4141 ; PROLOG-BLOCK-NEXT: %arrayidx.1 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv.next
4142 ; PROLOG-BLOCK-NEXT: %load.1 = load i32, ptr %arrayidx.1, align 4
4143 ; PROLOG-BLOCK-NEXT: %add.1 = add nsw i32 %load.1, %add
4144 ; PROLOG-BLOCK-NEXT: %indvars.iv.next.1 = add i64 %indvars.iv, 2
4145 ; PROLOG-BLOCK-NEXT: %exitcond.1 = icmp eq i64 %indvars.iv.next.1, %n
4146 ; PROLOG-BLOCK-NEXT: br i1 %exitcond.1, label %latch_exit.unr-lcssa, label %header, !llvm.loop !10
4147 ; PROLOG-BLOCK: latch_exit.unr-lcssa:
4148 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa.ph = phi i32 [ %add.1, %latch.1 ]
4149 ; PROLOG-BLOCK-NEXT: br label %latch_exit
4150 ; PROLOG-BLOCK: latch_exit:
4151 ; PROLOG-BLOCK-NEXT: %sum.0.lcssa = phi i32 [ %sum.0.lcssa.unr, %header.prol.loopexit ], [ %sum.0.lcssa.ph, %latch_exit.unr-lcssa ]
4152 ; PROLOG-BLOCK-NEXT: ret i32 %sum.0.lcssa
4153 ; PROLOG-BLOCK: for.exit2.loopexit:
4154 ; PROLOG-BLOCK-NEXT: %retval.ph = phi i32 [ 42, %for.exiting_block ], [ %sum.02, %header ], [ %add, %latch ], [ 42, %for.exiting_block.1 ]
4155 ; PROLOG-BLOCK-NEXT: br label %for.exit2
4156 ; PROLOG-BLOCK: for.exit2:
4157 ; PROLOG-BLOCK-NEXT: %retval = phi i32 [ 0, %header.prol ], [ 42, %for.exiting_block.prol ], [ %retval.ph, %for.exit2.loopexit ]
4158 ; PROLOG-BLOCK-NEXT: %addx = add i32 %retval, %x
4159 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %exit_true, label %exit_false
4160 ; PROLOG-BLOCK: exit_true:
4161 ; PROLOG-BLOCK-NEXT: ret i32 %retval
4162 ; PROLOG-BLOCK: exit_false:
4163 ; PROLOG-BLOCK-NEXT: ret i32 %addx
4170 %indvars.iv = phi i64 [ %indvars.iv.next, %latch ], [ 0, %entry ]
4171 %sum.02 = phi i32 [ %add, %latch ], [ 0, %entry ]
4172 br i1 false, label %for.exit2, label %for.exiting_block
4175 %cmp = icmp eq i64 %n, 42
4176 br i1 %cmp, label %for.exit2, label %latch
4179 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
4180 %load = load i32, ptr %arrayidx, align 4
4181 %add = add nsw i32 %load, %sum.02
4182 %indvars.iv.next = add i64 %indvars.iv, 1
4183 %exitcond = icmp eq i64 %indvars.iv.next, %n
4184 br i1 %exitcond, label %latch_exit, label %header
4187 %sum.0.lcssa = phi i32 [ %add, %latch ]
4188 ret i32 %sum.0.lcssa
4191 %retval = phi i32 [ %sum.02, %header ], [ 42, %for.exiting_block ]
4192 %addx = add i32 %retval, %x
4193 br i1 %cond, label %exit_true, label %exit_false
4202 ; test when value in exit block does not have VMap.
4203 define i32 @test7(i32 %arg, i32 %arg1, i32 %arg2) {
4204 ; EPILOG-LABEL: @test7(
4206 ; EPILOG-NEXT: %i = icmp slt i32 undef, 2
4207 ; EPILOG-NEXT: %sext = sext i32 undef to i64
4208 ; EPILOG-NEXT: %shft = ashr exact i32 %arg, 16
4209 ; EPILOG-NEXT: br i1 %i, label %loopexit2, label %preheader
4210 ; EPILOG: preheader:
4211 ; EPILOG-NEXT: %0 = add nsw i64 %sext, -1
4212 ; EPILOG-NEXT: %1 = freeze i64 %0
4213 ; EPILOG-NEXT: %2 = add i64 %1, -1
4214 ; EPILOG-NEXT: %xtraiter = and i64 %1, 7
4215 ; EPILOG-NEXT: %3 = icmp ult i64 %2, 7
4216 ; EPILOG-NEXT: br i1 %3, label %latchexit.unr-lcssa, label %preheader.new
4217 ; EPILOG: preheader.new:
4218 ; EPILOG-NEXT: %unroll_iter = sub i64 %1, %xtraiter
4219 ; EPILOG-NEXT: br label %header
4221 ; EPILOG-NEXT: %i6 = phi i64 [ 1, %preheader.new ], [ %add.7, %latch.7 ]
4222 ; EPILOG-NEXT: %niter = phi i64 [ 0, %preheader.new ], [ %niter.next.7, %latch.7 ]
4223 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4225 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4227 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.2
4229 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.3
4231 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.4
4233 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.5
4235 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.6
4237 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.7
4239 ; EPILOG-NEXT: %add.7 = add nuw nsw i64 %i6, 8
4240 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
4241 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
4242 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %header, label %latchexit.unr-lcssa.loopexit
4243 ; EPILOG: latchexit.unr-lcssa.loopexit:
4244 ; EPILOG-NEXT: %i6.unr.ph = phi i64 [ %add.7, %latch.7 ]
4245 ; EPILOG-NEXT: br label %latchexit.unr-lcssa
4246 ; EPILOG: latchexit.unr-lcssa:
4247 ; EPILOG-NEXT: %i6.unr = phi i64 [ 1, %preheader ], [ %i6.unr.ph, %latchexit.unr-lcssa.loopexit ]
4248 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4249 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchexit
4250 ; EPILOG: header.epil.preheader:
4251 ; EPILOG-NEXT: br label %header.epil
4252 ; EPILOG: header.epil:
4253 ; EPILOG-NEXT: %i6.epil = phi i64 [ %i6.unr, %header.epil.preheader ], [ %add.epil, %latch.epil ]
4254 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
4255 ; EPILOG-NEXT: br i1 false, label %loopexit1.loopexit1, label %latch.epil
4256 ; EPILOG: latch.epil:
4257 ; EPILOG-NEXT: %add.epil = add nuw nsw i64 %i6.epil, 1
4258 ; EPILOG-NEXT: %i9.epil = icmp slt i64 %add.epil, %sext
4259 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
4260 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
4261 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %latchexit.epilog-lcssa, !llvm.loop !11
4262 ; EPILOG: latchexit.epilog-lcssa:
4263 ; EPILOG-NEXT: br label %latchexit
4264 ; EPILOG: latchexit:
4265 ; EPILOG-NEXT: unreachable
4266 ; EPILOG: loopexit2:
4267 ; EPILOG-NEXT: ret i32 %shft
4268 ; EPILOG: loopexit1.loopexit:
4269 ; 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 ]
4270 ; EPILOG-NEXT: br label %loopexit1
4271 ; EPILOG: loopexit1.loopexit1:
4272 ; EPILOG-NEXT: %sext3.ph2 = phi i32 [ %shft, %header.epil ]
4273 ; EPILOG-NEXT: br label %loopexit1
4274 ; EPILOG: loopexit1:
4275 ; EPILOG-NEXT: %sext3 = phi i32 [ %sext3.ph, %loopexit1.loopexit ], [ %sext3.ph2, %loopexit1.loopexit1 ]
4276 ; EPILOG-NEXT: ret i32 %sext3
4278 ; EPILOG-BLOCK-LABEL: @test7(
4279 ; EPILOG-BLOCK-NEXT: bb:
4280 ; EPILOG-BLOCK-NEXT: %i = icmp slt i32 undef, 2
4281 ; EPILOG-BLOCK-NEXT: %sext = sext i32 undef to i64
4282 ; EPILOG-BLOCK-NEXT: %shft = ashr exact i32 %arg, 16
4283 ; EPILOG-BLOCK-NEXT: br i1 %i, label %loopexit2, label %preheader
4284 ; EPILOG-BLOCK: preheader:
4285 ; EPILOG-BLOCK-NEXT: %0 = add nsw i64 %sext, -1
4286 ; EPILOG-BLOCK-NEXT: %1 = freeze i64 %0
4287 ; EPILOG-BLOCK-NEXT: %2 = add i64 %1, -1
4288 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %1, 1
4289 ; EPILOG-BLOCK-NEXT: %3 = icmp ult i64 %2, 1
4290 ; EPILOG-BLOCK-NEXT: br i1 %3, label %latchexit.unr-lcssa, label %preheader.new
4291 ; EPILOG-BLOCK: preheader.new:
4292 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %1, %xtraiter
4293 ; EPILOG-BLOCK-NEXT: br label %header
4294 ; EPILOG-BLOCK: header:
4295 ; EPILOG-BLOCK-NEXT: %i6 = phi i64 [ 1, %preheader.new ], [ %add.1, %latch.1 ]
4296 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %preheader.new ], [ %niter.next.1, %latch.1 ]
4297 ; EPILOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4298 ; EPILOG-BLOCK: latch:
4299 ; EPILOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4300 ; EPILOG-BLOCK: latch.1:
4301 ; EPILOG-BLOCK-NEXT: %add.1 = add nuw nsw i64 %i6, 2
4302 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
4303 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
4304 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %header, label %latchexit.unr-lcssa.loopexit, !llvm.loop !11
4305 ; EPILOG-BLOCK: latchexit.unr-lcssa.loopexit:
4306 ; EPILOG-BLOCK-NEXT: br label %latchexit.unr-lcssa
4307 ; EPILOG-BLOCK: latchexit.unr-lcssa:
4308 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4309 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %latchexit
4310 ; EPILOG-BLOCK: header.epil.preheader:
4311 ; EPILOG-BLOCK-NEXT: br label %header.epil
4312 ; EPILOG-BLOCK: header.epil:
4313 ; EPILOG-BLOCK-NEXT: br i1 false, label %loopexit1, label %latch.epil
4314 ; EPILOG-BLOCK: latch.epil:
4315 ; EPILOG-BLOCK-NEXT: br label %latchexit
4316 ; EPILOG-BLOCK: latchexit:
4317 ; EPILOG-BLOCK-NEXT: unreachable
4318 ; EPILOG-BLOCK: loopexit2:
4319 ; EPILOG-BLOCK-NEXT: ret i32 %shft
4320 ; EPILOG-BLOCK: loopexit1.loopexit:
4321 ; EPILOG-BLOCK-NEXT: %sext3.ph = phi i32 [ %shft, %header ], [ %shft, %latch ]
4322 ; EPILOG-BLOCK-NEXT: br label %loopexit1
4323 ; EPILOG-BLOCK: loopexit1:
4324 ; EPILOG-BLOCK-NEXT: %sext3 = phi i32 [ %shft, %header.epil ], [ %sext3.ph, %loopexit1.loopexit ]
4325 ; EPILOG-BLOCK-NEXT: ret i32 %sext3
4327 ; PROLOG-LABEL: @test7(
4329 ; PROLOG-NEXT: %i = icmp slt i32 undef, 2
4330 ; PROLOG-NEXT: %sext = sext i32 undef to i64
4331 ; PROLOG-NEXT: %shft = ashr exact i32 %arg, 16
4332 ; PROLOG-NEXT: br i1 %i, label %loopexit2, label %preheader
4333 ; PROLOG: preheader:
4334 ; PROLOG-NEXT: %0 = add nsw i64 %sext, -1
4335 ; PROLOG-NEXT: %1 = freeze i64 %0
4336 ; PROLOG-NEXT: %2 = add i64 %1, -1
4337 ; PROLOG-NEXT: %xtraiter = and i64 %1, 7
4338 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4339 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4340 ; PROLOG: header.prol.preheader:
4341 ; PROLOG-NEXT: br label %header.prol
4342 ; PROLOG: header.prol:
4343 ; PROLOG-NEXT: %i6.prol = phi i64 [ 1, %header.prol.preheader ], [ %add.prol, %latch.prol ]
4344 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
4345 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit1, label %latch.prol
4346 ; PROLOG: latch.prol:
4347 ; PROLOG-NEXT: %add.prol = add nuw nsw i64 %i6.prol, 1
4348 ; PROLOG-NEXT: %i9.prol = icmp slt i64 %add.prol, %sext
4349 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
4350 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
4351 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !11
4352 ; PROLOG: header.prol.loopexit.unr-lcssa:
4353 ; PROLOG-NEXT: %i6.unr.ph = phi i64 [ %add.prol, %latch.prol ]
4354 ; PROLOG-NEXT: br label %header.prol.loopexit
4355 ; PROLOG: header.prol.loopexit:
4356 ; PROLOG-NEXT: %i6.unr = phi i64 [ 1, %preheader ], [ %i6.unr.ph, %header.prol.loopexit.unr-lcssa ]
4357 ; PROLOG-NEXT: %3 = icmp ult i64 %2, 7
4358 ; PROLOG-NEXT: br i1 %3, label %latchexit, label %preheader.new
4359 ; PROLOG: preheader.new:
4360 ; PROLOG-NEXT: br label %header
4362 ; PROLOG-NEXT: %i6 = phi i64 [ %i6.unr, %preheader.new ], [ %add.7, %latch.7 ]
4363 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4365 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4367 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.2
4369 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.3
4371 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.4
4373 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.5
4375 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.6
4377 ; PROLOG-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.7
4379 ; PROLOG-NEXT: %add.7 = add nuw nsw i64 %i6, 8
4380 ; PROLOG-NEXT: %i9.7 = icmp slt i64 %add.7, %sext
4381 ; PROLOG-NEXT: br i1 %i9.7, label %header, label %latchexit.unr-lcssa
4382 ; PROLOG: latchexit.unr-lcssa:
4383 ; PROLOG-NEXT: br label %latchexit
4384 ; PROLOG: latchexit:
4385 ; PROLOG-NEXT: unreachable
4386 ; PROLOG: loopexit2:
4387 ; PROLOG-NEXT: ret i32 %shft
4388 ; PROLOG: loopexit1.loopexit:
4389 ; 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 ]
4390 ; PROLOG-NEXT: br label %loopexit1
4391 ; PROLOG: loopexit1.loopexit1:
4392 ; PROLOG-NEXT: %sext3.ph2 = phi i32 [ %shft, %header.prol ]
4393 ; PROLOG-NEXT: br label %loopexit1
4394 ; PROLOG: loopexit1:
4395 ; PROLOG-NEXT: %sext3 = phi i32 [ %sext3.ph, %loopexit1.loopexit ], [ %sext3.ph2, %loopexit1.loopexit1 ]
4396 ; PROLOG-NEXT: ret i32 %sext3
4398 ; PROLOG-BLOCK-LABEL: @test7(
4399 ; PROLOG-BLOCK-NEXT: bb:
4400 ; PROLOG-BLOCK-NEXT: %i = icmp slt i32 undef, 2
4401 ; PROLOG-BLOCK-NEXT: %sext = sext i32 undef to i64
4402 ; PROLOG-BLOCK-NEXT: %shft = ashr exact i32 %arg, 16
4403 ; PROLOG-BLOCK-NEXT: br i1 %i, label %loopexit2, label %preheader
4404 ; PROLOG-BLOCK: preheader:
4405 ; PROLOG-BLOCK-NEXT: %0 = add nsw i64 %sext, -1
4406 ; PROLOG-BLOCK-NEXT: %1 = freeze i64 %0
4407 ; PROLOG-BLOCK-NEXT: %2 = add i64 %1, -1
4408 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %1, 1
4409 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4410 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4411 ; PROLOG-BLOCK: header.prol.preheader:
4412 ; PROLOG-BLOCK-NEXT: br label %header.prol
4413 ; PROLOG-BLOCK: header.prol:
4414 ; PROLOG-BLOCK-NEXT: br i1 false, label %loopexit1, label %latch.prol
4415 ; PROLOG-BLOCK: latch.prol:
4416 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
4417 ; PROLOG-BLOCK: header.prol.loopexit:
4418 ; PROLOG-BLOCK-NEXT: %i6.unr = phi i64 [ 1, %preheader ], [ 2, %latch.prol ]
4419 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i64 %2, 1
4420 ; PROLOG-BLOCK-NEXT: br i1 %3, label %latchexit, label %preheader.new
4421 ; PROLOG-BLOCK: preheader.new:
4422 ; PROLOG-BLOCK-NEXT: br label %header
4423 ; PROLOG-BLOCK: header:
4424 ; PROLOG-BLOCK-NEXT: %i6 = phi i64 [ %i6.unr, %preheader.new ], [ %add.1, %latch.1 ]
4425 ; PROLOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch
4426 ; PROLOG-BLOCK: latch:
4427 ; PROLOG-BLOCK-NEXT: br i1 false, label %loopexit1.loopexit, label %latch.1
4428 ; PROLOG-BLOCK: latch.1:
4429 ; PROLOG-BLOCK-NEXT: %add.1 = add nuw nsw i64 %i6, 2
4430 ; PROLOG-BLOCK-NEXT: %i9.1 = icmp slt i64 %add.1, %sext
4431 ; PROLOG-BLOCK-NEXT: br i1 %i9.1, label %header, label %latchexit.unr-lcssa, !llvm.loop !11
4432 ; PROLOG-BLOCK: latchexit.unr-lcssa:
4433 ; PROLOG-BLOCK-NEXT: br label %latchexit
4434 ; PROLOG-BLOCK: latchexit:
4435 ; PROLOG-BLOCK-NEXT: unreachable
4436 ; PROLOG-BLOCK: loopexit2:
4437 ; PROLOG-BLOCK-NEXT: ret i32 %shft
4438 ; PROLOG-BLOCK: loopexit1.loopexit:
4439 ; PROLOG-BLOCK-NEXT: %sext3.ph = phi i32 [ %shft, %header ], [ %shft, %latch ]
4440 ; PROLOG-BLOCK-NEXT: br label %loopexit1
4441 ; PROLOG-BLOCK: loopexit1:
4442 ; PROLOG-BLOCK-NEXT: %sext3 = phi i32 [ %shft, %header.prol ], [ %sext3.ph, %loopexit1.loopexit ]
4443 ; PROLOG-BLOCK-NEXT: ret i32 %sext3
4446 %i = icmp slt i32 undef, 2
4447 %sext = sext i32 undef to i64
4448 %shft = ashr exact i32 %arg, 16
4449 br i1 %i, label %loopexit2, label %preheader
4451 preheader: ; preds = %bb2
4454 header: ; preds = %latch, %preheader
4455 %i6 = phi i64 [ 1, %preheader ], [ %add, %latch ]
4456 br i1 false, label %loopexit1, label %latch
4458 latch: ; preds = %header
4459 %add = add nuw nsw i64 %i6, 1
4460 %i9 = icmp slt i64 %add, %sext
4461 br i1 %i9, label %header, label %latchexit
4463 latchexit: ; preds = %latch
4466 loopexit2: ; preds = %bb2
4469 loopexit1: ; preds = %header
4470 %sext3 = phi i32 [ %shft, %header ]
4474 ; Nested loop and inner loop is unrolled. The tricky bit here is that
4475 ; several blocks in the inner loop fall out of the outer block when we
4476 ; use the epilogue block remainder strategy.
4477 define void @test8() {
4478 ; EPILOG-LABEL: @test8(
4480 ; EPILOG-NEXT: br label %outerloop
4481 ; EPILOG: outerloop.loopexit.loopexit:
4482 ; EPILOG-NEXT: br label %outerloop.loopexit
4483 ; EPILOG: outerloop.loopexit.loopexit1:
4484 ; EPILOG-NEXT: br label %outerloop.loopexit
4485 ; EPILOG: outerloop.loopexit:
4486 ; EPILOG-NEXT: br label %outerloop
4487 ; EPILOG: outerloop:
4488 ; EPILOG-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit ]
4489 ; EPILOG-NEXT: %0 = sub i64 100, %i
4490 ; EPILOG-NEXT: %1 = sub i64 99, %i
4491 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
4492 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
4493 ; EPILOG-NEXT: br i1 %2, label %exit.unr-lcssa, label %outerloop.new
4494 ; EPILOG: outerloop.new:
4495 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
4496 ; EPILOG-NEXT: br label %innerH
4498 ; EPILOG-NEXT: %i3 = phi i64 [ %i, %outerloop.new ], [ %i4.7, %latch.7 ]
4499 ; EPILOG-NEXT: %niter = phi i64 [ 0, %outerloop.new ], [ %niter.next.7, %latch.7 ]
4500 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4502 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4504 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.2
4506 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.3
4508 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.4
4510 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.5
4512 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.6
4514 ; EPILOG-NEXT: %i4.7 = add nuw nsw i64 %i3, 8
4515 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.7
4517 ; EPILOG-NEXT: %niter.next.7 = add nuw nsw i64 %niter, 8
4518 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
4519 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %innerH, label %exit.unr-lcssa.loopexit
4520 ; EPILOG: exit.unr-lcssa.loopexit:
4521 ; EPILOG-NEXT: %i3.unr.ph = phi i64 [ %i4.7, %latch.7 ]
4522 ; EPILOG-NEXT: br label %exit.unr-lcssa
4523 ; EPILOG: exit.unr-lcssa:
4524 ; EPILOG-NEXT: %i3.unr = phi i64 [ %i, %outerloop ], [ %i3.unr.ph, %exit.unr-lcssa.loopexit ]
4525 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4526 ; EPILOG-NEXT: br i1 %lcmp.mod, label %innerH.epil.preheader, label %exit.loopexit
4527 ; EPILOG: innerH.epil.preheader:
4528 ; EPILOG-NEXT: br label %innerH.epil
4529 ; EPILOG: innerH.epil:
4530 ; EPILOG-NEXT: %i3.epil = phi i64 [ %i4.epil, %latch.epil ], [ %i3.unr, %innerH.epil.preheader ]
4531 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %innerH.epil.preheader ], [ %epil.iter.next, %latch.epil ]
4532 ; EPILOG-NEXT: %i4.epil = add nuw nsw i64 %i3.epil, 1
4533 ; EPILOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit1, label %latch.epil
4534 ; EPILOG: latch.epil:
4535 ; EPILOG-NEXT: %i6.epil = icmp ult i64 %i4.epil, 100
4536 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
4537 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
4538 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %innerH.epil, label %exit.epilog-lcssa, !llvm.loop !12
4539 ; EPILOG: exit.epilog-lcssa:
4540 ; EPILOG-NEXT: br label %exit
4541 ; EPILOG: exit.loopexit:
4542 ; EPILOG-NEXT: br label %exit
4544 ; EPILOG-NEXT: ret void
4546 ; EPILOG-BLOCK-LABEL: @test8(
4547 ; EPILOG-BLOCK-NEXT: bb:
4548 ; EPILOG-BLOCK-NEXT: br label %outerloop
4549 ; EPILOG-BLOCK: outerloop.loopexit.loopexit:
4550 ; EPILOG-BLOCK-NEXT: br label %outerloop.loopexit
4551 ; EPILOG-BLOCK: outerloop.loopexit:
4552 ; EPILOG-BLOCK-NEXT: br i1 false, label %exit.unr-lcssa.1, label %outerloop.new.1
4553 ; EPILOG-BLOCK: outerloop.new.1:
4554 ; EPILOG-BLOCK-NEXT: br label %innerH.1
4555 ; EPILOG-BLOCK: innerH.1:
4556 ; EPILOG-BLOCK-NEXT: %i3.1 = phi i64 [ 0, %outerloop.new.1 ], [ %i4.1.1, %latch.1.1 ]
4557 ; EPILOG-BLOCK-NEXT: %niter.1 = phi i64 [ 0, %outerloop.new.1 ], [ %niter.next.1.1, %latch.1.1 ]
4558 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.12
4559 ; EPILOG-BLOCK: latch.12:
4560 ; EPILOG-BLOCK-NEXT: %i4.1.1 = add nuw nsw i64 %i3.1, 2
4561 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.1.1
4562 ; EPILOG-BLOCK: latch.1.1:
4563 ; EPILOG-BLOCK-NEXT: %niter.next.1.1 = add i64 %niter.1, 2
4564 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1.1 = icmp ne i64 %niter.next.1.1, 100
4565 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1.1, label %innerH.1, label %exit.unr-lcssa.loopexit.1, !llvm.loop !12
4566 ; EPILOG-BLOCK: exit.unr-lcssa.loopexit.1:
4567 ; EPILOG-BLOCK-NEXT: br label %exit.unr-lcssa.1
4568 ; EPILOG-BLOCK: outerloop.loopexit.loopexit.1:
4569 ; EPILOG-BLOCK-NEXT: br label %outerloop.loopexit.1
4570 ; EPILOG-BLOCK: exit.unr-lcssa.1:
4571 ; EPILOG-BLOCK-NEXT: br i1 false, label %innerH.epil.preheader.1, label %exit.loopexit
4572 ; EPILOG-BLOCK: innerH.epil.preheader.1:
4573 ; EPILOG-BLOCK-NEXT: br label %innerH.epil.1
4574 ; EPILOG-BLOCK: innerH.epil.1:
4575 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.1, label %latch.epil
4576 ; EPILOG-BLOCK: outerloop.loopexit.1:
4577 ; EPILOG-BLOCK-NEXT: br label %outerloop, !llvm.loop !13
4578 ; EPILOG-BLOCK: outerloop:
4579 ; EPILOG-BLOCK-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit.1 ]
4580 ; EPILOG-BLOCK-NEXT: %0 = sub i64 100, %i
4581 ; EPILOG-BLOCK-NEXT: %1 = sub i64 99, %i
4582 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4583 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4584 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit.unr-lcssa, label %outerloop.new
4585 ; EPILOG-BLOCK: outerloop.new:
4586 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
4587 ; EPILOG-BLOCK-NEXT: br label %innerH
4588 ; EPILOG-BLOCK: innerH:
4589 ; EPILOG-BLOCK-NEXT: %i3 = phi i64 [ %i, %outerloop.new ], [ %i4.1, %latch.1 ]
4590 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %outerloop.new ], [ %niter.next.1, %latch.1 ]
4591 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4592 ; EPILOG-BLOCK: latch:
4593 ; EPILOG-BLOCK-NEXT: %i4.1 = add nuw nsw i64 %i3, 2
4594 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4595 ; EPILOG-BLOCK: latch.1:
4596 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
4597 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
4598 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %innerH, label %exit.unr-lcssa.loopexit, !llvm.loop !12
4599 ; EPILOG-BLOCK: exit.unr-lcssa.loopexit:
4600 ; EPILOG-BLOCK-NEXT: br label %exit.unr-lcssa
4601 ; EPILOG-BLOCK: exit.unr-lcssa:
4602 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4603 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %innerH.epil.preheader, label %exit.loopexit
4604 ; EPILOG-BLOCK: innerH.epil.preheader:
4605 ; EPILOG-BLOCK-NEXT: br label %innerH.epil
4606 ; EPILOG-BLOCK: innerH.epil:
4607 ; EPILOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit, label %latch.epil
4608 ; EPILOG-BLOCK: latch.epil:
4609 ; EPILOG-BLOCK-NEXT: br label %exit
4610 ; EPILOG-BLOCK: exit.loopexit:
4611 ; EPILOG-BLOCK-NEXT: br label %exit
4612 ; EPILOG-BLOCK: exit:
4613 ; EPILOG-BLOCK-NEXT: ret void
4615 ; PROLOG-LABEL: @test8(
4617 ; PROLOG-NEXT: br label %outerloop
4618 ; PROLOG: outerloop.loopexit.loopexit:
4619 ; PROLOG-NEXT: br label %outerloop.loopexit
4620 ; PROLOG: outerloop.loopexit.loopexit1:
4621 ; PROLOG-NEXT: br label %outerloop.loopexit
4622 ; PROLOG: outerloop.loopexit:
4623 ; PROLOG-NEXT: br label %outerloop
4624 ; PROLOG: outerloop:
4625 ; PROLOG-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit ]
4626 ; PROLOG-NEXT: %0 = sub i64 100, %i
4627 ; PROLOG-NEXT: %1 = sub i64 99, %i
4628 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
4629 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4630 ; PROLOG-NEXT: br i1 %lcmp.mod, label %innerH.prol.preheader, label %innerH.prol.loopexit
4631 ; PROLOG: innerH.prol.preheader:
4632 ; PROLOG-NEXT: br label %innerH.prol
4633 ; PROLOG: innerH.prol:
4634 ; PROLOG-NEXT: %i3.prol = phi i64 [ %i4.prol, %latch.prol ], [ %i, %innerH.prol.preheader ]
4635 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %innerH.prol.preheader ], [ %prol.iter.next, %latch.prol ]
4636 ; PROLOG-NEXT: %i4.prol = add nuw nsw i64 %i3.prol, 1
4637 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit1, label %latch.prol
4638 ; PROLOG: latch.prol:
4639 ; PROLOG-NEXT: %i6.prol = icmp ult i64 %i4.prol, 100
4640 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
4641 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
4642 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %innerH.prol, label %innerH.prol.loopexit.unr-lcssa, !llvm.loop !12
4643 ; PROLOG: innerH.prol.loopexit.unr-lcssa:
4644 ; PROLOG-NEXT: %i3.unr.ph = phi i64 [ %i4.prol, %latch.prol ]
4645 ; PROLOG-NEXT: br label %innerH.prol.loopexit
4646 ; PROLOG: innerH.prol.loopexit:
4647 ; PROLOG-NEXT: %i3.unr = phi i64 [ %i, %outerloop ], [ %i3.unr.ph, %innerH.prol.loopexit.unr-lcssa ]
4648 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
4649 ; PROLOG-NEXT: br i1 %2, label %exit.loopexit, label %outerloop.new
4650 ; PROLOG: outerloop.new:
4651 ; PROLOG-NEXT: br label %innerH
4653 ; PROLOG-NEXT: %i3 = phi i64 [ %i3.unr, %outerloop.new ], [ %i4.7, %latch.7 ]
4654 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4656 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4658 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.2
4660 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.3
4662 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.4
4664 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.5
4666 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.6
4668 ; PROLOG-NEXT: %i4.7 = add nuw nsw i64 %i3, 8
4669 ; PROLOG-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.7
4671 ; PROLOG-NEXT: %i6.7 = icmp ult i64 %i4.7, 100
4672 ; PROLOG-NEXT: br i1 %i6.7, label %innerH, label %exit.unr-lcssa
4673 ; PROLOG: exit.unr-lcssa:
4674 ; PROLOG-NEXT: br label %exit
4675 ; PROLOG: exit.loopexit:
4676 ; PROLOG-NEXT: br label %exit
4678 ; PROLOG-NEXT: ret void
4680 ; PROLOG-BLOCK-LABEL: @test8(
4681 ; PROLOG-BLOCK-NEXT: bb:
4682 ; PROLOG-BLOCK-NEXT: br label %outerloop
4683 ; PROLOG-BLOCK: outerloop.loopexit.loopexit:
4684 ; PROLOG-BLOCK-NEXT: br label %outerloop.loopexit
4685 ; PROLOG-BLOCK: outerloop.loopexit:
4686 ; PROLOG-BLOCK-NEXT: br i1 false, label %innerH.prol.preheader.1, label %innerH.prol.loopexit.1
4687 ; PROLOG-BLOCK: innerH.prol.preheader.1:
4688 ; PROLOG-BLOCK-NEXT: br label %innerH.prol.1
4689 ; PROLOG-BLOCK: innerH.prol.1:
4690 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.1, label %latch.prol.1
4691 ; PROLOG-BLOCK: latch.prol.1:
4692 ; PROLOG-BLOCK-NEXT: br label %innerH.prol.loopexit.1
4693 ; PROLOG-BLOCK: innerH.prol.loopexit.1:
4694 ; PROLOG-BLOCK-NEXT: %i3.unr.1 = phi i64 [ 0, %outerloop.loopexit ], [ 1, %latch.prol.1 ]
4695 ; PROLOG-BLOCK-NEXT: br i1 false, label %exit.loopexit, label %outerloop.new.1
4696 ; PROLOG-BLOCK: outerloop.new.1:
4697 ; PROLOG-BLOCK-NEXT: br label %innerH.1
4698 ; PROLOG-BLOCK: innerH.1:
4699 ; PROLOG-BLOCK-NEXT: %i3.1 = phi i64 [ %i3.unr.1, %outerloop.new.1 ], [ %i4.1.1, %latch.1.1 ]
4700 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.11
4701 ; PROLOG-BLOCK: latch.11:
4702 ; PROLOG-BLOCK-NEXT: %i4.1.1 = add nuw nsw i64 %i3.1, 2
4703 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit.1, label %latch.1.1
4704 ; PROLOG-BLOCK: latch.1.1:
4705 ; PROLOG-BLOCK-NEXT: %i6.1.1 = icmp ult i64 %i4.1.1, 100
4706 ; PROLOG-BLOCK-NEXT: br i1 %i6.1.1, label %innerH.1, label %exit.unr-lcssa.loopexit2, !llvm.loop !12
4707 ; PROLOG-BLOCK: outerloop.loopexit.loopexit.1:
4708 ; PROLOG-BLOCK-NEXT: br label %outerloop.loopexit.1
4709 ; PROLOG-BLOCK: outerloop.loopexit.1:
4710 ; PROLOG-BLOCK-NEXT: br label %outerloop, !llvm.loop !13
4711 ; PROLOG-BLOCK: outerloop:
4712 ; PROLOG-BLOCK-NEXT: %i = phi i64 [ 3, %bb ], [ 0, %outerloop.loopexit.1 ]
4713 ; PROLOG-BLOCK-NEXT: %0 = sub i64 100, %i
4714 ; PROLOG-BLOCK-NEXT: %1 = sub i64 99, %i
4715 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
4716 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
4717 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %innerH.prol.preheader, label %innerH.prol.loopexit
4718 ; PROLOG-BLOCK: innerH.prol.preheader:
4719 ; PROLOG-BLOCK-NEXT: br label %innerH.prol
4720 ; PROLOG-BLOCK: innerH.prol:
4721 ; PROLOG-BLOCK-NEXT: %i4.prol = add nuw nsw i64 %i, 1
4722 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit, label %latch.prol
4723 ; PROLOG-BLOCK: latch.prol:
4724 ; PROLOG-BLOCK-NEXT: br label %innerH.prol.loopexit
4725 ; PROLOG-BLOCK: innerH.prol.loopexit:
4726 ; PROLOG-BLOCK-NEXT: %i3.unr = phi i64 [ %i, %outerloop ], [ %i4.prol, %latch.prol ]
4727 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
4728 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit.loopexit, label %outerloop.new
4729 ; PROLOG-BLOCK: outerloop.new:
4730 ; PROLOG-BLOCK-NEXT: br label %innerH
4731 ; PROLOG-BLOCK: innerH:
4732 ; PROLOG-BLOCK-NEXT: %i3 = phi i64 [ %i3.unr, %outerloop.new ], [ %i4.1, %latch.1 ]
4733 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch
4734 ; PROLOG-BLOCK: latch:
4735 ; PROLOG-BLOCK-NEXT: %i4.1 = add nuw nsw i64 %i3, 2
4736 ; PROLOG-BLOCK-NEXT: br i1 false, label %outerloop.loopexit.loopexit, label %latch.1
4737 ; PROLOG-BLOCK: latch.1:
4738 ; PROLOG-BLOCK-NEXT: %i6.1 = icmp ult i64 %i4.1, 100
4739 ; PROLOG-BLOCK-NEXT: br i1 %i6.1, label %innerH, label %exit.unr-lcssa.loopexit, !llvm.loop !12
4740 ; PROLOG-BLOCK: exit.unr-lcssa.loopexit:
4741 ; PROLOG-BLOCK-NEXT: br label %exit.unr-lcssa
4742 ; PROLOG-BLOCK: exit.unr-lcssa.loopexit2:
4743 ; PROLOG-BLOCK-NEXT: br label %exit.unr-lcssa
4744 ; PROLOG-BLOCK: exit.unr-lcssa:
4745 ; PROLOG-BLOCK-NEXT: br label %exit
4746 ; PROLOG-BLOCK: exit.loopexit:
4747 ; PROLOG-BLOCK-NEXT: br label %exit
4748 ; PROLOG-BLOCK: exit:
4749 ; PROLOG-BLOCK-NEXT: ret void
4755 outerloop: ; preds = %innerH, %bb
4756 %i = phi i64 [ 3, %bb ], [ 0, %innerH ]
4759 innerH: ; preds = %latch, %outerloop
4760 %i3 = phi i64 [ %i4, %latch ], [ %i, %outerloop ]
4761 %i4 = add nuw nsw i64 %i3, 1
4762 br i1 false, label %outerloop, label %latch
4764 latch: ; preds = %innerH
4765 %i6 = icmp ult i64 %i4, 100
4766 br i1 %i6, label %innerH, label %exit
4768 exit: ; preds = %latch
4772 declare ptr addrspace(1) @foo(i32)
4773 ; inner loop prolog unrolled
4774 ; a value from outer loop is used in exit block of inner loop.
4775 ; Don't create VMap entries for such values (%trip).
4776 define ptr addrspace(1) @test9(ptr nocapture readonly %arg, i32 %n) {
4777 ; EPILOG-LABEL: @test9(
4779 ; EPILOG-NEXT: %0 = add i32 %n, -1
4780 ; EPILOG-NEXT: br label %outerloopHdr
4781 ; EPILOG: outerloopHdr:
4782 ; EPILOG-NEXT: %trip = add i32 %n, -1
4783 ; EPILOG-NEXT: %outercnd = icmp slt i32 0, %trip
4784 ; EPILOG-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
4785 ; EPILOG: preheader:
4786 ; EPILOG-NEXT: %i4 = zext i32 0 to i64
4787 ; EPILOG-NEXT: %1 = freeze i32 %0
4788 ; EPILOG-NEXT: %2 = add i32 %1, -1
4789 ; EPILOG-NEXT: %xtraiter = and i32 %1, 7
4790 ; EPILOG-NEXT: %3 = icmp ult i32 %2, 7
4791 ; EPILOG-NEXT: br i1 %3, label %outerLatch.loopexit.unr-lcssa, label %preheader.new
4792 ; EPILOG: preheader.new:
4793 ; EPILOG-NEXT: %unroll_iter = sub i32 %1, %xtraiter
4794 ; EPILOG-NEXT: br label %header
4796 ; EPILOG-NEXT: %phi = phi i64 [ %i4, %preheader.new ], [ %iv.next.7, %latch.7 ]
4797 ; EPILOG-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.7, %latch.7 ]
4798 ; EPILOG-NEXT: br i1 true, label %latch, label %innerexit.loopexit
4799 ; EPILOG: innerexit.loopexit:
4800 ; 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 ]
4801 ; EPILOG-NEXT: br label %innerexit
4802 ; EPILOG: innerexit.loopexit1:
4803 ; EPILOG-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.epil ]
4804 ; EPILOG-NEXT: br label %innerexit
4805 ; EPILOG: innerexit:
4806 ; EPILOG-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
4807 ; EPILOG-NEXT: %i9 = call ptr addrspace(1) @foo(i32 %trip.lcssa)
4808 ; EPILOG-NEXT: ret ptr addrspace(1) %i9
4810 ; EPILOG-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit
4812 ; EPILOG-NEXT: br i1 true, label %latch.2, label %innerexit.loopexit
4814 ; EPILOG-NEXT: br i1 true, label %latch.3, label %innerexit.loopexit
4816 ; EPILOG-NEXT: br i1 true, label %latch.4, label %innerexit.loopexit
4818 ; EPILOG-NEXT: br i1 true, label %latch.5, label %innerexit.loopexit
4820 ; EPILOG-NEXT: br i1 true, label %latch.6, label %innerexit.loopexit
4822 ; EPILOG-NEXT: br i1 true, label %latch.7, label %innerexit.loopexit
4824 ; EPILOG-NEXT: %iv.next.7 = add nuw nsw i64 %phi, 8
4825 ; EPILOG-NEXT: %niter.next.7 = add i32 %niter, 8
4826 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i32 %niter.next.7, %unroll_iter
4827 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %header, label %outerLatch.loopexit.unr-lcssa.loopexit
4828 ; EPILOG: outerLatch.loopexit.unr-lcssa.loopexit:
4829 ; EPILOG-NEXT: %phi.unr.ph = phi i64 [ %iv.next.7, %latch.7 ]
4830 ; EPILOG-NEXT: br label %outerLatch.loopexit.unr-lcssa
4831 ; EPILOG: outerLatch.loopexit.unr-lcssa:
4832 ; EPILOG-NEXT: %phi.unr = phi i64 [ %i4, %preheader ], [ %phi.unr.ph, %outerLatch.loopexit.unr-lcssa.loopexit ]
4833 ; EPILOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
4834 ; EPILOG-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %outerLatch.loopexit
4835 ; EPILOG: header.epil.preheader:
4836 ; EPILOG-NEXT: br label %header.epil
4837 ; EPILOG: header.epil:
4838 ; EPILOG-NEXT: %phi.epil = phi i64 [ %phi.unr, %header.epil.preheader ], [ %iv.next.epil, %latch.epil ]
4839 ; EPILOG-NEXT: %epil.iter = phi i32 [ 0, %header.epil.preheader ], [ %epil.iter.next, %latch.epil ]
4840 ; EPILOG-NEXT: %i7.epil = trunc i64 %phi.epil to i32
4841 ; EPILOG-NEXT: br i1 true, label %latch.epil, label %innerexit.loopexit1
4842 ; EPILOG: latch.epil:
4843 ; EPILOG-NEXT: %i11.epil = add nsw i32 %i7.epil, 1
4844 ; EPILOG-NEXT: %innercnd.epil = icmp slt i32 %i11.epil, %trip
4845 ; EPILOG-NEXT: %iv.next.epil = add nuw nsw i64 %phi.epil, 1
4846 ; EPILOG-NEXT: %epil.iter.next = add i32 %epil.iter, 1
4847 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i32 %epil.iter.next, %xtraiter
4848 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %header.epil, label %outerLatch.loopexit.epilog-lcssa, !llvm.loop !13
4849 ; EPILOG: outerLatch.loopexit.epilog-lcssa:
4850 ; EPILOG-NEXT: br label %outerLatch.loopexit
4851 ; EPILOG: outerLatch.loopexit:
4852 ; EPILOG-NEXT: br label %outerLatch
4853 ; EPILOG: outerLatch:
4854 ; EPILOG-NEXT: br label %outerloopHdr
4856 ; EPILOG-BLOCK-LABEL: @test9(
4857 ; EPILOG-BLOCK-NEXT: bb:
4858 ; EPILOG-BLOCK-NEXT: %0 = add i32 %n, -1
4859 ; EPILOG-BLOCK-NEXT: br label %outerloopHdr
4860 ; EPILOG-BLOCK: outerloopHdr:
4861 ; EPILOG-BLOCK-NEXT: %trip = add i32 %n, -1
4862 ; EPILOG-BLOCK-NEXT: %outercnd = icmp slt i32 0, %trip
4863 ; EPILOG-BLOCK-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
4864 ; EPILOG-BLOCK: preheader:
4865 ; EPILOG-BLOCK-NEXT: %1 = freeze i32 %0
4866 ; EPILOG-BLOCK-NEXT: %2 = add i32 %1, -1
4867 ; EPILOG-BLOCK-NEXT: %xtraiter = and i32 %1, 1
4868 ; EPILOG-BLOCK-NEXT: %3 = icmp ult i32 %2, 1
4869 ; EPILOG-BLOCK-NEXT: br i1 %3, label %outerLatch.loopexit.unr-lcssa, label %preheader.new
4870 ; EPILOG-BLOCK: preheader.new:
4871 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i32 %1, %xtraiter
4872 ; EPILOG-BLOCK-NEXT: br label %header
4873 ; EPILOG-BLOCK: header:
4874 ; EPILOG-BLOCK-NEXT: %phi = phi i64 [ 0, %preheader.new ], [ %iv.next.1, %latch.1 ]
4875 ; EPILOG-BLOCK-NEXT: %niter = phi i32 [ 0, %preheader.new ], [ %niter.next.1, %latch.1 ]
4876 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch, label %innerexit.loopexit.loopexit
4877 ; EPILOG-BLOCK: innerexit.loopexit.loopexit:
4878 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph.ph = phi i32 [ %trip, %latch ], [ %trip, %header ]
4879 ; EPILOG-BLOCK-NEXT: br label %innerexit.loopexit
4880 ; EPILOG-BLOCK: innerexit.loopexit.loopexit4:
4881 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph.ph5 = phi i32 [ %trip.1, %latch.13 ], [ %trip.1, %header.1 ]
4882 ; EPILOG-BLOCK-NEXT: br label %innerexit.loopexit
4883 ; EPILOG-BLOCK: innerexit.loopexit:
4884 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph = phi i32 [ %trip.lcssa.ph.ph, %innerexit.loopexit.loopexit ], [ %trip.lcssa.ph.ph5, %innerexit.loopexit.loopexit4 ]
4885 ; EPILOG-BLOCK-NEXT: br label %innerexit
4886 ; EPILOG-BLOCK: innerexit.loopexit1:
4887 ; EPILOG-BLOCK-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.epil ], [ %trip.1, %header.epil.1 ]
4888 ; EPILOG-BLOCK-NEXT: br label %innerexit
4889 ; EPILOG-BLOCK: innerexit:
4890 ; EPILOG-BLOCK-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
4891 ; EPILOG-BLOCK-NEXT: %i9 = call ptr addrspace(1) @foo(i32 %trip.lcssa)
4892 ; EPILOG-BLOCK-NEXT: ret ptr addrspace(1) %i9
4893 ; EPILOG-BLOCK: latch:
4894 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit.loopexit
4895 ; EPILOG-BLOCK: latch.1:
4896 ; EPILOG-BLOCK-NEXT: %iv.next.1 = add nuw nsw i64 %phi, 2
4897 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i32 %niter, 2
4898 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i32 %niter.next.1, %unroll_iter
4899 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %header, label %outerLatch.loopexit.unr-lcssa.loopexit, !llvm.loop !14
4900 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa.loopexit:
4901 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit.unr-lcssa
4902 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa:
4903 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
4904 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.epil.preheader, label %outerLatch.loopexit
4905 ; EPILOG-BLOCK: header.epil.preheader:
4906 ; EPILOG-BLOCK-NEXT: br label %header.epil
4907 ; EPILOG-BLOCK: header.epil:
4908 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.epil, label %innerexit.loopexit1
4909 ; EPILOG-BLOCK: latch.epil:
4910 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit
4911 ; EPILOG-BLOCK: outerLatch.loopexit:
4912 ; EPILOG-BLOCK-NEXT: br label %outerLatch
4913 ; EPILOG-BLOCK: outerLatch:
4914 ; EPILOG-BLOCK-NEXT: %trip.1 = add i32 %n, -1
4915 ; EPILOG-BLOCK-NEXT: %outercnd.1 = icmp slt i32 0, %trip.1
4916 ; EPILOG-BLOCK-NEXT: br i1 %outercnd.1, label %preheader.1, label %outerLatch.1
4917 ; EPILOG-BLOCK: preheader.1:
4918 ; EPILOG-BLOCK-NEXT: %4 = freeze i32 %0
4919 ; EPILOG-BLOCK-NEXT: %5 = add i32 %4, -1
4920 ; EPILOG-BLOCK-NEXT: %xtraiter.1 = and i32 %4, 1
4921 ; EPILOG-BLOCK-NEXT: %6 = icmp ult i32 %5, 1
4922 ; EPILOG-BLOCK-NEXT: br i1 %6, label %outerLatch.loopexit.unr-lcssa.1, label %preheader.new.1
4923 ; EPILOG-BLOCK: preheader.new.1:
4924 ; EPILOG-BLOCK-NEXT: %unroll_iter.1 = sub i32 %4, %xtraiter.1
4925 ; EPILOG-BLOCK-NEXT: br label %header.1
4926 ; EPILOG-BLOCK: header.1:
4927 ; EPILOG-BLOCK-NEXT: %phi.1 = phi i64 [ 0, %preheader.new.1 ], [ %iv.next.1.1, %latch.1.1 ]
4928 ; EPILOG-BLOCK-NEXT: %niter.1 = phi i32 [ 0, %preheader.new.1 ], [ %niter.next.1.1, %latch.1.1 ]
4929 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.13, label %innerexit.loopexit.loopexit4
4930 ; EPILOG-BLOCK: latch.13:
4931 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.1.1, label %innerexit.loopexit.loopexit4
4932 ; EPILOG-BLOCK: latch.1.1:
4933 ; EPILOG-BLOCK-NEXT: %iv.next.1.1 = add nuw nsw i64 %phi.1, 2
4934 ; EPILOG-BLOCK-NEXT: %niter.next.1.1 = add i32 %niter.1, 2
4935 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1.1 = icmp ne i32 %niter.next.1.1, %unroll_iter.1
4936 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1.1, label %header.1, label %outerLatch.loopexit.unr-lcssa.loopexit.1, !llvm.loop !14
4937 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa.loopexit.1:
4938 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit.unr-lcssa.1
4939 ; EPILOG-BLOCK: outerLatch.loopexit.unr-lcssa.1:
4940 ; EPILOG-BLOCK-NEXT: %lcmp.mod.1 = icmp ne i32 %xtraiter.1, 0
4941 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod.1, label %header.epil.preheader.1, label %outerLatch.loopexit.1
4942 ; EPILOG-BLOCK: header.epil.preheader.1:
4943 ; EPILOG-BLOCK-NEXT: br label %header.epil.1
4944 ; EPILOG-BLOCK: header.epil.1:
4945 ; EPILOG-BLOCK-NEXT: br i1 true, label %latch.epil.1, label %innerexit.loopexit1
4946 ; EPILOG-BLOCK: latch.epil.1:
4947 ; EPILOG-BLOCK-NEXT: br label %outerLatch.loopexit.1
4948 ; EPILOG-BLOCK: outerLatch.loopexit.1:
4949 ; EPILOG-BLOCK-NEXT: br label %outerLatch.1
4950 ; EPILOG-BLOCK: outerLatch.1:
4951 ; EPILOG-BLOCK-NEXT: br label %outerloopHdr, !llvm.loop !15
4953 ; PROLOG-LABEL: @test9(
4955 ; PROLOG-NEXT: %0 = add i32 %n, -1
4956 ; PROLOG-NEXT: br label %outerloopHdr
4957 ; PROLOG: outerloopHdr:
4958 ; PROLOG-NEXT: %trip = add i32 %n, -1
4959 ; PROLOG-NEXT: %outercnd = icmp slt i32 0, %trip
4960 ; PROLOG-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
4961 ; PROLOG: preheader:
4962 ; PROLOG-NEXT: %i4 = zext i32 0 to i64
4963 ; PROLOG-NEXT: %1 = freeze i32 %0
4964 ; PROLOG-NEXT: %2 = add i32 %1, -1
4965 ; PROLOG-NEXT: %xtraiter = and i32 %1, 7
4966 ; PROLOG-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
4967 ; PROLOG-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
4968 ; PROLOG: header.prol.preheader:
4969 ; PROLOG-NEXT: br label %header.prol
4970 ; PROLOG: header.prol:
4971 ; PROLOG-NEXT: %phi.prol = phi i64 [ %i4, %header.prol.preheader ], [ %iv.next.prol, %latch.prol ]
4972 ; PROLOG-NEXT: %prol.iter = phi i32 [ 0, %header.prol.preheader ], [ %prol.iter.next, %latch.prol ]
4973 ; PROLOG-NEXT: %i7.prol = trunc i64 %phi.prol to i32
4974 ; PROLOG-NEXT: br i1 true, label %latch.prol, label %innerexit.loopexit1
4975 ; PROLOG: latch.prol:
4976 ; PROLOG-NEXT: %i11.prol = add nsw i32 %i7.prol, 1
4977 ; PROLOG-NEXT: %innercnd.prol = icmp slt i32 %i11.prol, %trip
4978 ; PROLOG-NEXT: %iv.next.prol = add nuw nsw i64 %phi.prol, 1
4979 ; PROLOG-NEXT: %prol.iter.next = add i32 %prol.iter, 1
4980 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i32 %prol.iter.next, %xtraiter
4981 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %header.prol, label %header.prol.loopexit.unr-lcssa, !llvm.loop !13
4982 ; PROLOG: header.prol.loopexit.unr-lcssa:
4983 ; PROLOG-NEXT: %phi.unr.ph = phi i64 [ %iv.next.prol, %latch.prol ]
4984 ; PROLOG-NEXT: br label %header.prol.loopexit
4985 ; PROLOG: header.prol.loopexit:
4986 ; PROLOG-NEXT: %phi.unr = phi i64 [ %i4, %preheader ], [ %phi.unr.ph, %header.prol.loopexit.unr-lcssa ]
4987 ; PROLOG-NEXT: %3 = icmp ult i32 %2, 7
4988 ; PROLOG-NEXT: br i1 %3, label %outerLatch.loopexit, label %preheader.new
4989 ; PROLOG: preheader.new:
4990 ; PROLOG-NEXT: br label %header
4992 ; PROLOG-NEXT: %phi = phi i64 [ %phi.unr, %preheader.new ], [ %iv.next.7, %latch.7 ]
4993 ; PROLOG-NEXT: br i1 true, label %latch, label %innerexit.loopexit
4994 ; PROLOG: innerexit.loopexit:
4995 ; 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 ]
4996 ; PROLOG-NEXT: br label %innerexit
4997 ; PROLOG: innerexit.loopexit1:
4998 ; PROLOG-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.prol ]
4999 ; PROLOG-NEXT: br label %innerexit
5000 ; PROLOG: innerexit:
5001 ; PROLOG-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
5002 ; PROLOG-NEXT: %i9 = call ptr addrspace(1) @foo(i32 %trip.lcssa)
5003 ; PROLOG-NEXT: ret ptr addrspace(1) %i9
5005 ; PROLOG-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit
5007 ; PROLOG-NEXT: br i1 true, label %latch.2, label %innerexit.loopexit
5009 ; PROLOG-NEXT: br i1 true, label %latch.3, label %innerexit.loopexit
5011 ; PROLOG-NEXT: br i1 true, label %latch.4, label %innerexit.loopexit
5013 ; PROLOG-NEXT: br i1 true, label %latch.5, label %innerexit.loopexit
5015 ; PROLOG-NEXT: br i1 true, label %latch.6, label %innerexit.loopexit
5017 ; PROLOG-NEXT: %iv.next.6 = add nuw nsw i64 %phi, 7
5018 ; PROLOG-NEXT: %i7.7 = trunc i64 %iv.next.6 to i32
5019 ; PROLOG-NEXT: br i1 true, label %latch.7, label %innerexit.loopexit
5021 ; PROLOG-NEXT: %i11.7 = add nsw i32 %i7.7, 1
5022 ; PROLOG-NEXT: %innercnd.7 = icmp slt i32 %i11.7, %trip
5023 ; PROLOG-NEXT: %iv.next.7 = add nuw nsw i64 %phi, 8
5024 ; PROLOG-NEXT: br i1 %innercnd.7, label %header, label %outerLatch.loopexit.unr-lcssa
5025 ; PROLOG: outerLatch.loopexit.unr-lcssa:
5026 ; PROLOG-NEXT: br label %outerLatch.loopexit
5027 ; PROLOG: outerLatch.loopexit:
5028 ; PROLOG-NEXT: br label %outerLatch
5029 ; PROLOG: outerLatch:
5030 ; PROLOG-NEXT: br label %outerloopHdr
5032 ; PROLOG-BLOCK-LABEL: @test9(
5033 ; PROLOG-BLOCK-NEXT: bb:
5034 ; PROLOG-BLOCK-NEXT: %0 = add i32 %n, -1
5035 ; PROLOG-BLOCK-NEXT: br label %outerloopHdr
5036 ; PROLOG-BLOCK: outerloopHdr:
5037 ; PROLOG-BLOCK-NEXT: %trip = add i32 %n, -1
5038 ; PROLOG-BLOCK-NEXT: %outercnd = icmp slt i32 0, %trip
5039 ; PROLOG-BLOCK-NEXT: br i1 %outercnd, label %preheader, label %outerLatch
5040 ; PROLOG-BLOCK: preheader:
5041 ; PROLOG-BLOCK-NEXT: %1 = freeze i32 %0
5042 ; PROLOG-BLOCK-NEXT: %2 = add i32 %1, -1
5043 ; PROLOG-BLOCK-NEXT: %xtraiter = and i32 %1, 1
5044 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i32 %xtraiter, 0
5045 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %header.prol.preheader, label %header.prol.loopexit
5046 ; PROLOG-BLOCK: header.prol.preheader:
5047 ; PROLOG-BLOCK-NEXT: br label %header.prol
5048 ; PROLOG-BLOCK: header.prol:
5049 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.prol, label %innerexit.loopexit1
5050 ; PROLOG-BLOCK: latch.prol:
5051 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit
5052 ; PROLOG-BLOCK: header.prol.loopexit:
5053 ; PROLOG-BLOCK-NEXT: %phi.unr = phi i64 [ 0, %preheader ], [ 1, %latch.prol ]
5054 ; PROLOG-BLOCK-NEXT: %3 = icmp ult i32 %2, 1
5055 ; PROLOG-BLOCK-NEXT: br i1 %3, label %outerLatch.loopexit, label %preheader.new
5056 ; PROLOG-BLOCK: preheader.new:
5057 ; PROLOG-BLOCK-NEXT: br label %header
5058 ; PROLOG-BLOCK: header:
5059 ; PROLOG-BLOCK-NEXT: %phi = phi i64 [ %phi.unr, %preheader.new ], [ %iv.next.1, %latch.1 ]
5060 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch, label %innerexit.loopexit.loopexit
5061 ; PROLOG-BLOCK: innerexit.loopexit.loopexit:
5062 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph.ph = phi i32 [ %trip, %latch ], [ %trip, %header ]
5063 ; PROLOG-BLOCK-NEXT: br label %innerexit.loopexit
5064 ; PROLOG-BLOCK: innerexit.loopexit.loopexit5:
5065 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph.ph6 = phi i32 [ %trip.1, %latch.14 ], [ %trip.1, %header.1 ]
5066 ; PROLOG-BLOCK-NEXT: br label %innerexit.loopexit
5067 ; PROLOG-BLOCK: innerexit.loopexit:
5068 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph = phi i32 [ %trip.lcssa.ph.ph, %innerexit.loopexit.loopexit ], [ %trip.lcssa.ph.ph6, %innerexit.loopexit.loopexit5 ]
5069 ; PROLOG-BLOCK-NEXT: br label %innerexit
5070 ; PROLOG-BLOCK: innerexit.loopexit1:
5071 ; PROLOG-BLOCK-NEXT: %trip.lcssa.ph2 = phi i32 [ %trip, %header.prol ], [ %trip.1, %header.prol.1 ]
5072 ; PROLOG-BLOCK-NEXT: br label %innerexit
5073 ; PROLOG-BLOCK: innerexit:
5074 ; PROLOG-BLOCK-NEXT: %trip.lcssa = phi i32 [ %trip.lcssa.ph, %innerexit.loopexit ], [ %trip.lcssa.ph2, %innerexit.loopexit1 ]
5075 ; PROLOG-BLOCK-NEXT: %i9 = call ptr addrspace(1) @foo(i32 %trip.lcssa)
5076 ; PROLOG-BLOCK-NEXT: ret ptr addrspace(1) %i9
5077 ; PROLOG-BLOCK: latch:
5078 ; PROLOG-BLOCK-NEXT: %iv.next = add nuw nsw i64 %phi, 1
5079 ; PROLOG-BLOCK-NEXT: %i7.1 = trunc i64 %iv.next to i32
5080 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.1, label %innerexit.loopexit.loopexit
5081 ; PROLOG-BLOCK: latch.1:
5082 ; PROLOG-BLOCK-NEXT: %i11.1 = add nsw i32 %i7.1, 1
5083 ; PROLOG-BLOCK-NEXT: %innercnd.1 = icmp slt i32 %i11.1, %trip
5084 ; PROLOG-BLOCK-NEXT: %iv.next.1 = add nuw nsw i64 %phi, 2
5085 ; PROLOG-BLOCK-NEXT: br i1 %innercnd.1, label %header, label %outerLatch.loopexit.unr-lcssa, !llvm.loop !14
5086 ; PROLOG-BLOCK: outerLatch.loopexit.unr-lcssa:
5087 ; PROLOG-BLOCK-NEXT: br label %outerLatch.loopexit
5088 ; PROLOG-BLOCK: outerLatch.loopexit:
5089 ; PROLOG-BLOCK-NEXT: br label %outerLatch
5090 ; PROLOG-BLOCK: outerLatch:
5091 ; PROLOG-BLOCK-NEXT: %trip.1 = add i32 %n, -1
5092 ; PROLOG-BLOCK-NEXT: %outercnd.1 = icmp slt i32 0, %trip.1
5093 ; PROLOG-BLOCK-NEXT: br i1 %outercnd.1, label %preheader.1, label %outerLatch.1
5094 ; PROLOG-BLOCK: preheader.1:
5095 ; PROLOG-BLOCK-NEXT: %4 = freeze i32 %0
5096 ; PROLOG-BLOCK-NEXT: %5 = add i32 %4, -1
5097 ; PROLOG-BLOCK-NEXT: %xtraiter.1 = and i32 %4, 1
5098 ; PROLOG-BLOCK-NEXT: %lcmp.mod.1 = icmp ne i32 %xtraiter.1, 0
5099 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod.1, label %header.prol.preheader.1, label %header.prol.loopexit.1
5100 ; PROLOG-BLOCK: header.prol.preheader.1:
5101 ; PROLOG-BLOCK-NEXT: br label %header.prol.1
5102 ; PROLOG-BLOCK: header.prol.1:
5103 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.prol.1, label %innerexit.loopexit1
5104 ; PROLOG-BLOCK: latch.prol.1:
5105 ; PROLOG-BLOCK-NEXT: br label %header.prol.loopexit.1
5106 ; PROLOG-BLOCK: header.prol.loopexit.1:
5107 ; PROLOG-BLOCK-NEXT: %phi.unr.1 = phi i64 [ 0, %preheader.1 ], [ 1, %latch.prol.1 ]
5108 ; PROLOG-BLOCK-NEXT: %6 = icmp ult i32 %5, 1
5109 ; PROLOG-BLOCK-NEXT: br i1 %6, label %outerLatch.loopexit.1, label %preheader.new.1
5110 ; PROLOG-BLOCK: preheader.new.1:
5111 ; PROLOG-BLOCK-NEXT: br label %header.1
5112 ; PROLOG-BLOCK: header.1:
5113 ; PROLOG-BLOCK-NEXT: %phi.1 = phi i64 [ %phi.unr.1, %preheader.new.1 ], [ %iv.next.1.1, %latch.1.1 ]
5114 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.14, label %innerexit.loopexit.loopexit5
5115 ; PROLOG-BLOCK: latch.14:
5116 ; PROLOG-BLOCK-NEXT: %iv.next.13 = add nuw nsw i64 %phi.1, 1
5117 ; PROLOG-BLOCK-NEXT: %i7.1.1 = trunc i64 %iv.next.13 to i32
5118 ; PROLOG-BLOCK-NEXT: br i1 true, label %latch.1.1, label %innerexit.loopexit.loopexit5
5119 ; PROLOG-BLOCK: latch.1.1:
5120 ; PROLOG-BLOCK-NEXT: %i11.1.1 = add nsw i32 %i7.1.1, 1
5121 ; PROLOG-BLOCK-NEXT: %innercnd.1.1 = icmp slt i32 %i11.1.1, %trip.1
5122 ; PROLOG-BLOCK-NEXT: %iv.next.1.1 = add nuw nsw i64 %phi.1, 2
5123 ; PROLOG-BLOCK-NEXT: br i1 %innercnd.1.1, label %header.1, label %outerLatch.loopexit.unr-lcssa.1, !llvm.loop !14
5124 ; PROLOG-BLOCK: outerLatch.loopexit.unr-lcssa.1:
5125 ; PROLOG-BLOCK-NEXT: br label %outerLatch.loopexit.1
5126 ; PROLOG-BLOCK: outerLatch.loopexit.1:
5127 ; PROLOG-BLOCK-NEXT: br label %outerLatch.1
5128 ; PROLOG-BLOCK: outerLatch.1:
5129 ; PROLOG-BLOCK-NEXT: br label %outerloopHdr, !llvm.loop !15
5132 br label %outerloopHdr
5134 outerloopHdr: ; preds = %outerLatch, %bb
5135 %trip = add i32 %n, -1
5136 %outercnd = icmp slt i32 0, %trip
5137 br i1 %outercnd, label %preheader, label %outerLatch
5139 preheader: ; preds = %outerloopHdr
5140 %i4 = zext i32 0 to i64
5143 header: ; preds = %latch, %preheader
5144 %phi = phi i64 [ %i4, %preheader ], [ %iv.next, %latch ]
5145 %i7 = trunc i64 %phi to i32
5146 br i1 true, label %latch, label %innerexit
5148 innerexit: ; preds = %header
5149 %i9 = call ptr addrspace(1) @foo(i32 %trip)
5150 ret ptr addrspace(1) %i9
5152 latch: ; preds = %header
5153 %i11 = add nsw i32 %i7, 1
5154 %innercnd = icmp slt i32 %i11, %trip
5155 %iv.next = add nuw nsw i64 %phi, 1
5156 br i1 %innercnd, label %header, label %outerLatch
5158 outerLatch: ; preds = %latch, %outerloopHdr
5159 br label %outerloopHdr
5164 ; This is a case where we should be able to eliminate N-1 copies
5165 ; of the early exit test in the main loop when runtime unrolling
5167 define void @test10(i64 %trip, i64 %trip2) {
5168 ; EPILOG-LABEL: @test10(
5169 ; EPILOG-NEXT: entry:
5170 ; EPILOG-NEXT: %0 = freeze i64 %trip
5171 ; EPILOG-NEXT: %1 = add i64 %0, -1
5172 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
5173 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
5174 ; EPILOG-NEXT: br i1 %2, label %exit2.unr-lcssa, label %entry.new
5175 ; EPILOG: entry.new:
5176 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5177 ; EPILOG-NEXT: br label %loop_header
5178 ; EPILOG: loop_header:
5179 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5180 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
5181 ; EPILOG-NEXT: call void @bar()
5182 ; EPILOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5183 ; EPILOG-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5184 ; EPILOG: loop_latch:
5185 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5186 ; EPILOG-NEXT: call void @bar()
5187 ; EPILOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5188 ; EPILOG-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5189 ; EPILOG: loop_latch.1:
5190 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv, 2
5191 ; EPILOG-NEXT: call void @bar()
5192 ; EPILOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5193 ; EPILOG-NEXT: br i1 %cmp_early.2, label %loop_latch.2, label %exit1.loopexit
5194 ; EPILOG: loop_latch.2:
5195 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv, 3
5196 ; EPILOG-NEXT: call void @bar()
5197 ; EPILOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5198 ; EPILOG-NEXT: br i1 %cmp_early.3, label %loop_latch.3, label %exit1.loopexit
5199 ; EPILOG: loop_latch.3:
5200 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv, 4
5201 ; EPILOG-NEXT: call void @bar()
5202 ; EPILOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5203 ; EPILOG-NEXT: br i1 %cmp_early.4, label %loop_latch.4, label %exit1.loopexit
5204 ; EPILOG: loop_latch.4:
5205 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv, 5
5206 ; EPILOG-NEXT: call void @bar()
5207 ; EPILOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5208 ; EPILOG-NEXT: br i1 %cmp_early.5, label %loop_latch.5, label %exit1.loopexit
5209 ; EPILOG: loop_latch.5:
5210 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv, 6
5211 ; EPILOG-NEXT: call void @bar()
5212 ; EPILOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5213 ; EPILOG-NEXT: br i1 %cmp_early.6, label %loop_latch.6, label %exit1.loopexit
5214 ; EPILOG: loop_latch.6:
5215 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv, 7
5216 ; EPILOG-NEXT: call void @bar()
5217 ; EPILOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5218 ; EPILOG-NEXT: br i1 %cmp_early.7, label %loop_latch.7, label %exit1.loopexit
5219 ; EPILOG: loop_latch.7:
5220 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv, 8
5221 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
5222 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
5223 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.unr-lcssa.loopexit
5224 ; EPILOG: exit1.loopexit:
5225 ; EPILOG-NEXT: br label %exit1
5226 ; EPILOG: exit1.loopexit1:
5227 ; EPILOG-NEXT: br label %exit1
5229 ; EPILOG-NEXT: ret void
5230 ; EPILOG: exit2.unr-lcssa.loopexit:
5231 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
5232 ; EPILOG-NEXT: br label %exit2.unr-lcssa
5233 ; EPILOG: exit2.unr-lcssa:
5234 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.unr-lcssa.loopexit ]
5235 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5236 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5237 ; EPILOG: loop_header.epil.preheader:
5238 ; EPILOG-NEXT: br label %loop_header.epil
5239 ; EPILOG: loop_header.epil:
5240 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
5241 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
5242 ; EPILOG-NEXT: call void @bar()
5243 ; EPILOG-NEXT: %cmp_early.epil = icmp ne i64 %iv.epil, %trip2
5244 ; EPILOG-NEXT: br i1 %cmp_early.epil, label %loop_latch.epil, label %exit1.loopexit1
5245 ; EPILOG: loop_latch.epil:
5246 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
5247 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
5248 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
5249 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
5250 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.epilog-lcssa, !llvm.loop !14
5251 ; EPILOG: exit2.epilog-lcssa:
5252 ; EPILOG-NEXT: br label %exit2
5254 ; EPILOG-NEXT: ret void
5256 ; EPILOG-BLOCK-LABEL: @test10(
5257 ; EPILOG-BLOCK-NEXT: entry:
5258 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
5259 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
5260 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5261 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5262 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit2.unr-lcssa, label %entry.new
5263 ; EPILOG-BLOCK: entry.new:
5264 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5265 ; EPILOG-BLOCK-NEXT: br label %loop_header
5266 ; EPILOG-BLOCK: loop_header:
5267 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5268 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
5269 ; EPILOG-BLOCK-NEXT: call void @bar()
5270 ; EPILOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5271 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5272 ; EPILOG-BLOCK: loop_latch:
5273 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5274 ; EPILOG-BLOCK-NEXT: call void @bar()
5275 ; EPILOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5276 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5277 ; EPILOG-BLOCK: loop_latch.1:
5278 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
5279 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
5280 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
5281 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.unr-lcssa.loopexit, !llvm.loop !16
5282 ; EPILOG-BLOCK: exit1.loopexit:
5283 ; EPILOG-BLOCK-NEXT: br label %exit1
5284 ; EPILOG-BLOCK: exit1:
5285 ; EPILOG-BLOCK-NEXT: ret void
5286 ; EPILOG-BLOCK: exit2.unr-lcssa.loopexit:
5287 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
5288 ; EPILOG-BLOCK-NEXT: br label %exit2.unr-lcssa
5289 ; EPILOG-BLOCK: exit2.unr-lcssa:
5290 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.unr-lcssa.loopexit ]
5291 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5292 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5293 ; EPILOG-BLOCK: loop_header.epil.preheader:
5294 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
5295 ; EPILOG-BLOCK: loop_header.epil:
5296 ; EPILOG-BLOCK-NEXT: call void @bar()
5297 ; EPILOG-BLOCK-NEXT: %cmp_early.epil = icmp ne i64 %iv.unr, %trip2
5298 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.epil, label %loop_latch.epil, label %exit1
5299 ; EPILOG-BLOCK: loop_latch.epil:
5300 ; EPILOG-BLOCK-NEXT: br label %exit2
5301 ; EPILOG-BLOCK: exit2:
5302 ; EPILOG-BLOCK-NEXT: ret void
5304 ; PROLOG-LABEL: @test10(
5305 ; PROLOG-NEXT: entry:
5306 ; PROLOG-NEXT: %0 = freeze i64 %trip
5307 ; PROLOG-NEXT: %1 = add i64 %0, -1
5308 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
5309 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5310 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5311 ; PROLOG: loop_header.prol.preheader:
5312 ; PROLOG-NEXT: br label %loop_header.prol
5313 ; PROLOG: loop_header.prol:
5314 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
5315 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
5316 ; PROLOG-NEXT: call void @bar()
5317 ; PROLOG-NEXT: %cmp_early.prol = icmp ne i64 %iv.prol, %trip2
5318 ; PROLOG-NEXT: br i1 %cmp_early.prol, label %loop_latch.prol, label %exit1.loopexit1
5319 ; PROLOG: loop_latch.prol:
5320 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
5321 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
5322 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
5323 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
5324 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !14
5325 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
5326 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
5327 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
5328 ; PROLOG: loop_header.prol.loopexit:
5329 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
5330 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
5331 ; PROLOG-NEXT: br i1 %2, label %exit2, label %entry.new
5332 ; PROLOG: entry.new:
5333 ; PROLOG-NEXT: br label %loop_header
5334 ; PROLOG: loop_header:
5335 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5336 ; PROLOG-NEXT: call void @bar()
5337 ; PROLOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5338 ; PROLOG-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5339 ; PROLOG: loop_latch:
5340 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
5341 ; PROLOG-NEXT: call void @bar()
5342 ; PROLOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5343 ; PROLOG-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5344 ; PROLOG: loop_latch.1:
5345 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv, 2
5346 ; PROLOG-NEXT: call void @bar()
5347 ; PROLOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5348 ; PROLOG-NEXT: br i1 %cmp_early.2, label %loop_latch.2, label %exit1.loopexit
5349 ; PROLOG: loop_latch.2:
5350 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv, 3
5351 ; PROLOG-NEXT: call void @bar()
5352 ; PROLOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5353 ; PROLOG-NEXT: br i1 %cmp_early.3, label %loop_latch.3, label %exit1.loopexit
5354 ; PROLOG: loop_latch.3:
5355 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv, 4
5356 ; PROLOG-NEXT: call void @bar()
5357 ; PROLOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5358 ; PROLOG-NEXT: br i1 %cmp_early.4, label %loop_latch.4, label %exit1.loopexit
5359 ; PROLOG: loop_latch.4:
5360 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv, 5
5361 ; PROLOG-NEXT: call void @bar()
5362 ; PROLOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5363 ; PROLOG-NEXT: br i1 %cmp_early.5, label %loop_latch.5, label %exit1.loopexit
5364 ; PROLOG: loop_latch.5:
5365 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv, 6
5366 ; PROLOG-NEXT: call void @bar()
5367 ; PROLOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5368 ; PROLOG-NEXT: br i1 %cmp_early.6, label %loop_latch.6, label %exit1.loopexit
5369 ; PROLOG: loop_latch.6:
5370 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv, 7
5371 ; PROLOG-NEXT: call void @bar()
5372 ; PROLOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5373 ; PROLOG-NEXT: br i1 %cmp_early.7, label %loop_latch.7, label %exit1.loopexit
5374 ; PROLOG: loop_latch.7:
5375 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv, 8
5376 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
5377 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.unr-lcssa
5378 ; PROLOG: exit1.loopexit:
5379 ; PROLOG-NEXT: br label %exit1
5380 ; PROLOG: exit1.loopexit1:
5381 ; PROLOG-NEXT: br label %exit1
5383 ; PROLOG-NEXT: ret void
5384 ; PROLOG: exit2.unr-lcssa:
5385 ; PROLOG-NEXT: br label %exit2
5387 ; PROLOG-NEXT: ret void
5389 ; PROLOG-BLOCK-LABEL: @test10(
5390 ; PROLOG-BLOCK-NEXT: entry:
5391 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
5392 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
5393 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5394 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5395 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5396 ; PROLOG-BLOCK: loop_header.prol.preheader:
5397 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
5398 ; PROLOG-BLOCK: loop_header.prol:
5399 ; PROLOG-BLOCK-NEXT: call void @bar()
5400 ; PROLOG-BLOCK-NEXT: %cmp_early.prol = icmp ne i64 0, %trip2
5401 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.prol, label %loop_latch.prol, label %exit1
5402 ; PROLOG-BLOCK: loop_latch.prol:
5403 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
5404 ; PROLOG-BLOCK: loop_header.prol.loopexit:
5405 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
5406 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5407 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit2, label %entry.new
5408 ; PROLOG-BLOCK: entry.new:
5409 ; PROLOG-BLOCK-NEXT: br label %loop_header
5410 ; PROLOG-BLOCK: loop_header:
5411 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5412 ; PROLOG-BLOCK-NEXT: call void @bar()
5413 ; PROLOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5414 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_latch, label %exit1.loopexit
5415 ; PROLOG-BLOCK: loop_latch:
5416 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
5417 ; PROLOG-BLOCK-NEXT: call void @bar()
5418 ; PROLOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5419 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_latch.1, label %exit1.loopexit
5420 ; PROLOG-BLOCK: loop_latch.1:
5421 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
5422 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
5423 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.unr-lcssa, !llvm.loop !16
5424 ; PROLOG-BLOCK: exit1.loopexit:
5425 ; PROLOG-BLOCK-NEXT: br label %exit1
5426 ; PROLOG-BLOCK: exit1:
5427 ; PROLOG-BLOCK-NEXT: ret void
5428 ; PROLOG-BLOCK: exit2.unr-lcssa:
5429 ; PROLOG-BLOCK-NEXT: br label %exit2
5430 ; PROLOG-BLOCK: exit2:
5431 ; PROLOG-BLOCK-NEXT: ret void
5434 br label %loop_header
5437 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
5439 %cmp_early = icmp ne i64 %iv, %trip2
5440 br i1 %cmp_early, label %loop_latch, label %exit1
5443 %iv_next = add i64 %iv, 1
5444 %cmp = icmp ne i64 %iv_next, %trip
5445 br i1 %cmp, label %loop_header, label %exit2
5454 ; With a loop invariant, we can eliminate the last N-1
5455 ; copies of the exit test in the unrolled main loop body.
5456 define void @test11(i64 %trip, i1 %cond) {
5457 ; EPILOG-LABEL: @test11(
5458 ; EPILOG-NEXT: entry:
5459 ; EPILOG-NEXT: %0 = freeze i64 %trip
5460 ; EPILOG-NEXT: %1 = add i64 %0, -1
5461 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
5462 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
5463 ; EPILOG-NEXT: br i1 %2, label %exit2.unr-lcssa, label %entry.new
5464 ; EPILOG: entry.new:
5465 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5466 ; EPILOG-NEXT: br label %loop_header
5467 ; EPILOG: loop_header:
5468 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5469 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
5470 ; EPILOG-NEXT: call void @bar()
5471 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5472 ; EPILOG: loop_latch:
5473 ; EPILOG-NEXT: call void @bar()
5474 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5475 ; EPILOG: loop_latch.1:
5476 ; EPILOG-NEXT: call void @bar()
5477 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.loopexit
5478 ; EPILOG: loop_latch.2:
5479 ; EPILOG-NEXT: call void @bar()
5480 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.loopexit
5481 ; EPILOG: loop_latch.3:
5482 ; EPILOG-NEXT: call void @bar()
5483 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.loopexit
5484 ; EPILOG: loop_latch.4:
5485 ; EPILOG-NEXT: call void @bar()
5486 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.loopexit
5487 ; EPILOG: loop_latch.5:
5488 ; EPILOG-NEXT: call void @bar()
5489 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.loopexit
5490 ; EPILOG: loop_latch.6:
5491 ; EPILOG-NEXT: call void @bar()
5492 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.loopexit
5493 ; EPILOG: loop_latch.7:
5494 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv, 8
5495 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
5496 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
5497 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit2.unr-lcssa.loopexit
5498 ; EPILOG: exit1.loopexit:
5499 ; EPILOG-NEXT: br label %exit1
5500 ; EPILOG: exit1.loopexit1:
5501 ; EPILOG-NEXT: br label %exit1
5503 ; EPILOG-NEXT: ret void
5504 ; EPILOG: exit2.unr-lcssa.loopexit:
5505 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
5506 ; EPILOG-NEXT: br label %exit2.unr-lcssa
5507 ; EPILOG: exit2.unr-lcssa:
5508 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit2.unr-lcssa.loopexit ]
5509 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5510 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5511 ; EPILOG: loop_header.epil.preheader:
5512 ; EPILOG-NEXT: br label %loop_header.epil
5513 ; EPILOG: loop_header.epil:
5514 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
5515 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
5516 ; EPILOG-NEXT: call void @bar()
5517 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1.loopexit1
5518 ; EPILOG: loop_latch.epil:
5519 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
5520 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
5521 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
5522 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
5523 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit2.epilog-lcssa, !llvm.loop !15
5524 ; EPILOG: exit2.epilog-lcssa:
5525 ; EPILOG-NEXT: br label %exit2
5527 ; EPILOG-NEXT: ret void
5529 ; EPILOG-BLOCK-LABEL: @test11(
5530 ; EPILOG-BLOCK-NEXT: entry:
5531 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
5532 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
5533 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5534 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5535 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit2.unr-lcssa, label %entry.new
5536 ; EPILOG-BLOCK: entry.new:
5537 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5538 ; EPILOG-BLOCK-NEXT: br label %loop_header
5539 ; EPILOG-BLOCK: loop_header:
5540 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5541 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
5542 ; EPILOG-BLOCK-NEXT: call void @bar()
5543 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5544 ; EPILOG-BLOCK: loop_latch:
5545 ; EPILOG-BLOCK-NEXT: call void @bar()
5546 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5547 ; EPILOG-BLOCK: loop_latch.1:
5548 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
5549 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
5550 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
5551 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit2.unr-lcssa.loopexit, !llvm.loop !17
5552 ; EPILOG-BLOCK: exit1.loopexit:
5553 ; EPILOG-BLOCK-NEXT: br label %exit1
5554 ; EPILOG-BLOCK: exit1:
5555 ; EPILOG-BLOCK-NEXT: ret void
5556 ; EPILOG-BLOCK: exit2.unr-lcssa.loopexit:
5557 ; EPILOG-BLOCK-NEXT: br label %exit2.unr-lcssa
5558 ; EPILOG-BLOCK: exit2.unr-lcssa:
5559 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5560 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit2
5561 ; EPILOG-BLOCK: loop_header.epil.preheader:
5562 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
5563 ; EPILOG-BLOCK: loop_header.epil:
5564 ; EPILOG-BLOCK-NEXT: call void @bar()
5565 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1
5566 ; EPILOG-BLOCK: loop_latch.epil:
5567 ; EPILOG-BLOCK-NEXT: br label %exit2
5568 ; EPILOG-BLOCK: exit2:
5569 ; EPILOG-BLOCK-NEXT: ret void
5571 ; PROLOG-LABEL: @test11(
5572 ; PROLOG-NEXT: entry:
5573 ; PROLOG-NEXT: %0 = freeze i64 %trip
5574 ; PROLOG-NEXT: %1 = add i64 %0, -1
5575 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
5576 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5577 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5578 ; PROLOG: loop_header.prol.preheader:
5579 ; PROLOG-NEXT: br label %loop_header.prol
5580 ; PROLOG: loop_header.prol:
5581 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
5582 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
5583 ; PROLOG-NEXT: call void @bar()
5584 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1.loopexit1
5585 ; PROLOG: loop_latch.prol:
5586 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
5587 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
5588 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
5589 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
5590 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !15
5591 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
5592 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
5593 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
5594 ; PROLOG: loop_header.prol.loopexit:
5595 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
5596 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
5597 ; PROLOG-NEXT: br i1 %2, label %exit2, label %entry.new
5598 ; PROLOG: entry.new:
5599 ; PROLOG-NEXT: br label %loop_header
5600 ; PROLOG: loop_header:
5601 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5602 ; PROLOG-NEXT: call void @bar()
5603 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5604 ; PROLOG: loop_latch:
5605 ; PROLOG-NEXT: call void @bar()
5606 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5607 ; PROLOG: loop_latch.1:
5608 ; PROLOG-NEXT: call void @bar()
5609 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.loopexit
5610 ; PROLOG: loop_latch.2:
5611 ; PROLOG-NEXT: call void @bar()
5612 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.loopexit
5613 ; PROLOG: loop_latch.3:
5614 ; PROLOG-NEXT: call void @bar()
5615 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.loopexit
5616 ; PROLOG: loop_latch.4:
5617 ; PROLOG-NEXT: call void @bar()
5618 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.loopexit
5619 ; PROLOG: loop_latch.5:
5620 ; PROLOG-NEXT: call void @bar()
5621 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.loopexit
5622 ; PROLOG: loop_latch.6:
5623 ; PROLOG-NEXT: call void @bar()
5624 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.loopexit
5625 ; PROLOG: loop_latch.7:
5626 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv, 8
5627 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
5628 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit2.unr-lcssa
5629 ; PROLOG: exit1.loopexit:
5630 ; PROLOG-NEXT: br label %exit1
5631 ; PROLOG: exit1.loopexit1:
5632 ; PROLOG-NEXT: br label %exit1
5634 ; PROLOG-NEXT: ret void
5635 ; PROLOG: exit2.unr-lcssa:
5636 ; PROLOG-NEXT: br label %exit2
5638 ; PROLOG-NEXT: ret void
5640 ; PROLOG-BLOCK-LABEL: @test11(
5641 ; PROLOG-BLOCK-NEXT: entry:
5642 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
5643 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
5644 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5645 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5646 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5647 ; PROLOG-BLOCK: loop_header.prol.preheader:
5648 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
5649 ; PROLOG-BLOCK: loop_header.prol:
5650 ; PROLOG-BLOCK-NEXT: call void @bar()
5651 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1
5652 ; PROLOG-BLOCK: loop_latch.prol:
5653 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
5654 ; PROLOG-BLOCK: loop_header.prol.loopexit:
5655 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
5656 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5657 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit2, label %entry.new
5658 ; PROLOG-BLOCK: entry.new:
5659 ; PROLOG-BLOCK-NEXT: br label %loop_header
5660 ; PROLOG-BLOCK: loop_header:
5661 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5662 ; PROLOG-BLOCK-NEXT: call void @bar()
5663 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.loopexit
5664 ; PROLOG-BLOCK: loop_latch:
5665 ; PROLOG-BLOCK-NEXT: call void @bar()
5666 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.loopexit
5667 ; PROLOG-BLOCK: loop_latch.1:
5668 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
5669 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
5670 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit2.unr-lcssa, !llvm.loop !17
5671 ; PROLOG-BLOCK: exit1.loopexit:
5672 ; PROLOG-BLOCK-NEXT: br label %exit1
5673 ; PROLOG-BLOCK: exit1:
5674 ; PROLOG-BLOCK-NEXT: ret void
5675 ; PROLOG-BLOCK: exit2.unr-lcssa:
5676 ; PROLOG-BLOCK-NEXT: br label %exit2
5677 ; PROLOG-BLOCK: exit2:
5678 ; PROLOG-BLOCK-NEXT: ret void
5681 br label %loop_header
5684 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
5686 br i1 %cond, label %loop_latch, label %exit1
5689 %iv_next = add i64 %iv, 1
5690 %cmp = icmp ne i64 %iv_next, %trip
5691 br i1 %cmp, label %loop_header, label %exit2
5700 ; Combine a computeable and invariant test to make sure
5701 ; the interaction of both doesn't do anything weird
5702 define void @test12(i64 %trip, i64 %trip2, i1 %cond) {
5703 ; EPILOG-LABEL: @test12(
5704 ; EPILOG-NEXT: entry:
5705 ; EPILOG-NEXT: %0 = freeze i64 %trip
5706 ; EPILOG-NEXT: %1 = add i64 %0, -1
5707 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
5708 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
5709 ; EPILOG-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
5710 ; EPILOG: entry.new:
5711 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5712 ; EPILOG-NEXT: br label %loop_header
5713 ; EPILOG: loop_header:
5714 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5715 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
5716 ; EPILOG-NEXT: call void @bar()
5717 ; EPILOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5718 ; EPILOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
5719 ; EPILOG: loop_exiting_bb2:
5720 ; EPILOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.epilog-lcssa.loopexit
5721 ; EPILOG: loop_latch:
5722 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5723 ; EPILOG-NEXT: call void @bar()
5724 ; EPILOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5725 ; EPILOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
5726 ; EPILOG: loop_exiting_bb2.1:
5727 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
5728 ; EPILOG: loop_latch.1:
5729 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv, 2
5730 ; EPILOG-NEXT: call void @bar()
5731 ; EPILOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5732 ; EPILOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.epilog-lcssa.loopexit
5733 ; EPILOG: loop_exiting_bb2.2:
5734 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.epilog-lcssa.loopexit
5735 ; EPILOG: loop_latch.2:
5736 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv, 3
5737 ; EPILOG-NEXT: call void @bar()
5738 ; EPILOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5739 ; EPILOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.epilog-lcssa.loopexit
5740 ; EPILOG: loop_exiting_bb2.3:
5741 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.epilog-lcssa.loopexit
5742 ; EPILOG: loop_latch.3:
5743 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv, 4
5744 ; EPILOG-NEXT: call void @bar()
5745 ; EPILOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5746 ; EPILOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.epilog-lcssa.loopexit
5747 ; EPILOG: loop_exiting_bb2.4:
5748 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.epilog-lcssa.loopexit
5749 ; EPILOG: loop_latch.4:
5750 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv, 5
5751 ; EPILOG-NEXT: call void @bar()
5752 ; EPILOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5753 ; EPILOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.epilog-lcssa.loopexit
5754 ; EPILOG: loop_exiting_bb2.5:
5755 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.epilog-lcssa.loopexit
5756 ; EPILOG: loop_latch.5:
5757 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv, 6
5758 ; EPILOG-NEXT: call void @bar()
5759 ; EPILOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5760 ; EPILOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.epilog-lcssa.loopexit
5761 ; EPILOG: loop_exiting_bb2.6:
5762 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.epilog-lcssa.loopexit
5763 ; EPILOG: loop_latch.6:
5764 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv, 7
5765 ; EPILOG-NEXT: call void @bar()
5766 ; EPILOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5767 ; EPILOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.epilog-lcssa.loopexit
5768 ; EPILOG: loop_exiting_bb2.7:
5769 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.epilog-lcssa.loopexit
5770 ; EPILOG: loop_latch.7:
5771 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv, 8
5772 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
5773 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
5774 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
5775 ; EPILOG: exit1.unr-lcssa.loopexit:
5776 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
5777 ; EPILOG-NEXT: br label %exit1.unr-lcssa
5778 ; EPILOG: exit1.unr-lcssa:
5779 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
5780 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5781 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
5782 ; EPILOG: loop_header.epil.preheader:
5783 ; EPILOG-NEXT: br label %loop_header.epil
5784 ; EPILOG: loop_header.epil:
5785 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
5786 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
5787 ; EPILOG-NEXT: call void @bar()
5788 ; EPILOG-NEXT: %cmp_early.epil = icmp ne i64 %iv.epil, %trip2
5789 ; EPILOG-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa.loopexit1
5790 ; EPILOG: loop_exiting_bb2.epil:
5791 ; EPILOG-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1.epilog-lcssa.loopexit1
5792 ; EPILOG: loop_latch.epil:
5793 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
5794 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
5795 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
5796 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
5797 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit1.epilog-lcssa.loopexit1, !llvm.loop !16
5798 ; EPILOG: exit1.epilog-lcssa.loopexit:
5799 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
5800 ; EPILOG: exit1.epilog-lcssa.loopexit1:
5801 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
5802 ; EPILOG: exit1.epilog-lcssa:
5803 ; EPILOG-NEXT: br label %exit1
5805 ; EPILOG-NEXT: ret void
5807 ; EPILOG-BLOCK-LABEL: @test12(
5808 ; EPILOG-BLOCK-NEXT: entry:
5809 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
5810 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
5811 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5812 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5813 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
5814 ; EPILOG-BLOCK: entry.new:
5815 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
5816 ; EPILOG-BLOCK-NEXT: br label %loop_header
5817 ; EPILOG-BLOCK: loop_header:
5818 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5819 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
5820 ; EPILOG-BLOCK-NEXT: call void @bar()
5821 ; EPILOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5822 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
5823 ; EPILOG-BLOCK: loop_exiting_bb2:
5824 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.epilog-lcssa.loopexit
5825 ; EPILOG-BLOCK: loop_latch:
5826 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
5827 ; EPILOG-BLOCK-NEXT: call void @bar()
5828 ; EPILOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5829 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
5830 ; EPILOG-BLOCK: loop_exiting_bb2.1:
5831 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
5832 ; EPILOG-BLOCK: loop_latch.1:
5833 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
5834 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
5835 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
5836 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !18
5837 ; EPILOG-BLOCK: exit1.unr-lcssa.loopexit:
5838 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
5839 ; EPILOG-BLOCK-NEXT: br label %exit1.unr-lcssa
5840 ; EPILOG-BLOCK: exit1.unr-lcssa:
5841 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
5842 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5843 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
5844 ; EPILOG-BLOCK: loop_header.epil.preheader:
5845 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
5846 ; EPILOG-BLOCK: loop_header.epil:
5847 ; EPILOG-BLOCK-NEXT: call void @bar()
5848 ; EPILOG-BLOCK-NEXT: %cmp_early.epil = icmp ne i64 %iv.unr, %trip2
5849 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa
5850 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
5851 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.epil, label %exit1.epilog-lcssa
5852 ; EPILOG-BLOCK: loop_latch.epil:
5853 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
5854 ; EPILOG-BLOCK: exit1.epilog-lcssa.loopexit:
5855 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
5856 ; EPILOG-BLOCK: exit1.epilog-lcssa:
5857 ; EPILOG-BLOCK-NEXT: br label %exit1
5858 ; EPILOG-BLOCK: exit1:
5859 ; EPILOG-BLOCK-NEXT: ret void
5861 ; PROLOG-LABEL: @test12(
5862 ; PROLOG-NEXT: entry:
5863 ; PROLOG-NEXT: %0 = freeze i64 %trip
5864 ; PROLOG-NEXT: %1 = add i64 %0, -1
5865 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
5866 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5867 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5868 ; PROLOG: loop_header.prol.preheader:
5869 ; PROLOG-NEXT: br label %loop_header.prol
5870 ; PROLOG: loop_header.prol:
5871 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
5872 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
5873 ; PROLOG-NEXT: call void @bar()
5874 ; PROLOG-NEXT: %cmp_early.prol = icmp ne i64 %iv.prol, %trip2
5875 ; PROLOG-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa.loopexit1
5876 ; PROLOG: loop_exiting_bb2.prol:
5877 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1.unr-lcssa.loopexit1
5878 ; PROLOG: loop_latch.prol:
5879 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
5880 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
5881 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
5882 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
5883 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !16
5884 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
5885 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
5886 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
5887 ; PROLOG: loop_header.prol.loopexit:
5888 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
5889 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
5890 ; PROLOG-NEXT: br i1 %2, label %exit1, label %entry.new
5891 ; PROLOG: entry.new:
5892 ; PROLOG-NEXT: br label %loop_header
5893 ; PROLOG: loop_header:
5894 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
5895 ; PROLOG-NEXT: call void @bar()
5896 ; PROLOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5897 ; PROLOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
5898 ; PROLOG: loop_exiting_bb2:
5899 ; PROLOG-NEXT: br i1 %cond, label %loop_latch, label %exit1.unr-lcssa.loopexit
5900 ; PROLOG: loop_latch:
5901 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
5902 ; PROLOG-NEXT: call void @bar()
5903 ; PROLOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5904 ; PROLOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
5905 ; PROLOG: loop_exiting_bb2.1:
5906 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
5907 ; PROLOG: loop_latch.1:
5908 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv, 2
5909 ; PROLOG-NEXT: call void @bar()
5910 ; PROLOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
5911 ; PROLOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.unr-lcssa.loopexit
5912 ; PROLOG: loop_exiting_bb2.2:
5913 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.2, label %exit1.unr-lcssa.loopexit
5914 ; PROLOG: loop_latch.2:
5915 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv, 3
5916 ; PROLOG-NEXT: call void @bar()
5917 ; PROLOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
5918 ; PROLOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.unr-lcssa.loopexit
5919 ; PROLOG: loop_exiting_bb2.3:
5920 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.3, label %exit1.unr-lcssa.loopexit
5921 ; PROLOG: loop_latch.3:
5922 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv, 4
5923 ; PROLOG-NEXT: call void @bar()
5924 ; PROLOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
5925 ; PROLOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.unr-lcssa.loopexit
5926 ; PROLOG: loop_exiting_bb2.4:
5927 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.4, label %exit1.unr-lcssa.loopexit
5928 ; PROLOG: loop_latch.4:
5929 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv, 5
5930 ; PROLOG-NEXT: call void @bar()
5931 ; PROLOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
5932 ; PROLOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.unr-lcssa.loopexit
5933 ; PROLOG: loop_exiting_bb2.5:
5934 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.5, label %exit1.unr-lcssa.loopexit
5935 ; PROLOG: loop_latch.5:
5936 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv, 6
5937 ; PROLOG-NEXT: call void @bar()
5938 ; PROLOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
5939 ; PROLOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.unr-lcssa.loopexit
5940 ; PROLOG: loop_exiting_bb2.6:
5941 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.6, label %exit1.unr-lcssa.loopexit
5942 ; PROLOG: loop_latch.6:
5943 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv, 7
5944 ; PROLOG-NEXT: call void @bar()
5945 ; PROLOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
5946 ; PROLOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.unr-lcssa.loopexit
5947 ; PROLOG: loop_exiting_bb2.7:
5948 ; PROLOG-NEXT: br i1 %cond, label %loop_latch.7, label %exit1.unr-lcssa.loopexit
5949 ; PROLOG: loop_latch.7:
5950 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv, 8
5951 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
5952 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
5953 ; PROLOG: exit1.unr-lcssa.loopexit:
5954 ; PROLOG-NEXT: br label %exit1.unr-lcssa
5955 ; PROLOG: exit1.unr-lcssa.loopexit1:
5956 ; PROLOG-NEXT: br label %exit1.unr-lcssa
5957 ; PROLOG: exit1.unr-lcssa:
5958 ; PROLOG-NEXT: br label %exit1
5960 ; PROLOG-NEXT: ret void
5962 ; PROLOG-BLOCK-LABEL: @test12(
5963 ; PROLOG-BLOCK-NEXT: entry:
5964 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
5965 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
5966 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
5967 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
5968 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
5969 ; PROLOG-BLOCK: loop_header.prol.preheader:
5970 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
5971 ; PROLOG-BLOCK: loop_header.prol:
5972 ; PROLOG-BLOCK-NEXT: call void @bar()
5973 ; PROLOG-BLOCK-NEXT: %cmp_early.prol = icmp ne i64 0, %trip2
5974 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa
5975 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
5976 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.prol, label %exit1.unr-lcssa
5977 ; PROLOG-BLOCK: loop_latch.prol:
5978 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
5979 ; PROLOG-BLOCK: loop_header.prol.loopexit:
5980 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
5981 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
5982 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit1, label %entry.new
5983 ; PROLOG-BLOCK: entry.new:
5984 ; PROLOG-BLOCK-NEXT: br label %loop_header
5985 ; PROLOG-BLOCK: loop_header:
5986 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
5987 ; PROLOG-BLOCK-NEXT: call void @bar()
5988 ; PROLOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
5989 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
5990 ; PROLOG-BLOCK: loop_exiting_bb2:
5991 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch, label %exit1.unr-lcssa.loopexit
5992 ; PROLOG-BLOCK: loop_latch:
5993 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
5994 ; PROLOG-BLOCK-NEXT: call void @bar()
5995 ; PROLOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
5996 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
5997 ; PROLOG-BLOCK: loop_exiting_bb2.1:
5998 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
5999 ; PROLOG-BLOCK: loop_latch.1:
6000 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
6001 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
6002 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !18
6003 ; PROLOG-BLOCK: exit1.unr-lcssa.loopexit:
6004 ; PROLOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6005 ; PROLOG-BLOCK: exit1.unr-lcssa:
6006 ; PROLOG-BLOCK-NEXT: br label %exit1
6007 ; PROLOG-BLOCK: exit1:
6008 ; PROLOG-BLOCK-NEXT: ret void
6011 br label %loop_header
6014 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
6016 %cmp_early = icmp ne i64 %iv, %trip2
6017 br i1 %cmp_early, label %loop_exiting_bb2, label %exit1
6020 br i1 %cond, label %loop_latch, label %exit1
6023 %iv_next = add i64 %iv, 1
6024 %cmp = icmp ne i64 %iv_next, %trip
6025 br i1 %cmp, label %loop_header, label %exit1
6031 declare i1 @unknown_cond()
6033 ; Mix of computable and uncompatable exits
6034 define void @test13(i64 %trip, i64 %trip2) {
6035 ; EPILOG-LABEL: @test13(
6036 ; EPILOG-NEXT: entry:
6037 ; EPILOG-NEXT: %0 = freeze i64 %trip
6038 ; EPILOG-NEXT: %1 = add i64 %0, -1
6039 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
6040 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
6041 ; EPILOG-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
6042 ; EPILOG: entry.new:
6043 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
6044 ; EPILOG-NEXT: br label %loop_header
6045 ; EPILOG: loop_header:
6046 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6047 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
6048 ; EPILOG-NEXT: call void @bar()
6049 ; EPILOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6050 ; EPILOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6051 ; EPILOG: loop_exiting_bb2:
6052 ; EPILOG-NEXT: %unknown = call i1 @unknown_cond()
6053 ; EPILOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6054 ; EPILOG: loop_latch:
6055 ; EPILOG-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6056 ; EPILOG-NEXT: call void @bar()
6057 ; EPILOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6058 ; EPILOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6059 ; EPILOG: loop_exiting_bb2.1:
6060 ; EPILOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6061 ; EPILOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6062 ; EPILOG: loop_latch.1:
6063 ; EPILOG-NEXT: %iv_next.1 = add nuw nsw i64 %iv, 2
6064 ; EPILOG-NEXT: call void @bar()
6065 ; EPILOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
6066 ; EPILOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.epilog-lcssa.loopexit
6067 ; EPILOG: loop_exiting_bb2.2:
6068 ; EPILOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6069 ; EPILOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.epilog-lcssa.loopexit
6070 ; EPILOG: loop_latch.2:
6071 ; EPILOG-NEXT: %iv_next.2 = add nuw nsw i64 %iv, 3
6072 ; EPILOG-NEXT: call void @bar()
6073 ; EPILOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
6074 ; EPILOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.epilog-lcssa.loopexit
6075 ; EPILOG: loop_exiting_bb2.3:
6076 ; EPILOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6077 ; EPILOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.epilog-lcssa.loopexit
6078 ; EPILOG: loop_latch.3:
6079 ; EPILOG-NEXT: %iv_next.3 = add nuw nsw i64 %iv, 4
6080 ; EPILOG-NEXT: call void @bar()
6081 ; EPILOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
6082 ; EPILOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.epilog-lcssa.loopexit
6083 ; EPILOG: loop_exiting_bb2.4:
6084 ; EPILOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6085 ; EPILOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.epilog-lcssa.loopexit
6086 ; EPILOG: loop_latch.4:
6087 ; EPILOG-NEXT: %iv_next.4 = add nuw nsw i64 %iv, 5
6088 ; EPILOG-NEXT: call void @bar()
6089 ; EPILOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
6090 ; EPILOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.epilog-lcssa.loopexit
6091 ; EPILOG: loop_exiting_bb2.5:
6092 ; EPILOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6093 ; EPILOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.epilog-lcssa.loopexit
6094 ; EPILOG: loop_latch.5:
6095 ; EPILOG-NEXT: %iv_next.5 = add nuw nsw i64 %iv, 6
6096 ; EPILOG-NEXT: call void @bar()
6097 ; EPILOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
6098 ; EPILOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.epilog-lcssa.loopexit
6099 ; EPILOG: loop_exiting_bb2.6:
6100 ; EPILOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6101 ; EPILOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.epilog-lcssa.loopexit
6102 ; EPILOG: loop_latch.6:
6103 ; EPILOG-NEXT: %iv_next.6 = add nuw nsw i64 %iv, 7
6104 ; EPILOG-NEXT: call void @bar()
6105 ; EPILOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
6106 ; EPILOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.epilog-lcssa.loopexit
6107 ; EPILOG: loop_exiting_bb2.7:
6108 ; EPILOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6109 ; EPILOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.epilog-lcssa.loopexit
6110 ; EPILOG: loop_latch.7:
6111 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv, 8
6112 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
6113 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
6114 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6115 ; EPILOG: exit1.unr-lcssa.loopexit:
6116 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
6117 ; EPILOG-NEXT: br label %exit1.unr-lcssa
6118 ; EPILOG: exit1.unr-lcssa:
6119 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6120 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6121 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6122 ; EPILOG: loop_header.epil.preheader:
6123 ; EPILOG-NEXT: br label %loop_header.epil
6124 ; EPILOG: loop_header.epil:
6125 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
6126 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
6127 ; EPILOG-NEXT: call void @bar()
6128 ; EPILOG-NEXT: %cmp_early.epil = icmp ne i64 %iv.epil, %trip2
6129 ; EPILOG-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa.loopexit1
6130 ; EPILOG: loop_exiting_bb2.epil:
6131 ; EPILOG-NEXT: %unknown.epil = call i1 @unknown_cond()
6132 ; EPILOG-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa.loopexit1
6133 ; EPILOG: loop_latch.epil:
6134 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
6135 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
6136 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
6137 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
6138 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit1.epilog-lcssa.loopexit1, !llvm.loop !17
6139 ; EPILOG: exit1.epilog-lcssa.loopexit:
6140 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6141 ; EPILOG: exit1.epilog-lcssa.loopexit1:
6142 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6143 ; EPILOG: exit1.epilog-lcssa:
6144 ; EPILOG-NEXT: br label %exit1
6146 ; EPILOG-NEXT: ret void
6148 ; EPILOG-BLOCK-LABEL: @test13(
6149 ; EPILOG-BLOCK-NEXT: entry:
6150 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
6151 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
6152 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6153 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6154 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
6155 ; EPILOG-BLOCK: entry.new:
6156 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
6157 ; EPILOG-BLOCK-NEXT: br label %loop_header
6158 ; EPILOG-BLOCK: loop_header:
6159 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6160 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
6161 ; EPILOG-BLOCK-NEXT: call void @bar()
6162 ; EPILOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6163 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6164 ; EPILOG-BLOCK: loop_exiting_bb2:
6165 ; EPILOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6166 ; EPILOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6167 ; EPILOG-BLOCK: loop_latch:
6168 ; EPILOG-BLOCK-NEXT: %iv_next = add nuw nsw i64 %iv, 1
6169 ; EPILOG-BLOCK-NEXT: call void @bar()
6170 ; EPILOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6171 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6172 ; EPILOG-BLOCK: loop_exiting_bb2.1:
6173 ; EPILOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6174 ; EPILOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6175 ; EPILOG-BLOCK: loop_latch.1:
6176 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
6177 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
6178 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
6179 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !19
6180 ; EPILOG-BLOCK: exit1.unr-lcssa.loopexit:
6181 ; EPILOG-BLOCK-NEXT: %iv.unr.ph = phi i64 [ %iv_next.1, %loop_latch.1 ]
6182 ; EPILOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6183 ; EPILOG-BLOCK: exit1.unr-lcssa:
6184 ; EPILOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6185 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6186 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6187 ; EPILOG-BLOCK: loop_header.epil.preheader:
6188 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
6189 ; EPILOG-BLOCK: loop_header.epil:
6190 ; EPILOG-BLOCK-NEXT: call void @bar()
6191 ; EPILOG-BLOCK-NEXT: %cmp_early.epil = icmp ne i64 %iv.unr, %trip2
6192 ; EPILOG-BLOCK-NEXT: br i1 %cmp_early.epil, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa
6193 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
6194 ; EPILOG-BLOCK-NEXT: %unknown.epil = call i1 @unknown_cond()
6195 ; EPILOG-BLOCK-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa
6196 ; EPILOG-BLOCK: loop_latch.epil:
6197 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6198 ; EPILOG-BLOCK: exit1.epilog-lcssa.loopexit:
6199 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6200 ; EPILOG-BLOCK: exit1.epilog-lcssa:
6201 ; EPILOG-BLOCK-NEXT: br label %exit1
6202 ; EPILOG-BLOCK: exit1:
6203 ; EPILOG-BLOCK-NEXT: ret void
6205 ; PROLOG-LABEL: @test13(
6206 ; PROLOG-NEXT: entry:
6207 ; PROLOG-NEXT: %0 = freeze i64 %trip
6208 ; PROLOG-NEXT: %1 = add i64 %0, -1
6209 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
6210 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6211 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6212 ; PROLOG: loop_header.prol.preheader:
6213 ; PROLOG-NEXT: br label %loop_header.prol
6214 ; PROLOG: loop_header.prol:
6215 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
6216 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
6217 ; PROLOG-NEXT: call void @bar()
6218 ; PROLOG-NEXT: %cmp_early.prol = icmp ne i64 %iv.prol, %trip2
6219 ; PROLOG-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa.loopexit1
6220 ; PROLOG: loop_exiting_bb2.prol:
6221 ; PROLOG-NEXT: %unknown.prol = call i1 @unknown_cond()
6222 ; PROLOG-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa.loopexit1
6223 ; PROLOG: loop_latch.prol:
6224 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
6225 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
6226 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
6227 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
6228 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !17
6229 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
6230 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
6231 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
6232 ; PROLOG: loop_header.prol.loopexit:
6233 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
6234 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
6235 ; PROLOG-NEXT: br i1 %2, label %exit1, label %entry.new
6236 ; PROLOG: entry.new:
6237 ; PROLOG-NEXT: br label %loop_header
6238 ; PROLOG: loop_header:
6239 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6240 ; PROLOG-NEXT: call void @bar()
6241 ; PROLOG-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6242 ; PROLOG-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6243 ; PROLOG: loop_exiting_bb2:
6244 ; PROLOG-NEXT: %unknown = call i1 @unknown_cond()
6245 ; PROLOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6246 ; PROLOG: loop_latch:
6247 ; PROLOG-NEXT: %iv_next = add i64 %iv, 1
6248 ; PROLOG-NEXT: call void @bar()
6249 ; PROLOG-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6250 ; PROLOG-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6251 ; PROLOG: loop_exiting_bb2.1:
6252 ; PROLOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6253 ; PROLOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6254 ; PROLOG: loop_latch.1:
6255 ; PROLOG-NEXT: %iv_next.1 = add i64 %iv, 2
6256 ; PROLOG-NEXT: call void @bar()
6257 ; PROLOG-NEXT: %cmp_early.2 = icmp ne i64 %iv_next.1, %trip2
6258 ; PROLOG-NEXT: br i1 %cmp_early.2, label %loop_exiting_bb2.2, label %exit1.unr-lcssa.loopexit
6259 ; PROLOG: loop_exiting_bb2.2:
6260 ; PROLOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6261 ; PROLOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.unr-lcssa.loopexit
6262 ; PROLOG: loop_latch.2:
6263 ; PROLOG-NEXT: %iv_next.2 = add i64 %iv, 3
6264 ; PROLOG-NEXT: call void @bar()
6265 ; PROLOG-NEXT: %cmp_early.3 = icmp ne i64 %iv_next.2, %trip2
6266 ; PROLOG-NEXT: br i1 %cmp_early.3, label %loop_exiting_bb2.3, label %exit1.unr-lcssa.loopexit
6267 ; PROLOG: loop_exiting_bb2.3:
6268 ; PROLOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6269 ; PROLOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.unr-lcssa.loopexit
6270 ; PROLOG: loop_latch.3:
6271 ; PROLOG-NEXT: %iv_next.3 = add i64 %iv, 4
6272 ; PROLOG-NEXT: call void @bar()
6273 ; PROLOG-NEXT: %cmp_early.4 = icmp ne i64 %iv_next.3, %trip2
6274 ; PROLOG-NEXT: br i1 %cmp_early.4, label %loop_exiting_bb2.4, label %exit1.unr-lcssa.loopexit
6275 ; PROLOG: loop_exiting_bb2.4:
6276 ; PROLOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6277 ; PROLOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.unr-lcssa.loopexit
6278 ; PROLOG: loop_latch.4:
6279 ; PROLOG-NEXT: %iv_next.4 = add i64 %iv, 5
6280 ; PROLOG-NEXT: call void @bar()
6281 ; PROLOG-NEXT: %cmp_early.5 = icmp ne i64 %iv_next.4, %trip2
6282 ; PROLOG-NEXT: br i1 %cmp_early.5, label %loop_exiting_bb2.5, label %exit1.unr-lcssa.loopexit
6283 ; PROLOG: loop_exiting_bb2.5:
6284 ; PROLOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6285 ; PROLOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.unr-lcssa.loopexit
6286 ; PROLOG: loop_latch.5:
6287 ; PROLOG-NEXT: %iv_next.5 = add i64 %iv, 6
6288 ; PROLOG-NEXT: call void @bar()
6289 ; PROLOG-NEXT: %cmp_early.6 = icmp ne i64 %iv_next.5, %trip2
6290 ; PROLOG-NEXT: br i1 %cmp_early.6, label %loop_exiting_bb2.6, label %exit1.unr-lcssa.loopexit
6291 ; PROLOG: loop_exiting_bb2.6:
6292 ; PROLOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6293 ; PROLOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.unr-lcssa.loopexit
6294 ; PROLOG: loop_latch.6:
6295 ; PROLOG-NEXT: %iv_next.6 = add i64 %iv, 7
6296 ; PROLOG-NEXT: call void @bar()
6297 ; PROLOG-NEXT: %cmp_early.7 = icmp ne i64 %iv_next.6, %trip2
6298 ; PROLOG-NEXT: br i1 %cmp_early.7, label %loop_exiting_bb2.7, label %exit1.unr-lcssa.loopexit
6299 ; PROLOG: loop_exiting_bb2.7:
6300 ; PROLOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6301 ; PROLOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.unr-lcssa.loopexit
6302 ; PROLOG: loop_latch.7:
6303 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv, 8
6304 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
6305 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6306 ; PROLOG: exit1.unr-lcssa.loopexit:
6307 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6308 ; PROLOG: exit1.unr-lcssa.loopexit1:
6309 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6310 ; PROLOG: exit1.unr-lcssa:
6311 ; PROLOG-NEXT: br label %exit1
6313 ; PROLOG-NEXT: ret void
6315 ; PROLOG-BLOCK-LABEL: @test13(
6316 ; PROLOG-BLOCK-NEXT: entry:
6317 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
6318 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
6319 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6320 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6321 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6322 ; PROLOG-BLOCK: loop_header.prol.preheader:
6323 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
6324 ; PROLOG-BLOCK: loop_header.prol:
6325 ; PROLOG-BLOCK-NEXT: call void @bar()
6326 ; PROLOG-BLOCK-NEXT: %cmp_early.prol = icmp ne i64 0, %trip2
6327 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.prol, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa
6328 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
6329 ; PROLOG-BLOCK-NEXT: %unknown.prol = call i1 @unknown_cond()
6330 ; PROLOG-BLOCK-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa
6331 ; PROLOG-BLOCK: loop_latch.prol:
6332 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
6333 ; PROLOG-BLOCK: loop_header.prol.loopexit:
6334 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
6335 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6336 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit1, label %entry.new
6337 ; PROLOG-BLOCK: entry.new:
6338 ; PROLOG-BLOCK-NEXT: br label %loop_header
6339 ; PROLOG-BLOCK: loop_header:
6340 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6341 ; PROLOG-BLOCK-NEXT: call void @bar()
6342 ; PROLOG-BLOCK-NEXT: %cmp_early = icmp ne i64 %iv, %trip2
6343 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6344 ; PROLOG-BLOCK: loop_exiting_bb2:
6345 ; PROLOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6346 ; PROLOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6347 ; PROLOG-BLOCK: loop_latch:
6348 ; PROLOG-BLOCK-NEXT: %iv_next = add i64 %iv, 1
6349 ; PROLOG-BLOCK-NEXT: call void @bar()
6350 ; PROLOG-BLOCK-NEXT: %cmp_early.1 = icmp ne i64 %iv_next, %trip2
6351 ; PROLOG-BLOCK-NEXT: br i1 %cmp_early.1, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6352 ; PROLOG-BLOCK: loop_exiting_bb2.1:
6353 ; PROLOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6354 ; PROLOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6355 ; PROLOG-BLOCK: loop_latch.1:
6356 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
6357 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
6358 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !19
6359 ; PROLOG-BLOCK: exit1.unr-lcssa.loopexit:
6360 ; PROLOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6361 ; PROLOG-BLOCK: exit1.unr-lcssa:
6362 ; PROLOG-BLOCK-NEXT: br label %exit1
6363 ; PROLOG-BLOCK: exit1:
6364 ; PROLOG-BLOCK-NEXT: ret void
6367 br label %loop_header
6370 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
6372 %cmp_early = icmp ne i64 %iv, %trip2
6373 br i1 %cmp_early, label %loop_exiting_bb2, label %exit1
6376 %unknown = call i1 @unknown_cond()
6377 br i1 %unknown, label %loop_latch, label %exit1
6380 %iv_next = add i64 %iv, 1
6381 %cmp = icmp ne i64 %iv_next, %trip
6382 br i1 %cmp, label %loop_header, label %exit1
6388 ; Mix of invariant and (even in theory) uncomputable exits
6389 define void @test14(i64 %trip, i1 %cond) {
6390 ; EPILOG-LABEL: @test14(
6391 ; EPILOG-NEXT: entry:
6392 ; EPILOG-NEXT: %0 = freeze i64 %trip
6393 ; EPILOG-NEXT: %1 = add i64 %0, -1
6394 ; EPILOG-NEXT: %xtraiter = and i64 %0, 7
6395 ; EPILOG-NEXT: %2 = icmp ult i64 %1, 7
6396 ; EPILOG-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
6397 ; EPILOG: entry.new:
6398 ; EPILOG-NEXT: %unroll_iter = sub i64 %0, %xtraiter
6399 ; EPILOG-NEXT: br label %loop_header
6400 ; EPILOG: loop_header:
6401 ; EPILOG-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6402 ; EPILOG-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.7, %loop_latch.7 ]
6403 ; EPILOG-NEXT: call void @bar()
6404 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6405 ; EPILOG: loop_exiting_bb2:
6406 ; EPILOG-NEXT: %unknown = call i1 @unknown_cond()
6407 ; EPILOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6408 ; EPILOG: loop_latch:
6409 ; EPILOG-NEXT: call void @bar()
6410 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6411 ; EPILOG: loop_exiting_bb2.1:
6412 ; EPILOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6413 ; EPILOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6414 ; EPILOG: loop_latch.1:
6415 ; EPILOG-NEXT: call void @bar()
6416 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.2, label %exit1.epilog-lcssa.loopexit
6417 ; EPILOG: loop_exiting_bb2.2:
6418 ; EPILOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6419 ; EPILOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.epilog-lcssa.loopexit
6420 ; EPILOG: loop_latch.2:
6421 ; EPILOG-NEXT: call void @bar()
6422 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.3, label %exit1.epilog-lcssa.loopexit
6423 ; EPILOG: loop_exiting_bb2.3:
6424 ; EPILOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6425 ; EPILOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.epilog-lcssa.loopexit
6426 ; EPILOG: loop_latch.3:
6427 ; EPILOG-NEXT: call void @bar()
6428 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.4, label %exit1.epilog-lcssa.loopexit
6429 ; EPILOG: loop_exiting_bb2.4:
6430 ; EPILOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6431 ; EPILOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.epilog-lcssa.loopexit
6432 ; EPILOG: loop_latch.4:
6433 ; EPILOG-NEXT: call void @bar()
6434 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.5, label %exit1.epilog-lcssa.loopexit
6435 ; EPILOG: loop_exiting_bb2.5:
6436 ; EPILOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6437 ; EPILOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.epilog-lcssa.loopexit
6438 ; EPILOG: loop_latch.5:
6439 ; EPILOG-NEXT: call void @bar()
6440 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.6, label %exit1.epilog-lcssa.loopexit
6441 ; EPILOG: loop_exiting_bb2.6:
6442 ; EPILOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6443 ; EPILOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.epilog-lcssa.loopexit
6444 ; EPILOG: loop_latch.6:
6445 ; EPILOG-NEXT: call void @bar()
6446 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.7, label %exit1.epilog-lcssa.loopexit
6447 ; EPILOG: loop_exiting_bb2.7:
6448 ; EPILOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6449 ; EPILOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.epilog-lcssa.loopexit
6450 ; EPILOG: loop_latch.7:
6451 ; EPILOG-NEXT: %iv_next.7 = add i64 %iv, 8
6452 ; EPILOG-NEXT: %niter.next.7 = add i64 %niter, 8
6453 ; EPILOG-NEXT: %niter.ncmp.7 = icmp ne i64 %niter.next.7, %unroll_iter
6454 ; EPILOG-NEXT: br i1 %niter.ncmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6455 ; EPILOG: exit1.unr-lcssa.loopexit:
6456 ; EPILOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.7, %loop_latch.7 ]
6457 ; EPILOG-NEXT: br label %exit1.unr-lcssa
6458 ; EPILOG: exit1.unr-lcssa:
6459 ; EPILOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %exit1.unr-lcssa.loopexit ]
6460 ; EPILOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6461 ; EPILOG-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6462 ; EPILOG: loop_header.epil.preheader:
6463 ; EPILOG-NEXT: br label %loop_header.epil
6464 ; EPILOG: loop_header.epil:
6465 ; EPILOG-NEXT: %iv.epil = phi i64 [ %iv.unr, %loop_header.epil.preheader ], [ %iv_next.epil, %loop_latch.epil ]
6466 ; EPILOG-NEXT: %epil.iter = phi i64 [ 0, %loop_header.epil.preheader ], [ %epil.iter.next, %loop_latch.epil ]
6467 ; EPILOG-NEXT: call void @bar()
6468 ; EPILOG-NEXT: br i1 %cond, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa.loopexit1
6469 ; EPILOG: loop_exiting_bb2.epil:
6470 ; EPILOG-NEXT: %unknown.epil = call i1 @unknown_cond()
6471 ; EPILOG-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa.loopexit1
6472 ; EPILOG: loop_latch.epil:
6473 ; EPILOG-NEXT: %iv_next.epil = add i64 %iv.epil, 1
6474 ; EPILOG-NEXT: %cmp.epil = icmp ne i64 %iv_next.epil, %trip
6475 ; EPILOG-NEXT: %epil.iter.next = add i64 %epil.iter, 1
6476 ; EPILOG-NEXT: %epil.iter.cmp = icmp ne i64 %epil.iter.next, %xtraiter
6477 ; EPILOG-NEXT: br i1 %epil.iter.cmp, label %loop_header.epil, label %exit1.epilog-lcssa.loopexit1, !llvm.loop !18
6478 ; EPILOG: exit1.epilog-lcssa.loopexit:
6479 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6480 ; EPILOG: exit1.epilog-lcssa.loopexit1:
6481 ; EPILOG-NEXT: br label %exit1.epilog-lcssa
6482 ; EPILOG: exit1.epilog-lcssa:
6483 ; EPILOG-NEXT: br label %exit1
6485 ; EPILOG-NEXT: ret void
6487 ; EPILOG-BLOCK-LABEL: @test14(
6488 ; EPILOG-BLOCK-NEXT: entry:
6489 ; EPILOG-BLOCK-NEXT: %0 = freeze i64 %trip
6490 ; EPILOG-BLOCK-NEXT: %1 = add i64 %0, -1
6491 ; EPILOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6492 ; EPILOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6493 ; EPILOG-BLOCK-NEXT: br i1 %2, label %exit1.unr-lcssa, label %entry.new
6494 ; EPILOG-BLOCK: entry.new:
6495 ; EPILOG-BLOCK-NEXT: %unroll_iter = sub i64 %0, %xtraiter
6496 ; EPILOG-BLOCK-NEXT: br label %loop_header
6497 ; EPILOG-BLOCK: loop_header:
6498 ; EPILOG-BLOCK-NEXT: %iv = phi i64 [ 0, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6499 ; EPILOG-BLOCK-NEXT: %niter = phi i64 [ 0, %entry.new ], [ %niter.next.1, %loop_latch.1 ]
6500 ; EPILOG-BLOCK-NEXT: call void @bar()
6501 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.epilog-lcssa.loopexit
6502 ; EPILOG-BLOCK: loop_exiting_bb2:
6503 ; EPILOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6504 ; EPILOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.epilog-lcssa.loopexit
6505 ; EPILOG-BLOCK: loop_latch:
6506 ; EPILOG-BLOCK-NEXT: call void @bar()
6507 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.epilog-lcssa.loopexit
6508 ; EPILOG-BLOCK: loop_exiting_bb2.1:
6509 ; EPILOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6510 ; EPILOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.epilog-lcssa.loopexit
6511 ; EPILOG-BLOCK: loop_latch.1:
6512 ; EPILOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
6513 ; EPILOG-BLOCK-NEXT: %niter.next.1 = add i64 %niter, 2
6514 ; EPILOG-BLOCK-NEXT: %niter.ncmp.1 = icmp ne i64 %niter.next.1, %unroll_iter
6515 ; EPILOG-BLOCK-NEXT: br i1 %niter.ncmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !20
6516 ; EPILOG-BLOCK: exit1.unr-lcssa.loopexit:
6517 ; EPILOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6518 ; EPILOG-BLOCK: exit1.unr-lcssa:
6519 ; EPILOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6520 ; EPILOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.epil.preheader, label %exit1
6521 ; EPILOG-BLOCK: loop_header.epil.preheader:
6522 ; EPILOG-BLOCK-NEXT: br label %loop_header.epil
6523 ; EPILOG-BLOCK: loop_header.epil:
6524 ; EPILOG-BLOCK-NEXT: call void @bar()
6525 ; EPILOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.epil, label %exit1.epilog-lcssa
6526 ; EPILOG-BLOCK: loop_exiting_bb2.epil:
6527 ; EPILOG-BLOCK-NEXT: %unknown.epil = call i1 @unknown_cond()
6528 ; EPILOG-BLOCK-NEXT: br i1 %unknown.epil, label %loop_latch.epil, label %exit1.epilog-lcssa
6529 ; EPILOG-BLOCK: loop_latch.epil:
6530 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6531 ; EPILOG-BLOCK: exit1.epilog-lcssa.loopexit:
6532 ; EPILOG-BLOCK-NEXT: br label %exit1.epilog-lcssa
6533 ; EPILOG-BLOCK: exit1.epilog-lcssa:
6534 ; EPILOG-BLOCK-NEXT: br label %exit1
6535 ; EPILOG-BLOCK: exit1:
6536 ; EPILOG-BLOCK-NEXT: ret void
6538 ; PROLOG-LABEL: @test14(
6539 ; PROLOG-NEXT: entry:
6540 ; PROLOG-NEXT: %0 = freeze i64 %trip
6541 ; PROLOG-NEXT: %1 = add i64 %0, -1
6542 ; PROLOG-NEXT: %xtraiter = and i64 %0, 7
6543 ; PROLOG-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6544 ; PROLOG-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6545 ; PROLOG: loop_header.prol.preheader:
6546 ; PROLOG-NEXT: br label %loop_header.prol
6547 ; PROLOG: loop_header.prol:
6548 ; PROLOG-NEXT: %iv.prol = phi i64 [ 0, %loop_header.prol.preheader ], [ %iv_next.prol, %loop_latch.prol ]
6549 ; PROLOG-NEXT: %prol.iter = phi i64 [ 0, %loop_header.prol.preheader ], [ %prol.iter.next, %loop_latch.prol ]
6550 ; PROLOG-NEXT: call void @bar()
6551 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa.loopexit1
6552 ; PROLOG: loop_exiting_bb2.prol:
6553 ; PROLOG-NEXT: %unknown.prol = call i1 @unknown_cond()
6554 ; PROLOG-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa.loopexit1
6555 ; PROLOG: loop_latch.prol:
6556 ; PROLOG-NEXT: %iv_next.prol = add i64 %iv.prol, 1
6557 ; PROLOG-NEXT: %cmp.prol = icmp ne i64 %iv_next.prol, %trip
6558 ; PROLOG-NEXT: %prol.iter.next = add i64 %prol.iter, 1
6559 ; PROLOG-NEXT: %prol.iter.cmp = icmp ne i64 %prol.iter.next, %xtraiter
6560 ; PROLOG-NEXT: br i1 %prol.iter.cmp, label %loop_header.prol, label %loop_header.prol.loopexit.unr-lcssa, !llvm.loop !18
6561 ; PROLOG: loop_header.prol.loopexit.unr-lcssa:
6562 ; PROLOG-NEXT: %iv.unr.ph = phi i64 [ %iv_next.prol, %loop_latch.prol ]
6563 ; PROLOG-NEXT: br label %loop_header.prol.loopexit
6564 ; PROLOG: loop_header.prol.loopexit:
6565 ; PROLOG-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ %iv.unr.ph, %loop_header.prol.loopexit.unr-lcssa ]
6566 ; PROLOG-NEXT: %2 = icmp ult i64 %1, 7
6567 ; PROLOG-NEXT: br i1 %2, label %exit1, label %entry.new
6568 ; PROLOG: entry.new:
6569 ; PROLOG-NEXT: br label %loop_header
6570 ; PROLOG: loop_header:
6571 ; PROLOG-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.7, %loop_latch.7 ]
6572 ; PROLOG-NEXT: call void @bar()
6573 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6574 ; PROLOG: loop_exiting_bb2:
6575 ; PROLOG-NEXT: %unknown = call i1 @unknown_cond()
6576 ; PROLOG-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6577 ; PROLOG: loop_latch:
6578 ; PROLOG-NEXT: call void @bar()
6579 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6580 ; PROLOG: loop_exiting_bb2.1:
6581 ; PROLOG-NEXT: %unknown.1 = call i1 @unknown_cond()
6582 ; PROLOG-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6583 ; PROLOG: loop_latch.1:
6584 ; PROLOG-NEXT: call void @bar()
6585 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.2, label %exit1.unr-lcssa.loopexit
6586 ; PROLOG: loop_exiting_bb2.2:
6587 ; PROLOG-NEXT: %unknown.2 = call i1 @unknown_cond()
6588 ; PROLOG-NEXT: br i1 %unknown.2, label %loop_latch.2, label %exit1.unr-lcssa.loopexit
6589 ; PROLOG: loop_latch.2:
6590 ; PROLOG-NEXT: call void @bar()
6591 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.3, label %exit1.unr-lcssa.loopexit
6592 ; PROLOG: loop_exiting_bb2.3:
6593 ; PROLOG-NEXT: %unknown.3 = call i1 @unknown_cond()
6594 ; PROLOG-NEXT: br i1 %unknown.3, label %loop_latch.3, label %exit1.unr-lcssa.loopexit
6595 ; PROLOG: loop_latch.3:
6596 ; PROLOG-NEXT: call void @bar()
6597 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.4, label %exit1.unr-lcssa.loopexit
6598 ; PROLOG: loop_exiting_bb2.4:
6599 ; PROLOG-NEXT: %unknown.4 = call i1 @unknown_cond()
6600 ; PROLOG-NEXT: br i1 %unknown.4, label %loop_latch.4, label %exit1.unr-lcssa.loopexit
6601 ; PROLOG: loop_latch.4:
6602 ; PROLOG-NEXT: call void @bar()
6603 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.5, label %exit1.unr-lcssa.loopexit
6604 ; PROLOG: loop_exiting_bb2.5:
6605 ; PROLOG-NEXT: %unknown.5 = call i1 @unknown_cond()
6606 ; PROLOG-NEXT: br i1 %unknown.5, label %loop_latch.5, label %exit1.unr-lcssa.loopexit
6607 ; PROLOG: loop_latch.5:
6608 ; PROLOG-NEXT: call void @bar()
6609 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.6, label %exit1.unr-lcssa.loopexit
6610 ; PROLOG: loop_exiting_bb2.6:
6611 ; PROLOG-NEXT: %unknown.6 = call i1 @unknown_cond()
6612 ; PROLOG-NEXT: br i1 %unknown.6, label %loop_latch.6, label %exit1.unr-lcssa.loopexit
6613 ; PROLOG: loop_latch.6:
6614 ; PROLOG-NEXT: call void @bar()
6615 ; PROLOG-NEXT: br i1 %cond, label %loop_exiting_bb2.7, label %exit1.unr-lcssa.loopexit
6616 ; PROLOG: loop_exiting_bb2.7:
6617 ; PROLOG-NEXT: %unknown.7 = call i1 @unknown_cond()
6618 ; PROLOG-NEXT: br i1 %unknown.7, label %loop_latch.7, label %exit1.unr-lcssa.loopexit
6619 ; PROLOG: loop_latch.7:
6620 ; PROLOG-NEXT: %iv_next.7 = add i64 %iv, 8
6621 ; PROLOG-NEXT: %cmp.7 = icmp ne i64 %iv_next.7, %trip
6622 ; PROLOG-NEXT: br i1 %cmp.7, label %loop_header, label %exit1.unr-lcssa.loopexit
6623 ; PROLOG: exit1.unr-lcssa.loopexit:
6624 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6625 ; PROLOG: exit1.unr-lcssa.loopexit1:
6626 ; PROLOG-NEXT: br label %exit1.unr-lcssa
6627 ; PROLOG: exit1.unr-lcssa:
6628 ; PROLOG-NEXT: br label %exit1
6630 ; PROLOG-NEXT: ret void
6632 ; PROLOG-BLOCK-LABEL: @test14(
6633 ; PROLOG-BLOCK-NEXT: entry:
6634 ; PROLOG-BLOCK-NEXT: %0 = freeze i64 %trip
6635 ; PROLOG-BLOCK-NEXT: %1 = add i64 %0, -1
6636 ; PROLOG-BLOCK-NEXT: %xtraiter = and i64 %0, 1
6637 ; PROLOG-BLOCK-NEXT: %lcmp.mod = icmp ne i64 %xtraiter, 0
6638 ; PROLOG-BLOCK-NEXT: br i1 %lcmp.mod, label %loop_header.prol.preheader, label %loop_header.prol.loopexit
6639 ; PROLOG-BLOCK: loop_header.prol.preheader:
6640 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol
6641 ; PROLOG-BLOCK: loop_header.prol:
6642 ; PROLOG-BLOCK-NEXT: call void @bar()
6643 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.prol, label %exit1.unr-lcssa
6644 ; PROLOG-BLOCK: loop_exiting_bb2.prol:
6645 ; PROLOG-BLOCK-NEXT: %unknown.prol = call i1 @unknown_cond()
6646 ; PROLOG-BLOCK-NEXT: br i1 %unknown.prol, label %loop_latch.prol, label %exit1.unr-lcssa
6647 ; PROLOG-BLOCK: loop_latch.prol:
6648 ; PROLOG-BLOCK-NEXT: br label %loop_header.prol.loopexit
6649 ; PROLOG-BLOCK: loop_header.prol.loopexit:
6650 ; PROLOG-BLOCK-NEXT: %iv.unr = phi i64 [ 0, %entry ], [ 1, %loop_latch.prol ]
6651 ; PROLOG-BLOCK-NEXT: %2 = icmp ult i64 %1, 1
6652 ; PROLOG-BLOCK-NEXT: br i1 %2, label %exit1, label %entry.new
6653 ; PROLOG-BLOCK: entry.new:
6654 ; PROLOG-BLOCK-NEXT: br label %loop_header
6655 ; PROLOG-BLOCK: loop_header:
6656 ; PROLOG-BLOCK-NEXT: %iv = phi i64 [ %iv.unr, %entry.new ], [ %iv_next.1, %loop_latch.1 ]
6657 ; PROLOG-BLOCK-NEXT: call void @bar()
6658 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2, label %exit1.unr-lcssa.loopexit
6659 ; PROLOG-BLOCK: loop_exiting_bb2:
6660 ; PROLOG-BLOCK-NEXT: %unknown = call i1 @unknown_cond()
6661 ; PROLOG-BLOCK-NEXT: br i1 %unknown, label %loop_latch, label %exit1.unr-lcssa.loopexit
6662 ; PROLOG-BLOCK: loop_latch:
6663 ; PROLOG-BLOCK-NEXT: call void @bar()
6664 ; PROLOG-BLOCK-NEXT: br i1 %cond, label %loop_exiting_bb2.1, label %exit1.unr-lcssa.loopexit
6665 ; PROLOG-BLOCK: loop_exiting_bb2.1:
6666 ; PROLOG-BLOCK-NEXT: %unknown.1 = call i1 @unknown_cond()
6667 ; PROLOG-BLOCK-NEXT: br i1 %unknown.1, label %loop_latch.1, label %exit1.unr-lcssa.loopexit
6668 ; PROLOG-BLOCK: loop_latch.1:
6669 ; PROLOG-BLOCK-NEXT: %iv_next.1 = add i64 %iv, 2
6670 ; PROLOG-BLOCK-NEXT: %cmp.1 = icmp ne i64 %iv_next.1, %trip
6671 ; PROLOG-BLOCK-NEXT: br i1 %cmp.1, label %loop_header, label %exit1.unr-lcssa.loopexit, !llvm.loop !20
6672 ; PROLOG-BLOCK: exit1.unr-lcssa.loopexit:
6673 ; PROLOG-BLOCK-NEXT: br label %exit1.unr-lcssa
6674 ; PROLOG-BLOCK: exit1.unr-lcssa:
6675 ; PROLOG-BLOCK-NEXT: br label %exit1
6676 ; PROLOG-BLOCK: exit1:
6677 ; PROLOG-BLOCK-NEXT: ret void
6680 br label %loop_header
6683 %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ]
6685 br i1 %cond, label %loop_exiting_bb2, label %exit1
6688 %unknown = call i1 @unknown_cond()
6689 br i1 %unknown, label %loop_latch, label %exit1
6692 %iv_next = add i64 %iv, 1
6693 %cmp = icmp ne i64 %iv_next, %trip
6694 br i1 %cmp, label %loop_header, label %exit1