1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='require<domtree>,loop(loop-simplifycfg),gvn' -S %s | FileCheck %s
4 define i32 @test_pointer_phi_select_simp_1(ptr %a, ptr %b, i1 %cond) {
5 ; CHECK-LABEL: @test_pointer_phi_select_simp_1(
7 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
9 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
10 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
11 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
12 ; CHECK-NEXT: [[TMP0:%.*]] = select i1 [[CMP_I_I_I]], i32 [[L_1]], i32 [[L_2]]
13 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
14 ; CHECK-NEXT: br label [[EXIT:%.*]]
16 ; CHECK-NEXT: [[RES_2_PRE:%.*]] = load i32, ptr [[A]], align 4
17 ; CHECK-NEXT: br label [[EXIT]]
19 ; CHECK-NEXT: [[RES_2:%.*]] = phi i32 [ [[TMP0]], [[THEN]] ], [ [[RES_2_PRE]], [[ELSE]] ]
20 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
21 ; CHECK-NEXT: ret i32 [[RES_2]]
24 br i1 %cond, label %then, label %else
27 %l.1 = load i32, ptr %a, align 4
28 %l.2 = load i32, ptr %b, align 4
29 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
30 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
37 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
38 %res.2 = load i32, ptr %p, align 4
42 define i32 @test_pointer_phi_select_simp_non_local(ptr %a, ptr %b, ptr %c) {
43 ; CHECK-LABEL: @test_pointer_phi_select_simp_non_local(
45 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
46 ; CHECK-NEXT: [[COND:%.*]] = icmp sgt i32 [[L_1]], 0
47 ; CHECK-NEXT: br i1 [[COND]], label [[THEN:%.*]], label [[ELSE:%.*]]
49 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
50 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
51 ; CHECK-NEXT: [[TMP0:%.*]] = select i1 [[CMP_I_I_I]], i32 [[L_1]], i32 [[L_2]]
52 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
53 ; CHECK-NEXT: br label [[EXIT:%.*]]
55 ; CHECK-NEXT: [[RES_2_PRE:%.*]] = load i32, ptr [[C:%.*]], align 4
56 ; CHECK-NEXT: br label [[EXIT]]
58 ; CHECK-NEXT: [[RES_2:%.*]] = phi i32 [ [[TMP0]], [[THEN]] ], [ [[RES_2_PRE]], [[ELSE]] ]
59 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[C]], [[ELSE]] ]
60 ; CHECK-NEXT: ret i32 [[RES_2]]
63 %l.1 = load i32, ptr %a, align 4
64 %cond = icmp sgt i32 %l.1, 0
65 br i1 %cond, label %then, label %else
68 %l.2 = load i32, ptr %b, align 4
69 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
70 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
77 %p = phi ptr [ %min.select, %then ], [ %c, %else ]
78 %res.2 = load i32, ptr %p, align 4
82 define i32 @test_pointer_phi_select_simp_non_local_mismatched_type(ptr %a, ptr %b, ptr %c) {
83 ; CHECK-LABEL: @test_pointer_phi_select_simp_non_local_mismatched_type(
85 ; CHECK-NEXT: [[L_1:%.*]] = load float, ptr [[A:%.*]], align 4
86 ; CHECK-NEXT: [[CONV:%.*]] = fptosi float [[L_1]] to i32
87 ; CHECK-NEXT: [[COND:%.*]] = icmp sgt i32 [[CONV]], 0
88 ; CHECK-NEXT: br i1 [[COND]], label [[THEN:%.*]], label [[ELSE:%.*]]
90 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
91 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[CONV]], [[L_2]]
92 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
93 ; CHECK-NEXT: br label [[EXIT:%.*]]
95 ; CHECK-NEXT: br label [[EXIT]]
97 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[C:%.*]], [[ELSE]] ]
98 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
99 ; CHECK-NEXT: ret i32 [[RES_2]]
102 %l.1 = load float, ptr %a, align 4
103 %conv = fptosi float %l.1 to i32
104 %cond = icmp sgt i32 %conv, 0
105 br i1 %cond, label %then, label %else
108 %l.2 = load i32, ptr %b, align 4
109 %cmp.i.i.i = icmp ult i32 %conv, %l.2
110 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
117 %p = phi ptr [ %min.select, %then ], [ %c, %else ]
118 %res.2 = load i32, ptr %p, align 4
122 define i32 @test_pointer_phi_select_simp_no_load_for_select_op_1(ptr %a, ptr %b, ptr %c, i1 %cond) {
123 ; CHECK-LABEL: @test_pointer_phi_select_simp_no_load_for_select_op_1(
125 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
127 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[C:%.*]], align 4
128 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
129 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
130 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A:%.*]], ptr [[B]]
131 ; CHECK-NEXT: br label [[EXIT:%.*]]
133 ; CHECK-NEXT: br label [[EXIT]]
135 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
136 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
137 ; CHECK-NEXT: ret i32 [[RES_2]]
140 br i1 %cond, label %then, label %else
143 %l.1 = load i32, ptr %c, align 4
144 %l.2 = load i32, ptr %b, align 4
145 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
146 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
153 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
154 %res.2 = load i32, ptr %p, align 4
158 define i32 @test_pointer_phi_select_simp_no_load_for_select_op_2(ptr %a, ptr %b, ptr %c, i1 %cond) {
159 ; CHECK-LABEL: @test_pointer_phi_select_simp_no_load_for_select_op_2(
161 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
163 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
164 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[C:%.*]], align 4
165 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
166 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B:%.*]]
167 ; CHECK-NEXT: br label [[EXIT:%.*]]
169 ; CHECK-NEXT: br label [[EXIT]]
171 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
172 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
173 ; CHECK-NEXT: ret i32 [[RES_2]]
176 br i1 %cond, label %then, label %else
179 %l.1 = load i32, ptr %a, align 4
180 %l.2 = load i32, ptr %c, align 4
181 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
182 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
189 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
190 %res.2 = load i32, ptr %p, align 4
194 define i32 @test_pointer_phi_select_simp_store_noclobber(ptr %a, ptr %b, ptr noalias %c, i1 %cond) {
195 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_noclobber(
197 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
199 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
200 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
201 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
202 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
203 ; CHECK-NEXT: [[TMP0:%.*]] = select i1 [[CMP_I_I_I]], i32 [[L_1]], i32 [[L_2]]
204 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
205 ; CHECK-NEXT: br label [[EXIT:%.*]]
207 ; CHECK-NEXT: [[RES_2_PRE:%.*]] = load i32, ptr [[A]], align 4
208 ; CHECK-NEXT: br label [[EXIT]]
210 ; CHECK-NEXT: [[RES_2:%.*]] = phi i32 [ [[TMP0]], [[THEN]] ], [ [[RES_2_PRE]], [[ELSE]] ]
211 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
212 ; CHECK-NEXT: ret i32 [[RES_2]]
215 br i1 %cond, label %then, label %else
218 %l.1 = load i32, ptr %a, align 4
219 %l.2 = load i32, ptr %b, align 4
221 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
222 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
229 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
230 %res.2 = load i32, ptr %p, align 4
234 define i32 @test_pointer_phi_select_simp_store_clobber_1(ptr %a, ptr %b, ptr %c, i1 %cond) {
235 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_1(
237 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
239 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
240 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
241 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
242 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
243 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
244 ; CHECK-NEXT: br label [[EXIT:%.*]]
246 ; CHECK-NEXT: br label [[EXIT]]
248 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
249 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
250 ; CHECK-NEXT: ret i32 [[RES_2]]
253 br i1 %cond, label %then, label %else
256 %l.1 = load i32, ptr %a, align 4
257 %l.2 = load i32, ptr %b, align 4
259 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
260 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
267 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
268 %res.2 = load i32, ptr %p, align 4
272 define i32 @test_pointer_phi_select_simp_store_clobber_2(ptr %a, ptr %b, ptr %c, i1 %cond) {
273 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_2(
275 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
277 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
278 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
279 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
280 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
281 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
282 ; CHECK-NEXT: br label [[EXIT:%.*]]
284 ; CHECK-NEXT: br label [[EXIT]]
286 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
287 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
288 ; CHECK-NEXT: ret i32 [[RES_2]]
291 br i1 %cond, label %then, label %else
294 %l.1 = load i32, ptr %a, align 4
296 %l.2 = load i32, ptr %b, align 4
297 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
298 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
305 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
306 %res.2 = load i32, ptr %p, align 4
310 define i32 @test_pointer_phi_select_simp_store_clobber_3(ptr %a, ptr %b, ptr %c, i1 %cond) {
311 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_3(
313 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
315 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
316 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
317 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
318 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
319 ; CHECK-NEXT: [[TMP0:%.*]] = select i1 [[CMP_I_I_I]], i32 [[L_1]], i32 [[L_2]]
320 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
321 ; CHECK-NEXT: br label [[EXIT:%.*]]
323 ; CHECK-NEXT: [[RES_2_PRE:%.*]] = load i32, ptr [[A]], align 4
324 ; CHECK-NEXT: br label [[EXIT]]
326 ; CHECK-NEXT: [[RES_2:%.*]] = phi i32 [ [[TMP0]], [[THEN]] ], [ [[RES_2_PRE]], [[ELSE]] ]
327 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
328 ; CHECK-NEXT: ret i32 [[RES_2]]
331 br i1 %cond, label %then, label %else
335 %l.1 = load i32, ptr %a, align 4
336 %l.2 = load i32, ptr %b, align 4
337 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
338 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
345 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
346 %res.2 = load i32, ptr %p, align 4
350 define i32 @test_pointer_phi_select_simp_store_clobber_4(ptr %a, ptr %b, ptr %c, i1 %cond) {
351 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_4(
353 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
355 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
356 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
357 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
358 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
359 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
360 ; CHECK-NEXT: br label [[EXIT:%.*]]
362 ; CHECK-NEXT: br label [[EXIT]]
364 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
365 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
366 ; CHECK-NEXT: ret i32 [[RES_2]]
369 br i1 %cond, label %then, label %else
372 %l.1 = load i32, ptr %a, align 4
373 %l.2 = load i32, ptr %b, align 4
374 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
375 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
383 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
384 %res.2 = load i32, ptr %p, align 4
388 define i32 @test_pointer_phi_select_simp_store_clobber_5(ptr %a, ptr %b, ptr %c, i1 %cond) {
389 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_5(
391 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
393 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
394 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
395 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
396 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
397 ; CHECK-NEXT: br label [[EXIT:%.*]]
399 ; CHECK-NEXT: br label [[EXIT]]
401 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
402 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
403 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
404 ; CHECK-NEXT: ret i32 [[RES_2]]
407 br i1 %cond, label %then, label %else
410 %l.1 = load i32, ptr %a, align 4
411 %l.2 = load i32, ptr %b, align 4
412 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
413 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
420 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
422 %res.2 = load i32, ptr %p, align 4
426 define i32 @test_pointer_phi_select_simp_store_clobber_6(ptr %a, ptr %b, ptr %c, i1 %cond) {
427 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_6(
429 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
431 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
432 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
433 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
434 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
435 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
436 ; CHECK-NEXT: [[RES_0:%.*]] = load i32, ptr [[MIN_SELECT]], align 4
437 ; CHECK-NEXT: br label [[EXIT:%.*]]
439 ; CHECK-NEXT: [[RES_2_PRE:%.*]] = load i32, ptr [[A]], align 4
440 ; CHECK-NEXT: br label [[EXIT]]
442 ; CHECK-NEXT: [[RES_2:%.*]] = phi i32 [ [[RES_0]], [[THEN]] ], [ [[RES_2_PRE]], [[ELSE]] ]
443 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
444 ; CHECK-NEXT: [[V:%.*]] = phi i32 [ [[RES_0]], [[THEN]] ], [ 10, [[ELSE]] ]
445 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[RES_2]], [[V]]
446 ; CHECK-NEXT: ret i32 [[RES_2]]
449 br i1 %cond, label %then, label %else
452 %l.1 = load i32, ptr %a, align 4
453 %l.2 = load i32, ptr %b, align 4
455 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
456 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
457 %res.0 = load i32, ptr %min.select, align 4
464 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
465 %v = phi i32 [ %res.0, %then ], [ 10, %else ]
466 %res.2 = load i32, ptr %p, align 4
467 %add = add i32 %res.2, %v
471 define i32 @test_pointer_phi_select_simp_store_clobber_7(ptr %a, ptr %b, ptr %c, i1 %cond) {
472 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_7(
474 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
476 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
477 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
478 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
479 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
480 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
481 ; CHECK-NEXT: [[RES_0:%.*]] = load i32, ptr [[A]], align 4
482 ; CHECK-NEXT: br label [[EXIT:%.*]]
484 ; CHECK-NEXT: br label [[EXIT]]
486 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
487 ; CHECK-NEXT: [[V:%.*]] = phi i32 [ [[RES_0]], [[THEN]] ], [ 10, [[ELSE]] ]
488 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
489 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[RES_2]], [[V]]
490 ; CHECK-NEXT: ret i32 [[RES_2]]
493 br i1 %cond, label %then, label %else
496 %l.1 = load i32, ptr %a, align 4
497 %l.2 = load i32, ptr %b, align 4
499 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
500 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
501 %res.0 = load i32, ptr %a, align 4
508 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
509 %v = phi i32 [ %res.0, %then ], [ 10, %else ]
510 %res.2 = load i32, ptr %p, align 4
511 %add = add i32 %res.2, %v
515 define i32 @test_pointer_phi_select_simp_store_clobber_8(ptr %a, ptr %b, ptr %c, i1 %cond) {
516 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_8(
518 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
520 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
521 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
522 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
523 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
524 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
525 ; CHECK-NEXT: [[RES_0:%.*]] = load i32, ptr [[B]], align 4
526 ; CHECK-NEXT: br label [[EXIT:%.*]]
528 ; CHECK-NEXT: br label [[EXIT]]
530 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
531 ; CHECK-NEXT: [[V:%.*]] = phi i32 [ [[RES_0]], [[THEN]] ], [ 10, [[ELSE]] ]
532 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
533 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[RES_2]], [[V]]
534 ; CHECK-NEXT: ret i32 [[RES_2]]
537 br i1 %cond, label %then, label %else
540 %l.1 = load i32, ptr %a, align 4
541 %l.2 = load i32, ptr %b, align 4
543 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
544 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
545 %res.0 = load i32, ptr %b, align 4
552 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
553 %v = phi i32 [ %res.0, %then ], [ 10, %else ]
554 %res.2 = load i32, ptr %p, align 4
555 %add = add i32 %res.2, %v
559 define i32 @test_pointer_phi_select_simp_store_clobber_9(ptr %a, ptr %b, i1 %cond) {
560 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_9(
562 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
564 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
565 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
566 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
567 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
568 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
569 ; CHECK-NEXT: [[RES_0:%.*]] = load i32, ptr [[B]], align 4
570 ; CHECK-NEXT: br label [[EXIT:%.*]]
572 ; CHECK-NEXT: br label [[EXIT]]
574 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
575 ; CHECK-NEXT: [[V:%.*]] = phi i32 [ [[RES_0]], [[THEN]] ], [ 10, [[ELSE]] ]
576 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
577 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[RES_2]], [[V]]
578 ; CHECK-NEXT: ret i32 [[RES_2]]
581 br i1 %cond, label %then, label %else
584 %l.1 = load i32, ptr %a, align 4
585 %l.2 = load i32, ptr %b, align 4
587 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
588 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
589 %res.0 = load i32, ptr %b, align 4
596 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
597 %v = phi i32 [ %res.0, %then ], [ 10, %else ]
598 %res.2 = load i32, ptr %p, align 4
599 %add = add i32 %res.2, %v
603 define i32 @test_pointer_phi_select_simp_store_clobber_10(ptr %a, ptr %b, i1 %cond) {
604 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_10(
606 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
608 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
609 ; CHECK-NEXT: store i32 99, ptr [[A]], align 4
610 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
611 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
612 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
613 ; CHECK-NEXT: br label [[EXIT:%.*]]
615 ; CHECK-NEXT: br label [[EXIT]]
617 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
618 ; CHECK-NEXT: [[V:%.*]] = phi i32 [ [[L_2]], [[THEN]] ], [ 10, [[ELSE]] ]
619 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
620 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[RES_2]], [[V]]
621 ; CHECK-NEXT: ret i32 [[RES_2]]
624 br i1 %cond, label %then, label %else
627 %l.1 = load i32, ptr %a, align 4
629 %l.2 = load i32, ptr %b, align 4
630 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
631 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
632 %res.0 = load i32, ptr %b, align 4
639 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
640 %v = phi i32 [ %res.0, %then ], [ 10, %else ]
641 %res.2 = load i32, ptr %p, align 4
642 %add = add i32 %res.2, %v
646 define i32 @test_pointer_phi_select_simp_store_clobber_11(ptr %a, ptr %b, i1 %cond) {
647 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_11(
649 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
651 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
652 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
653 ; CHECK-NEXT: store i32 99, ptr [[B]], align 4
654 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
655 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
656 ; CHECK-NEXT: br label [[EXIT:%.*]]
658 ; CHECK-NEXT: br label [[EXIT]]
660 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
661 ; CHECK-NEXT: [[V:%.*]] = phi i32 [ 99, [[THEN]] ], [ 10, [[ELSE]] ]
662 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
663 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[RES_2]], [[V]]
664 ; CHECK-NEXT: ret i32 [[RES_2]]
667 br i1 %cond, label %then, label %else
670 %l.1 = load i32, ptr %a, align 4
671 %l.2 = load i32, ptr %b, align 4
673 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
674 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
675 %res.0 = load i32, ptr %b, align 4
682 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
683 %v = phi i32 [ %res.0, %then ], [ 10, %else ]
684 %res.2 = load i32, ptr %p, align 4
685 %add = add i32 %res.2, %v
689 define i32 @test_pointer_phi_select_simp_store_clobber_12(ptr %a, ptr %b, i1 %cond) {
690 ; CHECK-LABEL: @test_pointer_phi_select_simp_store_clobber_12(
692 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[ELSE:%.*]]
694 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
695 ; CHECK-NEXT: store i32 99, ptr [[B:%.*]], align 4
696 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], 99
697 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
698 ; CHECK-NEXT: br label [[EXIT:%.*]]
700 ; CHECK-NEXT: br label [[EXIT]]
702 ; CHECK-NEXT: [[P:%.*]] = phi ptr [ [[MIN_SELECT]], [[THEN]] ], [ [[A]], [[ELSE]] ]
703 ; CHECK-NEXT: [[V:%.*]] = phi i32 [ 99, [[THEN]] ], [ 10, [[ELSE]] ]
704 ; CHECK-NEXT: [[RES_2:%.*]] = load i32, ptr [[P]], align 4
705 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[RES_2]], [[V]]
706 ; CHECK-NEXT: ret i32 [[RES_2]]
709 br i1 %cond, label %then, label %else
712 %l.1 = load i32, ptr %a, align 4
714 %l.2 = load i32, ptr %b, align 4
715 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
716 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
717 %res.0 = load i32, ptr %b, align 4
724 %p = phi ptr [ %min.select, %then ], [ %a, %else ]
725 %v = phi i32 [ %res.0, %then ], [ 10, %else ]
726 %res.2 = load i32, ptr %p, align 4
727 %add = add i32 %res.2, %v
731 define i32 @test_pointer_phi_select_single_block_store(ptr %a, ptr %b) {
732 ; CHECK-LABEL: @test_pointer_phi_select_single_block_store(
734 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
735 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
736 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
737 ; CHECK-NEXT: [[TMP0:%.*]] = select i1 [[CMP_I_I_I]], i32 [[L_1]], i32 [[L_2]]
738 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
739 ; CHECK-NEXT: ret i32 [[TMP0]]
742 %l.1 = load i32, ptr %a, align 4
743 %l.2 = load i32, ptr %b, align 4
744 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
745 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
746 %res.0 = load i32, ptr %min.select, align 4
750 define i32 @test_pointer_phi_select_single_block_store_clobber_1(ptr %a, ptr %b, ptr %c) {
751 ; CHECK-LABEL: @test_pointer_phi_select_single_block_store_clobber_1(
753 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
754 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
755 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
756 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
757 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
758 ; CHECK-NEXT: [[RES_0:%.*]] = load i32, ptr [[MIN_SELECT]], align 4
759 ; CHECK-NEXT: ret i32 [[RES_0]]
762 %l.1 = load i32, ptr %a, align 4
763 %l.2 = load i32, ptr %b, align 4
765 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
766 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
767 %res.0 = load i32, ptr %min.select, align 4
771 define i32 @test_pointer_phi_select_single_block_store_clobber_2(ptr %a, ptr %b, ptr %c) {
772 ; CHECK-LABEL: @test_pointer_phi_select_single_block_store_clobber_2(
774 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
775 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
776 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
777 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
778 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
779 ; CHECK-NEXT: [[RES_0:%.*]] = load i32, ptr [[MIN_SELECT]], align 4
780 ; CHECK-NEXT: ret i32 [[RES_0]]
783 %l.1 = load i32, ptr %a, align 4
784 %l.2 = load i32, ptr %b, align 4
785 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
786 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
788 %res.0 = load i32, ptr %min.select, align 4
792 define i32 @test_pointer_phi_select_single_block_store_clobber_3(ptr %a, ptr %b, ptr %c) {
793 ; CHECK-LABEL: @test_pointer_phi_select_single_block_store_clobber_3(
795 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
796 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
797 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
798 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
799 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
800 ; CHECK-NEXT: [[RES_0:%.*]] = load i32, ptr [[MIN_SELECT]], align 4
801 ; CHECK-NEXT: ret i32 [[RES_0]]
804 %l.1 = load i32, ptr %a, align 4
806 %l.2 = load i32, ptr %b, align 4
807 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
808 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
809 %res.0 = load i32, ptr %min.select, align 4
813 define i32 @test_pointer_phi_select_single_block_store_after(ptr %a, ptr %b, ptr %c) {
814 ; CHECK-LABEL: @test_pointer_phi_select_single_block_store_after(
816 ; CHECK-NEXT: [[L_1:%.*]] = load i32, ptr [[A:%.*]], align 4
817 ; CHECK-NEXT: [[L_2:%.*]] = load i32, ptr [[B:%.*]], align 4
818 ; CHECK-NEXT: [[CMP_I_I_I:%.*]] = icmp ult i32 [[L_1]], [[L_2]]
819 ; CHECK-NEXT: [[TMP0:%.*]] = select i1 [[CMP_I_I_I]], i32 [[L_1]], i32 [[L_2]]
820 ; CHECK-NEXT: [[MIN_SELECT:%.*]] = select i1 [[CMP_I_I_I]], ptr [[A]], ptr [[B]]
821 ; CHECK-NEXT: store i32 99, ptr [[C:%.*]], align 4
822 ; CHECK-NEXT: ret i32 [[TMP0]]
825 %l.1 = load i32, ptr %a, align 4
826 %l.2 = load i32, ptr %b, align 4
827 %cmp.i.i.i = icmp ult i32 %l.1, %l.2
828 %min.select = select i1 %cmp.i.i.i, ptr %a, ptr %b
829 %res.0 = load i32, ptr %min.select, align 4
834 define i32 @test_phi_select_index_non_local(ptr %A, i32 %N, i32 %i) {
835 ; CHECK-LABEL: @test_phi_select_index_non_local(
837 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I:%.*]], [[N:%.*]]
838 ; CHECK-NEXT: br i1 [[CMP]], label [[LAND_LHS_TRUE:%.*]], label [[IF_END:%.*]]
839 ; CHECK: land.lhs.true:
840 ; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[I]] to i64
841 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM]]
842 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
843 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[I]], 1
844 ; CHECK-NEXT: [[IDXPROM1:%.*]] = sext i32 [[ADD]] to i64
845 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM1]]
846 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
847 ; CHECK-NEXT: [[CMP3:%.*]] = icmp slt i32 [[TMP0]], [[TMP1]]
848 ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[CMP3]], i32 [[ADD]], i32 [[I]]
849 ; CHECK-NEXT: br label [[IF_END]]
851 ; CHECK-NEXT: [[I_ADDR_0:%.*]] = phi i32 [ [[I]], [[ENTRY:%.*]] ], [ [[SPEC_SELECT]], [[LAND_LHS_TRUE]] ]
852 ; CHECK-NEXT: [[IDXPROM5:%.*]] = sext i32 [[I_ADDR_0]] to i64
853 ; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM5]]
854 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARRAYIDX6]], align 4
855 ; CHECK-NEXT: ret i32 [[TMP2]]
858 %cmp = icmp slt i32 %i, %N
859 br i1 %cmp, label %land.lhs.true, label %if.end
862 %idxprom = sext i32 %i to i64
863 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %idxprom
864 %0 = load i32, ptr %arrayidx, align 4
865 %add = add nsw i32 %i, 1
866 %idxprom1 = sext i32 %add to i64
867 %arrayidx2 = getelementptr inbounds i32, ptr %A, i64 %idxprom1
868 %1 = load i32, ptr %arrayidx2, align 4
869 %cmp3 = icmp slt i32 %0, %1
870 %spec.select = select i1 %cmp3, i32 %add, i32 %i
874 %i.addr.0 = phi i32 [ %i, %entry ], [ %spec.select, %land.lhs.true ]
875 %idxprom5 = sext i32 %i.addr.0 to i64
876 %arrayidx6 = getelementptr inbounds i32, ptr %A, i64 %idxprom5
877 %2 = load i32, ptr %arrayidx6, align 4
881 define i32 @test_phi_select_index_loop(ptr %A, i32 %N) {
882 ; CHECK-LABEL: @test_phi_select_index_loop(
884 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], 1
885 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
886 ; CHECK: for.body.preheader:
887 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
889 ; CHECK-NEXT: [[IDX:%.*]] = phi i32 [ [[IDX_NEXT:%.*]], [[FOR_BODY]] ], [ 1, [[FOR_BODY_PREHEADER]] ]
890 ; CHECK-NEXT: [[RES:%.*]] = phi i32 [ [[SPEC_SELECT:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
891 ; CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[IDX]] to i64
892 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A:%.*]], i64 [[IDXPROM]]
893 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
894 ; CHECK-NEXT: [[IDXPROM1:%.*]] = sext i32 [[RES]] to i64
895 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM1]]
896 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX1]], align 4
897 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[TMP0]], [[TMP1]]
898 ; CHECK-NEXT: [[SPEC_SELECT]] = select i1 [[CMP1]], i32 [[IDX]], i32 [[RES]]
899 ; CHECK-NEXT: [[IDX_NEXT]] = add nsw i32 [[IDX]], 1
900 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[IDX_NEXT]], [[N]]
901 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY]]
902 ; CHECK: for.cond.cleanup.loopexit:
903 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
904 ; CHECK: for.cond.cleanup:
905 ; CHECK-NEXT: [[RES_0_LCSSA:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[SPEC_SELECT]], [[FOR_COND_CLEANUP_LOOPEXIT]] ]
906 ; CHECK-NEXT: ret i32 [[RES_0_LCSSA]]
909 %cmp = icmp sgt i32 %N, 1
910 br i1 %cmp, label %for.body, label %for.cond.cleanup
913 %idx = phi i32 [ 1, %entry ], [ %idx.next, %for.body ]
914 %res = phi i32 [ 0, %entry ], [ %spec.select, %for.body ]
915 %idxprom = sext i32 %idx to i64
916 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %idxprom
917 %0 = load i32, ptr %arrayidx, align 4
918 %idxprom1 = sext i32 %res to i64
919 %arrayidx1 = getelementptr inbounds i32, ptr %A, i64 %idxprom1
920 %1 = load i32, ptr %arrayidx1, align 4
921 %cmp1 = icmp slt i32 %0, %1
922 %spec.select = select i1 %cmp1, i32 %idx, i32 %res
923 %idx.next = add nsw i32 %idx, 1
924 %exitcond.not = icmp eq i32 %idx.next, %N
925 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
928 %res.0.lcssa = phi i32 [ 0, %entry ], [ %spec.select, %for.body ]