1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=newgvn -enable-phi-of-ops=true -S | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 define i32 @test1(i32, ptr) {
7 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP0:%.*]], 0
8 ; CHECK-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP5:%.*]]
9 ; CHECK: br label [[TMP6:%.*]]
10 ; CHECK: br label [[TMP6]]
11 ; CHECK: [[PHIOFOPS:%.*]] = phi i32 [ 105, [[TMP5]] ], [ 75, [[TMP4]] ]
12 ; CHECK-NEXT: [[DOT0:%.*]] = phi i32 [ 5, [[TMP4]] ], [ 7, [[TMP5]] ]
13 ; CHECK-NEXT: ret i32 [[PHIOFOPS]]
15 %3 = icmp ne i32 %0, 0
16 br i1 %3, label %4, label %5
18 ; <label>:4: ; preds = %2
21 ; <label>:5: ; preds = %2
24 ; <label>:6: ; preds = %5, %4
25 %.0 = phi i32 [ 5, %4 ], [ 7, %5 ]
26 %7 = mul nsw i32 %.0, 15
29 ;; Dependent phi of ops
30 define i32 @test1b(i32, ptr) {
31 ; CHECK-LABEL: @test1b(
32 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ne i32 [[TMP0:%.*]], 0
33 ; CHECK-NEXT: br i1 [[TMP3]], label [[TMP4:%.*]], label [[TMP5:%.*]]
34 ; CHECK: br label [[TMP6:%.*]]
35 ; CHECK: br label [[TMP6]]
36 ; CHECK: [[PHIOFOPS1:%.*]] = phi i32 [ 105, [[TMP5]] ], [ 75, [[TMP4]] ]
37 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i32 [ 1575, [[TMP5]] ], [ 1125, [[TMP4]] ]
38 ; CHECK-NEXT: [[DOT0:%.*]] = phi i32 [ 5, [[TMP4]] ], [ 7, [[TMP5]] ]
39 ; CHECK-NEXT: ret i32 [[PHIOFOPS]]
41 %3 = icmp ne i32 %0, 0
42 br i1 %3, label %4, label %5
44 ; <label>:4: ; preds = %2
47 ; <label>:5: ; preds = %2
50 ; <label>:6: ; preds = %5, %4
51 %.0 = phi i32 [ 5, %4 ], [ 7, %5 ]
52 %7 = mul nsw i32 %.0, 15
53 %8 = mul nsw i32 %7, 15
57 define i32 @test2(i32) {
58 ; CHECK-LABEL: @test2(
59 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP0:%.*]], 0
60 ; CHECK-NEXT: br i1 [[TMP2]], label [[TMP3:%.*]], label [[TMP4:%.*]]
61 ; CHECK: br label [[TMP5:%.*]]
62 ; CHECK: br label [[TMP5]]
63 ; CHECK: [[DOT01:%.*]] = phi i32 [ 3, [[TMP3]] ], [ 2, [[TMP4]] ]
64 ; CHECK-NEXT: [[DOT0:%.*]] = phi i32 [ 2, [[TMP3]] ], [ 3, [[TMP4]] ]
65 ; CHECK-NEXT: ret i32 5
67 %2 = icmp ne i32 %0, 0
68 br i1 %2, label %3, label %4
70 ; <label>:3: ; preds = %1
73 ; <label>:4: ; preds = %1
76 ; <label>:5: ; preds = %4, %3
77 %.01 = phi i32 [ 3, %3 ], [ 2, %4 ]
78 %.0 = phi i32 [ 2, %3 ], [ 3, %4 ]
79 %6 = add nsw i32 %.01, %.0
82 define i32 @test3(i1 %which) {
83 ; CHECK-LABEL: @test3(
85 ; CHECK-NEXT: br i1 [[WHICH:%.*]], label [[FINAL:%.*]], label [[DELAY:%.*]]
87 ; CHECK-NEXT: br label [[FINAL]]
89 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i32 [ -877, [[ENTRY:%.*]] ], [ 113, [[DELAY]] ]
90 ; CHECK-NEXT: [[A:%.*]] = phi i32 [ 1000, [[ENTRY]] ], [ 10, [[DELAY]] ]
91 ; CHECK-NEXT: ret i32 [[PHIOFOPS]]
95 br i1 %which, label %final, label %delay
101 %A = phi i32 [ 1000, %entry ], [ 10, %delay ]
102 %value = sub i32 123, %A
106 define <2 x i32> @test3vec(i1 %which) {
107 ; CHECK-LABEL: @test3vec(
109 ; CHECK-NEXT: br i1 [[WHICH:%.*]], label [[FINAL:%.*]], label [[DELAY:%.*]]
111 ; CHECK-NEXT: br label [[FINAL]]
113 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi <2 x i32> [ <i32 -877, i32 -877>, [[ENTRY:%.*]] ], [ <i32 113, i32 113>, [[DELAY]] ]
114 ; CHECK-NEXT: [[A:%.*]] = phi <2 x i32> [ <i32 1000, i32 1000>, [[ENTRY]] ], [ <i32 10, i32 10>, [[DELAY]] ]
115 ; CHECK-NEXT: ret <2 x i32> [[PHIOFOPS]]
119 br i1 %which, label %final, label %delay
125 %A = phi <2 x i32> [ <i32 1000, i32 1000>, %entry ], [ <i32 10, i32 10>, %delay ]
126 %value = sub <2 x i32> <i32 123, i32 123>, %A
130 define <2 x i32> @test3vec2(i1 %which) {
131 ; CHECK-LABEL: @test3vec2(
133 ; CHECK-NEXT: br i1 [[WHICH:%.*]], label [[FINAL:%.*]], label [[DELAY:%.*]]
135 ; CHECK-NEXT: br label [[FINAL]]
137 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi <2 x i32> [ <i32 -877, i32 -2167>, [[ENTRY:%.*]] ], [ <i32 113, i32 303>, [[DELAY]] ]
138 ; CHECK-NEXT: [[A:%.*]] = phi <2 x i32> [ <i32 1000, i32 2500>, [[ENTRY]] ], [ <i32 10, i32 30>, [[DELAY]] ]
139 ; CHECK-NEXT: ret <2 x i32> [[PHIOFOPS]]
143 br i1 %which, label %final, label %delay
149 %A = phi <2 x i32> [ <i32 1000, i32 2500>, %entry ], [ <i32 10, i32 30>, %delay ]
150 %value = sub <2 x i32> <i32 123, i32 333>, %A
154 ;; This example is a bit contrived because we can't create fake memoryuses, so we use two loads in the if blocks
155 define i32 @test4(i32, ptr, ptr noalias, ptr noalias) {
156 ; CHECK-LABEL: @test4(
157 ; CHECK-NEXT: store i32 5, ptr [[TMP2:%.*]], align 4
158 ; CHECK-NEXT: store i32 7, ptr [[TMP3:%.*]], align 4
159 ; CHECK-NEXT: [[TMP5:%.*]] = icmp ne i32 [[TMP0:%.*]], 0
160 ; CHECK-NEXT: br i1 [[TMP5]], label [[TMP6:%.*]], label [[TMP7:%.*]]
161 ; CHECK: br label [[TMP8:%.*]]
162 ; CHECK: br label [[TMP8]]
163 ; CHECK: [[DOT01:%.*]] = phi i32 [ 5, [[TMP6]] ], [ 7, [[TMP7]] ]
164 ; CHECK-NEXT: [[DOT0:%.*]] = phi ptr [ [[TMP2]], [[TMP6]] ], [ [[TMP3]], [[TMP7]] ]
165 ; CHECK-NEXT: [[TMP9:%.*]] = load i32, ptr [[DOT0]], align 4
166 ; CHECK-NEXT: [[TMP10:%.*]] = mul nsw i32 [[TMP9]], 15
167 ; CHECK-NEXT: [[TMP11:%.*]] = mul nsw i32 [[TMP10]], [[DOT01]]
168 ; CHECK-NEXT: ret i32 [[TMP11]]
170 store i32 5, ptr %2, align 4
171 store i32 7, ptr %3, align 4
172 %5 = icmp ne i32 %0, 0
173 br i1 %5, label %6, label %8
175 ; <label>:6: ; preds = %4
176 %7 = load i32, ptr %2, align 4
179 ; <label>:8: ; preds = %4
180 %9 = load i32, ptr %3, align 4
183 ; <label>:10: ; preds = %8, %6
184 %.01 = phi i32 [ %7, %6 ], [ %9, %8 ]
185 %.0 = phi ptr [ %2, %6 ], [ %3, %8 ]
186 %11 = load i32, ptr %.0, align 4
187 %12 = mul nsw i32 %11, 15
188 %13 = mul nsw i32 %12, %.01
192 @global = common global [100 x i64] zeroinitializer, align 16
193 @global.1 = common global [100 x i64] zeroinitializer, align 16
194 define i64 @test5(i64 %arg) {
195 ; CHECK-LABEL: @test5(
197 ; CHECK-NEXT: [[TMP:%.*]] = alloca i64, align 8
198 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[ARG:%.*]], 0
199 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB28:%.*]], label [[BB2:%.*]]
201 ; CHECK-NEXT: br label [[BB7:%.*]]
203 ; CHECK-NEXT: br label [[BB5:%.*]]
205 ; CHECK-NEXT: [[TMP6:%.*]] = icmp eq i64 [[TMP9:%.*]], 0
206 ; CHECK-NEXT: br i1 [[TMP6]], label [[BB27:%.*]], label [[BB7]]
208 ; CHECK-NEXT: [[TMP8:%.*]] = phi i64 [ [[ARG]], [[BB2]] ], [ [[TMP9]], [[BB5]] ]
209 ; CHECK-NEXT: [[TMP9]] = add nsw i64 [[TMP8]], -1
210 ; CHECK-NEXT: [[TMP10:%.*]] = load i64, ptr @global, align 16
211 ; CHECK-NEXT: [[TMP11:%.*]] = load i64, ptr @global.1, align 16
212 ; CHECK-NEXT: [[TMP12:%.*]] = mul nsw i64 [[TMP11]], [[TMP10]]
213 ; CHECK-NEXT: [[TMP13:%.*]] = icmp eq i64 [[TMP12]], 0
214 ; CHECK-NEXT: br i1 [[TMP13]], label [[BB5]], label [[BB14:%.*]]
216 ; CHECK-NEXT: br label [[BB15:%.*]]
218 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i64 [ [[TMP12]], [[BB14]] ], [ [[TMP25:%.*]], [[BB15]] ]
219 ; CHECK-NEXT: [[TMP16:%.*]] = phi i64 [ [[TMP24:%.*]], [[BB15]] ], [ [[TMP11]], [[BB14]] ]
220 ; CHECK-NEXT: [[TMP17:%.*]] = phi i64 [ [[TMP22:%.*]], [[BB15]] ], [ [[TMP10]], [[BB14]] ]
221 ; CHECK-NEXT: [[TMP18:%.*]] = phi i64 [ [[TMP20:%.*]], [[BB15]] ], [ 0, [[BB14]] ]
222 ; CHECK-NEXT: store i64 [[PHIOFOPS]], ptr [[TMP]], align 8
223 ; CHECK-NEXT: [[TMP20]] = add nuw nsw i64 [[TMP18]], 1
224 ; CHECK-NEXT: [[TMP21:%.*]] = getelementptr inbounds [100 x i64], ptr @global, i64 0, i64 [[TMP20]]
225 ; CHECK-NEXT: [[TMP22]] = load i64, ptr [[TMP21]], align 8
226 ; CHECK-NEXT: [[TMP23:%.*]] = getelementptr inbounds [100 x i64], ptr @global.1, i64 0, i64 [[TMP20]]
227 ; CHECK-NEXT: [[TMP24]] = load i64, ptr [[TMP23]], align 8
228 ; CHECK-NEXT: [[TMP25]] = mul nsw i64 [[TMP24]], [[TMP22]]
229 ; CHECK-NEXT: [[TMP26:%.*]] = icmp eq i64 [[TMP20]], [[TMP25]]
230 ; CHECK-NEXT: br i1 [[TMP26]], label [[BB4:%.*]], label [[BB15]]
232 ; CHECK-NEXT: br label [[BB28]]
234 ; CHECK-NEXT: ret i64 0
237 %tmp = alloca i64, align 8
238 %tmp1 = icmp eq i64 %arg, 0
239 br i1 %tmp1, label %bb28, label %bb2
247 bb5: ; preds = %bb7, %bb4
248 %tmp6 = icmp eq i64 %tmp9, 0
249 br i1 %tmp6, label %bb27, label %bb7
251 bb7: ; preds = %bb5, %bb2
252 %tmp8 = phi i64 [ %arg, %bb2 ], [ %tmp9, %bb5 ]
253 %tmp9 = add nsw i64 %tmp8, -1
254 %tmp10 = load i64, ptr @global, align 16
255 %tmp11 = load i64, ptr @global.1, align 16
256 %tmp12 = mul nsw i64 %tmp11, %tmp10
257 %tmp13 = icmp eq i64 %tmp12, 0
258 br i1 %tmp13, label %bb5, label %bb14
263 bb15: ; preds = %bb15, %bb14
264 %tmp16 = phi i64 [ %tmp24, %bb15 ], [ %tmp11, %bb14 ]
265 %tmp17 = phi i64 [ %tmp22, %bb15 ], [ %tmp10, %bb14 ]
266 %tmp18 = phi i64 [ %tmp20, %bb15 ], [ 0, %bb14 ]
267 ;; This multiply is an op of phis which is really equivalent to phi(tmp25, tmp12)
268 %tmp19 = mul nsw i64 %tmp16, %tmp17
269 store i64 %tmp19, ptr %tmp, align 8
270 %tmp20 = add nuw nsw i64 %tmp18, 1
271 %tmp21 = getelementptr inbounds [100 x i64], ptr @global, i64 0, i64 %tmp20
272 %tmp22 = load i64, ptr %tmp21, align 8
273 %tmp23 = getelementptr inbounds [100 x i64], ptr @global.1, i64 0, i64 %tmp20
274 %tmp24 = load i64, ptr %tmp23, align 8
275 %tmp25 = mul nsw i64 %tmp24, %tmp22
276 %tmp26 = icmp eq i64 %tmp20, %tmp25
277 br i1 %tmp26, label %bb4, label %bb15
282 bb28: ; preds = %bb27, %bb
286 ;; These icmps are all equivalent to phis of constants
287 define i8 @test6(ptr %addr) {
288 ; CHECK-LABEL: @test6(
289 ; CHECK-NEXT: entry-block:
290 ; CHECK-NEXT: br label %main-loop
292 ; CHECK-NEXT: [[PHIOFOPS1:%.*]] = phi i1 [ true, %entry-block ], [ false, [[CORE:%.*]] ]
293 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i1 [ false, %entry-block ], [ true, [[CORE]] ]
294 ; CHECK-NEXT: [[PHI:%.*]] = phi i8 [ 0, %entry-block ], [ 1, [[CORE]] ]
295 ; CHECK-NEXT: store volatile i8 0, ptr [[ADDR:%.*]]
296 ; CHECK-NEXT: br i1 [[PHIOFOPS1]], label %busy-wait-phi-0, label [[EXIT:%.*]]
297 ; CHECK: busy-wait-phi-0:
298 ; CHECK-NEXT: [[LOAD:%.*]] = load volatile i8, ptr [[ADDR]]
299 ; CHECK-NEXT: [[ICMP:%.*]] = icmp eq i8 [[LOAD]], 0
300 ; CHECK-NEXT: br i1 [[ICMP]], label %busy-wait-phi-0, label [[CORE]]
302 ; CHECK-NEXT: br i1 [[PHIOFOPS]], label [[TRAP:%.*]], label %main-loop
304 ; CHECK-NEXT: ret i8 1
306 ; CHECK-NEXT: ret i8 0
312 %phi = phi i8 [ 0, %entry-block ], [ 1, %core ]
313 %switch_0 = icmp eq i8 %phi, 0
314 store volatile i8 0, ptr %addr
315 br i1 %switch_0, label %busy-wait-phi-0, label %exit
318 %load = load volatile i8, ptr %addr
319 %icmp = icmp eq i8 %load, 0
320 br i1 %icmp, label %busy-wait-phi-0, label %core
323 %switch_1 = icmp eq i8 %phi, 1
324 br i1 %switch_1, label %trap, label %main-loop
333 ; Test that we don't infinite loop simplifying
334 ; an undefined value that can go both ways.
335 define void @test7() {
336 ; CHECK-LABEL: @test7(
338 ; CHECK-NEXT: br label [[BB1:%.*]]
340 ; CHECK-NEXT: br label [[BB1]]
345 bb1: ; preds = %bb1, %bb
346 %tmp = phi i32 [ undef, %bb ], [ %tmp3, %bb1 ]
347 %tmp2 = icmp eq i32 %tmp, 0
348 %tmp3 = select i1 %tmp2, i32 1, i32 %tmp
354 ; Test that we get a consistent answer about what the
355 ; value of this undefined select is.
356 define void @test8() {
357 ; CHECK-LABEL: @test8(
359 ; CHECK-NEXT: br label [[BB1:%.*]]
361 ; CHECK-NEXT: br label [[BB1]]
364 %tmp = select i1 undef, i8 0, i8 1
367 bb1: ; preds = %bb1, %bb
368 %tmp2 = phi i8 [ %tmp4, %bb1 ], [ %tmp, %bb ]
369 %tmp3 = icmp eq i8 %tmp2, 0
370 %tmp4 = select i1 %tmp3, i8 1, i8 %tmp2
375 ;; Make sure we handle the case where we later come up with an expression that we need
377 define void @test9() {
378 ; CHECK-LABEL: @test9(
380 ; CHECK-NEXT: br label [[BB1:%.*]]
382 ; CHECK-NEXT: br i1 undef, label [[BB1]], label [[BB2:%.*]]
384 ; CHECK-NEXT: br label [[BB6:%.*]]
386 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i32 [ -13, [[BB2]] ], [ [[TMP11:%.*]], [[BB6]] ]
387 ; CHECK-NEXT: [[TMP7:%.*]] = phi i32 [ 1, [[BB2]] ], [ [[TMP8:%.*]], [[BB6]] ]
388 ; CHECK-NEXT: [[TMP8]] = add nuw nsw i32 [[TMP7]], 1
389 ; CHECK-NEXT: [[TMP11]] = add i32 -14, [[TMP8]]
390 ; CHECK-NEXT: br label [[BB6]]
395 bb1: ; preds = %bb1, %bb
396 br i1 undef, label %bb1, label %bb2
399 %tmp = select i1 true, i32 -14, i32 -10
400 %tmp3 = add i32 %tmp, 0
401 %tmp4 = select i1 true, i32 -14, i32 -10
402 %tmp5 = add i32 %tmp4, 0
405 bb6: ; preds = %bb6, %bb2
406 %tmp7 = phi i32 [ 1, %bb2 ], [ %tmp13, %bb6 ]
407 %tmp8 = add nuw nsw i32 %tmp7, 1
408 %tmp9 = add i32 %tmp3, %tmp7
409 %tmp10 = select i1 false, i32 undef, i32 %tmp9
410 %tmp11 = add i32 %tmp5, %tmp8
411 %tmp12 = select i1 undef, i32 undef, i32 %tmp11
412 %tmp13 = add nuw nsw i32 %tmp7, 1
416 ;; Ensure that we revisit predicateinfo operands at the right points in time.
417 define void @test10() {
418 ; CHECK-LABEL: @test10(
420 ; CHECK-NEXT: br label [[G:%.*]]
422 ; CHECK-NEXT: [[N:%.*]] = phi ptr [ [[H:%.*]], [[I:%.*]] ], [ null, [[B:%.*]] ]
423 ; CHECK-NEXT: [[H]] = getelementptr i32, ptr [[N]], i64 1
424 ; CHECK-NEXT: [[J:%.*]] = icmp eq ptr [[H]], inttoptr (i64 32 to ptr)
425 ; CHECK-NEXT: br i1 [[J]], label [[C:%.*]], label [[I]]
427 ; CHECK-NEXT: br i1 undef, label [[K:%.*]], label [[G]]
429 ; CHECK-NEXT: br i1 false, label [[C]], label [[O:%.*]]
431 ; CHECK-NEXT: br label [[C]]
433 ; CHECK-NEXT: ret void
436 %m = getelementptr i32, ptr null, i64 8
440 %n = phi ptr [ %h, %i ], [ null, %b ]
441 %h = getelementptr i32, ptr %n, i64 1
442 %j = icmp eq ptr %h, %m
443 br i1 %j, label %c, label %i
446 br i1 undef, label %k, label %g
449 %l = icmp eq ptr %n, %m
450 br i1 %l, label %c, label %o
455 c: ; preds = %o, %k, %g
456 %0 = phi ptr [ undef, %o ], [ %m, %k ], [ %m, %g ]
460 ;; Ensure we handle VariableExpression properly.
461 define void @test11() {
462 ; CHECK-LABEL: @test11(
464 ; CHECK-NEXT: br i1 undef, label [[BB1:%.*]], label [[BB2:%.*]]
466 ; CHECK-NEXT: br label [[BB2]]
468 ; CHECK-NEXT: [[TMP:%.*]] = phi i1 [ false, [[BB1]] ], [ true, [[BB:%.*]] ]
469 ; CHECK-NEXT: [[TMP3:%.*]] = call ptr @wombat()
470 ; CHECK-NEXT: [[TMP4:%.*]] = icmp ne ptr [[TMP3]], null
471 ; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP]], [[TMP4]]
472 ; CHECK-NEXT: br i1 [[TMP5]], label [[BB6:%.*]], label [[BB7:%.*]]
474 ; CHECK-NEXT: unreachable
476 ; CHECK-NEXT: ret void
479 br i1 undef, label %bb1, label %bb2
484 bb2: ; preds = %bb1, %bb
485 %tmp = phi i1 [ false, %bb1 ], [ true, %bb ]
486 %tmp3 = call ptr @wombat()
487 %tmp4 = icmp ne ptr %tmp3, null
488 %tmp5 = and i1 %tmp, %tmp4
489 br i1 %tmp5, label %bb6, label %bb7
498 declare ptr @wombat()
500 ;; Ensure that when reachability affects a phi of ops, we recompute
501 ;; it. Here, the phi node is marked for recomputation when bb7->bb3
502 ;; becomes live, but the value does not change. if we do not directly
503 ;; recompute the phi of ops instruction (tmp5), the value number will
504 ;; change in the verifier, as it goes from a constant value to a
505 ;; phi of [true, false]
507 define void @test12(ptr %p) {
508 ; CHECK-LABEL: @test12(
510 ; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr %p
511 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 [[TMP]], 0
512 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB2:%.*]], label [[BB8:%.*]]
514 ; CHECK-NEXT: br label [[BB3:%.*]]
516 ; CHECK-NEXT: br i1 true, label [[BB6:%.*]], label [[BB7]]
518 ; CHECK-NEXT: br label [[BB7]]
520 ; CHECK-NEXT: br label [[BB3]]
522 ; CHECK-NEXT: ret void
525 %tmp = load i32, ptr %p
526 %tmp1 = icmp sgt i32 %tmp, 0
527 br i1 %tmp1, label %bb2, label %bb8
532 bb3: ; preds = %bb7, %bb2
533 %tmp4 = phi i32 [ %tmp, %bb2 ], [ poison, %bb7 ]
534 %tmp5 = icmp sgt i32 %tmp4, 0
535 br i1 %tmp5, label %bb6, label %bb7
540 bb7: ; preds = %bb6, %bb3
547 ;; Make sure we reprocess phi of ops involving loads when loads change class.
549 define void @test13() {
550 ; CHECK-LABEL: @test13(
552 ; CHECK-NEXT: br label [[BB1:%.*]]
554 ; CHECK-NEXT: [[TMP:%.*]] = load i8, ptr null
555 ; CHECK-NEXT: br label [[BB3:%.*]]
557 ; CHECK-NEXT: [[PHIOFOPS:%.*]] = phi i8 [ [[TMP]], [[BB1]] ], [ [[TMP10:%.*]], [[BB3]] ]
558 ; CHECK-NEXT: [[TMP4:%.*]] = phi ptr [ null, [[BB1]] ], [ [[TMP6:%.*]], [[BB3]] ]
559 ; CHECK-NEXT: [[TMP5:%.*]] = phi i32 [ undef, [[BB1]] ], [ [[TMP9:%.*]], [[BB3]] ]
560 ; CHECK-NEXT: [[TMP6]] = getelementptr i8, ptr [[TMP4]], i64 1
561 ; CHECK-NEXT: [[TMP8:%.*]] = sext i8 [[PHIOFOPS]] to i32
562 ; CHECK-NEXT: [[TMP9]] = mul i32 [[TMP5]], [[TMP8]]
563 ; CHECK-NEXT: [[TMP10]] = load i8, ptr [[TMP6]]
564 ; CHECK-NEXT: [[TMP11:%.*]] = icmp eq i8 [[TMP10]], 0
565 ; CHECK-NEXT: br i1 [[TMP11]], label [[BB12:%.*]], label [[BB3]]
567 ; CHECK-NEXT: [[TMP14:%.*]] = icmp eq i32 [[TMP9]], 0
568 ; CHECK-NEXT: br i1 [[TMP14]], label [[BB1]], label [[BB15:%.*]]
570 ; CHECK-NEXT: call void (...) @bar()
571 ; CHECK-NEXT: br label [[BB1]]
576 bb1: ; preds = %bb15, %bb12, %bb
577 %tmp = load i8, ptr null
578 %tmp2 = icmp eq i8 %tmp, 8
581 bb3: ; preds = %bb3, %bb1
582 %tmp4 = phi ptr [ null, %bb1 ], [ %tmp6, %bb3 ]
583 %tmp5 = phi i32 [ undef, %bb1 ], [ %tmp9, %bb3 ]
584 %tmp6 = getelementptr i8, ptr %tmp4, i64 1
585 %tmp7 = load i8, ptr %tmp4
586 %tmp8 = sext i8 %tmp7 to i32
587 %tmp9 = mul i32 %tmp5, %tmp8
588 %tmp10 = load i8, ptr %tmp6
589 %tmp11 = icmp eq i8 %tmp10, 0
590 br i1 %tmp11, label %bb12, label %bb3
593 %tmp13 = phi i32 [ %tmp9, %bb3 ]
594 %tmp14 = icmp eq i32 %tmp13, 0
595 br i1 %tmp14, label %bb1, label %bb15
597 bb15: ; preds = %bb12
598 call void (...) @bar()
602 declare void @bar(...)