1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -p loop-vectorize -mtriple=x86_64-apple-macosx -mcpu=skylake-avx512 -force-vector-interleave=1 -S %s | FileCheck --check-prefixes=IC1 %s
3 ; RUN: opt -p loop-vectorize -mtriple=x86_64-apple-macosx -mcpu=skylake-avx512 -force-vector-interleave=2 -S %s | FileCheck --check-prefixes=IC2 %s
5 define void @switch_default_to_latch_common_dest(ptr %start, ptr %end) {
6 ; IC1-LABEL: define void @switch_default_to_latch_common_dest(
7 ; IC1-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0:[0-9]+]] {
8 ; IC1-NEXT: [[ENTRY:.*]]:
9 ; IC1-NEXT: br label %[[LOOP_HEADER:.*]]
10 ; IC1: [[LOOP_HEADER]]:
11 ; IC1-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
12 ; IC1-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
13 ; IC1-NEXT: switch i64 [[L]], label %[[LOOP_LATCH]] [
14 ; IC1-NEXT: i64 -12, label %[[IF_THEN:.*]]
15 ; IC1-NEXT: i64 13, label %[[IF_THEN]]
18 ; IC1-NEXT: store i64 42, ptr [[PTR_IV]], align 1
19 ; IC1-NEXT: br label %[[LOOP_LATCH]]
20 ; IC1: [[LOOP_LATCH]]:
21 ; IC1-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
22 ; IC1-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
23 ; IC1-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
27 ; IC2-LABEL: define void @switch_default_to_latch_common_dest(
28 ; IC2-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0:[0-9]+]] {
29 ; IC2-NEXT: [[ENTRY:.*]]:
30 ; IC2-NEXT: br label %[[LOOP_HEADER:.*]]
31 ; IC2: [[LOOP_HEADER]]:
32 ; IC2-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
33 ; IC2-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
34 ; IC2-NEXT: switch i64 [[L]], label %[[LOOP_LATCH]] [
35 ; IC2-NEXT: i64 -12, label %[[IF_THEN:.*]]
36 ; IC2-NEXT: i64 13, label %[[IF_THEN]]
39 ; IC2-NEXT: store i64 42, ptr [[PTR_IV]], align 1
40 ; IC2-NEXT: br label %[[LOOP_LATCH]]
41 ; IC2: [[LOOP_LATCH]]:
42 ; IC2-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
43 ; IC2-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
44 ; IC2-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
52 %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop.latch ]
53 %l = load i64, ptr %ptr.iv, align 1
54 switch i64 %l, label %loop.latch [
55 i64 -12, label %if.then
56 i64 13, label %if.then
60 store i64 42, ptr %ptr.iv, align 1
64 %ptr.iv.next = getelementptr inbounds i64, ptr %ptr.iv, i64 1
65 %ec = icmp eq ptr %ptr.iv.next, %end
66 br i1 %ec, label %exit, label %loop.header
72 define void @switch_all_dests_distinct(ptr %start, ptr %end) {
73 ; IC1-LABEL: define void @switch_all_dests_distinct(
74 ; IC1-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0]] {
75 ; IC1-NEXT: [[ENTRY:.*]]:
76 ; IC1-NEXT: br label %[[LOOP_HEADER:.*]]
77 ; IC1: [[LOOP_HEADER]]:
78 ; IC1-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
79 ; IC1-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
80 ; IC1-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
81 ; IC1-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
82 ; IC1-NEXT: i64 13, label %[[IF_THEN_2:.*]]
83 ; IC1-NEXT: i64 0, label %[[IF_THEN_3:.*]]
86 ; IC1-NEXT: store i64 42, ptr [[PTR_IV]], align 1
87 ; IC1-NEXT: br label %[[LOOP_LATCH]]
89 ; IC1-NEXT: store i64 0, ptr [[PTR_IV]], align 1
90 ; IC1-NEXT: br label %[[LOOP_LATCH]]
92 ; IC1-NEXT: store i64 1, ptr [[PTR_IV]], align 1
93 ; IC1-NEXT: br label %[[LOOP_LATCH]]
95 ; IC1-NEXT: store i64 2, ptr [[PTR_IV]], align 1
96 ; IC1-NEXT: br label %[[LOOP_LATCH]]
97 ; IC1: [[LOOP_LATCH]]:
98 ; IC1-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
99 ; IC1-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
100 ; IC1-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
104 ; IC2-LABEL: define void @switch_all_dests_distinct(
105 ; IC2-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0]] {
106 ; IC2-NEXT: [[ENTRY:.*]]:
107 ; IC2-NEXT: br label %[[LOOP_HEADER:.*]]
108 ; IC2: [[LOOP_HEADER]]:
109 ; IC2-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
110 ; IC2-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
111 ; IC2-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
112 ; IC2-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
113 ; IC2-NEXT: i64 13, label %[[IF_THEN_2:.*]]
114 ; IC2-NEXT: i64 0, label %[[IF_THEN_3:.*]]
116 ; IC2: [[IF_THEN_1]]:
117 ; IC2-NEXT: store i64 42, ptr [[PTR_IV]], align 1
118 ; IC2-NEXT: br label %[[LOOP_LATCH]]
119 ; IC2: [[IF_THEN_2]]:
120 ; IC2-NEXT: store i64 0, ptr [[PTR_IV]], align 1
121 ; IC2-NEXT: br label %[[LOOP_LATCH]]
122 ; IC2: [[IF_THEN_3]]:
123 ; IC2-NEXT: store i64 1, ptr [[PTR_IV]], align 1
124 ; IC2-NEXT: br label %[[LOOP_LATCH]]
126 ; IC2-NEXT: store i64 2, ptr [[PTR_IV]], align 1
127 ; IC2-NEXT: br label %[[LOOP_LATCH]]
128 ; IC2: [[LOOP_LATCH]]:
129 ; IC2-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
130 ; IC2-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
131 ; IC2-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
136 br label %loop.header
139 %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop.latch ]
140 %l = load i64, ptr %ptr.iv, align 1
141 switch i64 %l, label %default [
142 i64 -12, label %if.then.1
143 i64 13, label %if.then.2
144 i64 0, label %if.then.3
148 store i64 42, ptr %ptr.iv, align 1
152 store i64 0, ptr %ptr.iv, align 1
156 store i64 1, ptr %ptr.iv, align 1
160 store i64 2, ptr %ptr.iv, align 1
164 %ptr.iv.next = getelementptr inbounds i64, ptr %ptr.iv, i64 1
165 %ec = icmp eq ptr %ptr.iv.next, %end
166 br i1 %ec, label %exit, label %loop.header
173 define void @switch_multiple_common_dests(ptr %start, ptr %end) {
174 ; IC1-LABEL: define void @switch_multiple_common_dests(
175 ; IC1-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0]] {
176 ; IC1-NEXT: [[ENTRY:.*]]:
177 ; IC1-NEXT: br label %[[LOOP_HEADER:.*]]
178 ; IC1: [[LOOP_HEADER]]:
179 ; IC1-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
180 ; IC1-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
181 ; IC1-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
182 ; IC1-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
183 ; IC1-NEXT: i64 0, label %[[IF_THEN_1]]
184 ; IC1-NEXT: i64 13, label %[[IF_THEN_2:.*]]
185 ; IC1-NEXT: i64 14, label %[[IF_THEN_2]]
186 ; IC1-NEXT: i64 15, label %[[IF_THEN_2]]
188 ; IC1: [[IF_THEN_1]]:
189 ; IC1-NEXT: store i64 42, ptr [[PTR_IV]], align 1
190 ; IC1-NEXT: br label %[[LOOP_LATCH]]
191 ; IC1: [[IF_THEN_2]]:
192 ; IC1-NEXT: store i64 0, ptr [[PTR_IV]], align 1
193 ; IC1-NEXT: br label %[[LOOP_LATCH]]
195 ; IC1-NEXT: store i64 2, ptr [[PTR_IV]], align 1
196 ; IC1-NEXT: br label %[[LOOP_LATCH]]
197 ; IC1: [[LOOP_LATCH]]:
198 ; IC1-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
199 ; IC1-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
200 ; IC1-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
204 ; IC2-LABEL: define void @switch_multiple_common_dests(
205 ; IC2-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0]] {
206 ; IC2-NEXT: [[ENTRY:.*]]:
207 ; IC2-NEXT: br label %[[LOOP_HEADER:.*]]
208 ; IC2: [[LOOP_HEADER]]:
209 ; IC2-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
210 ; IC2-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
211 ; IC2-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
212 ; IC2-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
213 ; IC2-NEXT: i64 0, label %[[IF_THEN_1]]
214 ; IC2-NEXT: i64 13, label %[[IF_THEN_2:.*]]
215 ; IC2-NEXT: i64 14, label %[[IF_THEN_2]]
216 ; IC2-NEXT: i64 15, label %[[IF_THEN_2]]
218 ; IC2: [[IF_THEN_1]]:
219 ; IC2-NEXT: store i64 42, ptr [[PTR_IV]], align 1
220 ; IC2-NEXT: br label %[[LOOP_LATCH]]
221 ; IC2: [[IF_THEN_2]]:
222 ; IC2-NEXT: store i64 0, ptr [[PTR_IV]], align 1
223 ; IC2-NEXT: br label %[[LOOP_LATCH]]
225 ; IC2-NEXT: store i64 2, ptr [[PTR_IV]], align 1
226 ; IC2-NEXT: br label %[[LOOP_LATCH]]
227 ; IC2: [[LOOP_LATCH]]:
228 ; IC2-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
229 ; IC2-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
230 ; IC2-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
235 br label %loop.header
238 %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop.latch ]
239 %l = load i64, ptr %ptr.iv, align 1
240 switch i64 %l, label %default [
241 i64 -12, label %if.then.1
242 i64 0, label %if.then.1
243 i64 13, label %if.then.2
244 i64 14, label %if.then.2
245 i64 15, label %if.then.2
249 store i64 42, ptr %ptr.iv, align 1
253 store i64 0, ptr %ptr.iv, align 1
257 store i64 2, ptr %ptr.iv, align 1
261 %ptr.iv.next = getelementptr inbounds i64, ptr %ptr.iv, i64 1
262 %ec = icmp eq ptr %ptr.iv.next, %end
263 br i1 %ec, label %exit, label %loop.header
269 define void @switch4_default_common_dest_with_case(ptr %start, ptr %end) {
270 ; IC1-LABEL: define void @switch4_default_common_dest_with_case(
271 ; IC1-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0]] {
272 ; IC1-NEXT: [[ENTRY:.*]]:
273 ; IC1-NEXT: br label %[[LOOP_HEADER:.*]]
274 ; IC1: [[LOOP_HEADER]]:
275 ; IC1-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
276 ; IC1-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
277 ; IC1-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
278 ; IC1-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
279 ; IC1-NEXT: i64 13, label %[[IF_THEN_2:.*]]
280 ; IC1-NEXT: i64 0, label %[[DEFAULT]]
282 ; IC1: [[IF_THEN_1]]:
283 ; IC1-NEXT: store i64 42, ptr [[PTR_IV]], align 1
284 ; IC1-NEXT: br label %[[LOOP_LATCH]]
285 ; IC1: [[IF_THEN_2]]:
286 ; IC1-NEXT: store i64 0, ptr [[PTR_IV]], align 1
287 ; IC1-NEXT: br label %[[LOOP_LATCH]]
289 ; IC1-NEXT: store i64 2, ptr [[PTR_IV]], align 1
290 ; IC1-NEXT: br label %[[LOOP_LATCH]]
291 ; IC1: [[LOOP_LATCH]]:
292 ; IC1-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
293 ; IC1-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
294 ; IC1-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
298 ; IC2-LABEL: define void @switch4_default_common_dest_with_case(
299 ; IC2-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0]] {
300 ; IC2-NEXT: [[ENTRY:.*]]:
301 ; IC2-NEXT: br label %[[LOOP_HEADER:.*]]
302 ; IC2: [[LOOP_HEADER]]:
303 ; IC2-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
304 ; IC2-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
305 ; IC2-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
306 ; IC2-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
307 ; IC2-NEXT: i64 13, label %[[IF_THEN_2:.*]]
308 ; IC2-NEXT: i64 0, label %[[DEFAULT]]
310 ; IC2: [[IF_THEN_1]]:
311 ; IC2-NEXT: store i64 42, ptr [[PTR_IV]], align 1
312 ; IC2-NEXT: br label %[[LOOP_LATCH]]
313 ; IC2: [[IF_THEN_2]]:
314 ; IC2-NEXT: store i64 0, ptr [[PTR_IV]], align 1
315 ; IC2-NEXT: br label %[[LOOP_LATCH]]
317 ; IC2-NEXT: store i64 2, ptr [[PTR_IV]], align 1
318 ; IC2-NEXT: br label %[[LOOP_LATCH]]
319 ; IC2: [[LOOP_LATCH]]:
320 ; IC2-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
321 ; IC2-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
322 ; IC2-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
327 br label %loop.header
330 %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop.latch ]
331 %l = load i64, ptr %ptr.iv, align 1
332 switch i64 %l, label %default [
333 i64 -12, label %if.then.1
334 i64 13, label %if.then.2
335 i64 0, label %default
339 store i64 42, ptr %ptr.iv, align 1
343 store i64 0, ptr %ptr.iv, align 1
347 store i64 2, ptr %ptr.iv, align 1
351 %ptr.iv.next = getelementptr inbounds i64, ptr %ptr.iv, i64 1
352 %ec = icmp eq ptr %ptr.iv.next, %end
353 br i1 %ec, label %exit, label %loop.header
359 define void @switch_under_br_default_common_dest_with_case(ptr %start, ptr %end, i64 %x) {
360 ; IC1-LABEL: define void @switch_under_br_default_common_dest_with_case(
361 ; IC1-SAME: ptr [[START:%.*]], ptr [[END:%.*]], i64 [[X:%.*]]) #[[ATTR0]] {
362 ; IC1-NEXT: [[ENTRY:.*]]:
363 ; IC1-NEXT: br label %[[LOOP_HEADER:.*]]
364 ; IC1: [[LOOP_HEADER]]:
365 ; IC1-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
366 ; IC1-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
367 ; IC1-NEXT: [[C:%.*]] = icmp ule i64 [[L]], [[X]]
368 ; IC1-NEXT: br i1 [[C]], label %[[THEN:.*]], label %[[LOOP_LATCH]]
370 ; IC1-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
371 ; IC1-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
372 ; IC1-NEXT: i64 13, label %[[IF_THEN_2:.*]]
373 ; IC1-NEXT: i64 0, label %[[DEFAULT]]
375 ; IC1: [[IF_THEN_1]]:
376 ; IC1-NEXT: store i64 42, ptr [[PTR_IV]], align 1
377 ; IC1-NEXT: br label %[[LOOP_LATCH]]
378 ; IC1: [[IF_THEN_2]]:
379 ; IC1-NEXT: store i64 0, ptr [[PTR_IV]], align 1
380 ; IC1-NEXT: br label %[[LOOP_LATCH]]
382 ; IC1-NEXT: store i64 2, ptr [[PTR_IV]], align 1
383 ; IC1-NEXT: br label %[[LOOP_LATCH]]
384 ; IC1: [[LOOP_LATCH]]:
385 ; IC1-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
386 ; IC1-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
387 ; IC1-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
391 ; IC2-LABEL: define void @switch_under_br_default_common_dest_with_case(
392 ; IC2-SAME: ptr [[START:%.*]], ptr [[END:%.*]], i64 [[X:%.*]]) #[[ATTR0]] {
393 ; IC2-NEXT: [[ENTRY:.*]]:
394 ; IC2-NEXT: br label %[[LOOP_HEADER:.*]]
395 ; IC2: [[LOOP_HEADER]]:
396 ; IC2-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
397 ; IC2-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
398 ; IC2-NEXT: [[C:%.*]] = icmp ule i64 [[L]], [[X]]
399 ; IC2-NEXT: br i1 [[C]], label %[[THEN:.*]], label %[[LOOP_LATCH]]
401 ; IC2-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
402 ; IC2-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
403 ; IC2-NEXT: i64 13, label %[[IF_THEN_2:.*]]
404 ; IC2-NEXT: i64 0, label %[[DEFAULT]]
406 ; IC2: [[IF_THEN_1]]:
407 ; IC2-NEXT: store i64 42, ptr [[PTR_IV]], align 1
408 ; IC2-NEXT: br label %[[LOOP_LATCH]]
409 ; IC2: [[IF_THEN_2]]:
410 ; IC2-NEXT: store i64 0, ptr [[PTR_IV]], align 1
411 ; IC2-NEXT: br label %[[LOOP_LATCH]]
413 ; IC2-NEXT: store i64 2, ptr [[PTR_IV]], align 1
414 ; IC2-NEXT: br label %[[LOOP_LATCH]]
415 ; IC2: [[LOOP_LATCH]]:
416 ; IC2-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
417 ; IC2-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
418 ; IC2-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
423 br label %loop.header
426 %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop.latch ]
427 %l = load i64, ptr %ptr.iv, align 1
428 %c = icmp ule i64 %l, %x
429 br i1 %c, label %then, label %loop.latch
432 switch i64 %l, label %default [
433 i64 -12, label %if.then.1
434 i64 13, label %if.then.2
435 i64 0, label %default
439 store i64 42, ptr %ptr.iv, align 1
443 store i64 0, ptr %ptr.iv, align 1
447 store i64 2, ptr %ptr.iv, align 1
451 %ptr.iv.next = getelementptr inbounds i64, ptr %ptr.iv, i64 1
452 %ec = icmp eq ptr %ptr.iv.next, %end
453 br i1 %ec, label %exit, label %loop.header
459 define void @br_under_switch_default_common_dest_with_case(ptr %start, ptr %end, i64 %x) {
460 ; IC1-LABEL: define void @br_under_switch_default_common_dest_with_case(
461 ; IC1-SAME: ptr [[START:%.*]], ptr [[END:%.*]], i64 [[X:%.*]]) #[[ATTR0]] {
462 ; IC1-NEXT: [[ENTRY:.*]]:
463 ; IC1-NEXT: br label %[[LOOP_HEADER:.*]]
464 ; IC1: [[LOOP_HEADER]]:
465 ; IC1-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
466 ; IC1-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
467 ; IC1-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
468 ; IC1-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
469 ; IC1-NEXT: i64 13, label %[[IF_THEN_2:.*]]
470 ; IC1-NEXT: i64 0, label %[[DEFAULT]]
472 ; IC1: [[IF_THEN_1]]:
473 ; IC1-NEXT: [[C:%.*]] = icmp ule i64 [[L]], [[X]]
474 ; IC1-NEXT: br i1 [[C]], label %[[THEN:.*]], label %[[IF_THEN_2]]
476 ; IC1-NEXT: store i64 42, ptr [[PTR_IV]], align 1
477 ; IC1-NEXT: br label %[[DEFAULT]]
478 ; IC1: [[IF_THEN_2]]:
479 ; IC1-NEXT: store i64 0, ptr [[PTR_IV]], align 1
480 ; IC1-NEXT: br label %[[LOOP_LATCH]]
482 ; IC1-NEXT: store i64 2, ptr [[PTR_IV]], align 1
483 ; IC1-NEXT: br label %[[LOOP_LATCH]]
484 ; IC1: [[LOOP_LATCH]]:
485 ; IC1-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
486 ; IC1-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
487 ; IC1-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
491 ; IC2-LABEL: define void @br_under_switch_default_common_dest_with_case(
492 ; IC2-SAME: ptr [[START:%.*]], ptr [[END:%.*]], i64 [[X:%.*]]) #[[ATTR0]] {
493 ; IC2-NEXT: [[ENTRY:.*]]:
494 ; IC2-NEXT: br label %[[LOOP_HEADER:.*]]
495 ; IC2: [[LOOP_HEADER]]:
496 ; IC2-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[START]], %[[ENTRY]] ], [ [[PTR_IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
497 ; IC2-NEXT: [[L:%.*]] = load i64, ptr [[PTR_IV]], align 1
498 ; IC2-NEXT: switch i64 [[L]], label %[[DEFAULT:.*]] [
499 ; IC2-NEXT: i64 -12, label %[[IF_THEN_1:.*]]
500 ; IC2-NEXT: i64 13, label %[[IF_THEN_2:.*]]
501 ; IC2-NEXT: i64 0, label %[[DEFAULT]]
503 ; IC2: [[IF_THEN_1]]:
504 ; IC2-NEXT: [[C:%.*]] = icmp ule i64 [[L]], [[X]]
505 ; IC2-NEXT: br i1 [[C]], label %[[THEN:.*]], label %[[IF_THEN_2]]
507 ; IC2-NEXT: store i64 42, ptr [[PTR_IV]], align 1
508 ; IC2-NEXT: br label %[[DEFAULT]]
509 ; IC2: [[IF_THEN_2]]:
510 ; IC2-NEXT: store i64 0, ptr [[PTR_IV]], align 1
511 ; IC2-NEXT: br label %[[LOOP_LATCH]]
513 ; IC2-NEXT: store i64 2, ptr [[PTR_IV]], align 1
514 ; IC2-NEXT: br label %[[LOOP_LATCH]]
515 ; IC2: [[LOOP_LATCH]]:
516 ; IC2-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i64, ptr [[PTR_IV]], i64 1
517 ; IC2-NEXT: [[EC:%.*]] = icmp eq ptr [[PTR_IV_NEXT]], [[END]]
518 ; IC2-NEXT: br i1 [[EC]], label %[[EXIT:.*]], label %[[LOOP_HEADER]]
523 br label %loop.header
526 %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop.latch ]
527 %l = load i64, ptr %ptr.iv, align 1
528 switch i64 %l, label %default [
529 i64 -12, label %if.then.1
530 i64 13, label %if.then.2
531 i64 0, label %default
535 %c = icmp ule i64 %l, %x
536 br i1 %c, label %then, label %if.then.2
539 store i64 42, ptr %ptr.iv, align 1
543 store i64 0, ptr %ptr.iv, align 1
547 store i64 2, ptr %ptr.iv, align 1
551 %ptr.iv.next = getelementptr inbounds i64, ptr %ptr.iv, i64 1
552 %ec = icmp eq ptr %ptr.iv.next, %end
553 br i1 %ec, label %exit, label %loop.header