1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=jump-threading -S | FileCheck %s
3 ; RUN: opt < %s -aa-pipeline=basic-aa -passes=jump-threading -S | FileCheck %s
5 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
6 target triple = "i386-apple-darwin7"
8 ; Test that we can thread through the block with the partially redundant load (%2).
10 define i32 @test1(ptr %P) nounwind {
11 ; CHECK-LABEL: @test1(
13 ; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 (...) @f1() #[[ATTR0:[0-9]+]]
14 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP0]], 0
15 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB1:%.*]], label [[BB1_THREAD:%.*]]
17 ; CHECK-NEXT: store i32 42, ptr [[P:%.*]], align 4
18 ; CHECK-NEXT: br label [[BB3:%.*]]
20 ; CHECK-NEXT: [[DOTPR:%.*]] = load i32, ptr [[P]], align 4
21 ; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[DOTPR]], 36
22 ; CHECK-NEXT: br i1 [[TMP2]], label [[BB3]], label [[BB2:%.*]]
24 ; CHECK-NEXT: [[TMP3:%.*]] = tail call i32 (...) @f2() #[[ATTR0]]
25 ; CHECK-NEXT: ret i32 0
27 ; CHECK-NEXT: [[RES_02:%.*]] = phi i32 [ 1, [[BB1_THREAD]] ], [ 0, [[BB1]] ]
28 ; CHECK-NEXT: ret i32 [[RES_02]]
31 %0 = tail call i32 (...) @f1() nounwind ; <i32> [#uses=1]
32 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
33 br i1 %1, label %bb1, label %bb
36 store i32 42, ptr %P, align 4
39 bb1: ; preds = %entry, %bb
40 %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ] ; <i32> [#uses=2]
41 %2 = load i32, ptr %P, align 4 ; <i32> [#uses=1]
42 %3 = icmp sgt i32 %2, 36 ; <i1> [#uses=1]
43 br i1 %3, label %bb3, label %bb2
46 %4 = tail call i32 (...) @f2() nounwind ; <i32> [#uses=0]
58 ;; Check that we preserve TBAA information.
61 define i32 @test2(ptr %P) nounwind {
62 ; CHECK-LABEL: @test2(
64 ; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 (...) @f1() #[[ATTR0]]
65 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[TMP0]], 0
66 ; CHECK-NEXT: br i1 [[TMP1]], label [[BB1:%.*]], label [[BB1_THREAD:%.*]]
68 ; CHECK-NEXT: store i32 42, ptr [[P:%.*]], align 4, !tbaa [[TBAA0:![0-9]+]]
69 ; CHECK-NEXT: br label [[BB3:%.*]]
71 ; CHECK-NEXT: [[DOTPR:%.*]] = load i32, ptr [[P]], align 4, !tbaa [[TBAA0]]
72 ; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[DOTPR]], 36
73 ; CHECK-NEXT: br i1 [[TMP2]], label [[BB3]], label [[BB2:%.*]]
75 ; CHECK-NEXT: [[TMP3:%.*]] = tail call i32 (...) @f2() #[[ATTR0]]
76 ; CHECK-NEXT: ret i32 0
78 ; CHECK-NEXT: [[RES_02:%.*]] = phi i32 [ 1, [[BB1_THREAD]] ], [ 0, [[BB1]] ]
79 ; CHECK-NEXT: ret i32 [[RES_02]]
82 %0 = tail call i32 (...) @f1() nounwind ; <i32> [#uses=1]
83 %1 = icmp eq i32 %0, 0 ; <i1> [#uses=1]
84 br i1 %1, label %bb1, label %bb
87 store i32 42, ptr %P, align 4, !tbaa !0
90 bb1: ; preds = %entry, %bb
91 %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
92 %2 = load i32, ptr %P, align 4, !tbaa !0
93 %3 = icmp sgt i32 %2, 36
94 br i1 %3, label %bb3, label %bb2
97 %4 = tail call i32 (...) @f2() nounwind
104 define i32 @test3(ptr %x, i1 %f) {
105 ; Correctly thread loads of different (but compatible) types, placing bitcasts
106 ; as necessary in the predecessors. This is especially tricky because the same
107 ; predecessor ends up with two entries in the PHI node and they must share
109 ; CHECK-LABEL: @test3(
111 ; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[X:%.*]], align 8
112 ; CHECK-NEXT: br i1 [[F:%.*]], label [[IF_END57:%.*]], label [[IF_END57]]
114 ; CHECK-NEXT: [[TMP3:%.*]] = phi ptr [ [[TMP1]], [[ENTRY:%.*]] ], [ [[TMP1]], [[ENTRY]] ]
115 ; CHECK-NEXT: [[TOBOOL59:%.*]] = icmp eq ptr [[TMP3]], null
116 ; CHECK-NEXT: br i1 [[TOBOOL59]], label [[RETURN:%.*]], label [[IF_THEN60:%.*]]
118 ; CHECK-NEXT: ret i32 42
120 ; CHECK-NEXT: ret i32 13
123 %0 = load ptr, ptr %x, align 8
124 br i1 %f, label %if.end57, label %if.then56
130 %1 = load ptr, ptr %x, align 8
131 %tobool59 = icmp eq ptr %1, null
132 br i1 %tobool59, label %return, label %if.then60
141 define i32 @test4(ptr %P) {
142 ; CHECK-LABEL: @test4(
144 ; CHECK-NEXT: [[V0:%.*]] = tail call i32 (...) @f1()
145 ; CHECK-NEXT: [[V1:%.*]] = icmp eq i32 [[V0]], 0
146 ; CHECK-NEXT: br i1 [[V1]], label [[BB1:%.*]], label [[BB1_THREAD:%.*]]
148 ; CHECK-NEXT: store atomic i32 42, ptr [[P:%.*]] unordered, align 4
149 ; CHECK-NEXT: br label [[BB3:%.*]]
151 ; CHECK-NEXT: [[V2_PR:%.*]] = load atomic i32, ptr [[P]] unordered, align 4
152 ; CHECK-NEXT: [[V3:%.*]] = icmp sgt i32 [[V2_PR]], 36
153 ; CHECK-NEXT: br i1 [[V3]], label [[BB3]], label [[BB2:%.*]]
155 ; CHECK-NEXT: [[V4:%.*]] = tail call i32 (...) @f2()
156 ; CHECK-NEXT: ret i32 0
158 ; CHECK-NEXT: [[RES_04:%.*]] = phi i32 [ 1, [[BB1_THREAD]] ], [ 0, [[BB1]] ]
159 ; CHECK-NEXT: ret i32 [[RES_04]]
162 %v0 = tail call i32 (...) @f1()
163 %v1 = icmp eq i32 %v0, 0
164 br i1 %v1, label %bb1, label %bb
167 store atomic i32 42, ptr %P unordered, align 4
171 %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
172 %v2 = load atomic i32, ptr %P unordered, align 4
173 %v3 = icmp sgt i32 %v2, 36
174 br i1 %v3, label %bb3, label %bb2
177 %v4 = tail call i32 (...) @f2()
184 define i32 @test5(ptr %P) {
186 ; CHECK-LABEL: @test5(
188 ; CHECK-NEXT: [[V0:%.*]] = tail call i32 (...) @f1()
189 ; CHECK-NEXT: [[V1:%.*]] = icmp eq i32 [[V0]], 0
190 ; CHECK-NEXT: br i1 [[V1]], label [[BB1:%.*]], label [[BB:%.*]]
192 ; CHECK-NEXT: store atomic i32 42, ptr [[P:%.*]] release, align 4
193 ; CHECK-NEXT: br label [[BB1]]
195 ; CHECK-NEXT: [[RES_0:%.*]] = phi i32 [ 1, [[BB]] ], [ 0, [[ENTRY:%.*]] ]
196 ; CHECK-NEXT: [[V2:%.*]] = load atomic i32, ptr [[P]] acquire, align 4
197 ; CHECK-NEXT: [[V3:%.*]] = icmp sgt i32 [[V2]], 36
198 ; CHECK-NEXT: br i1 [[V3]], label [[BB3:%.*]], label [[BB2:%.*]]
200 ; CHECK-NEXT: [[V4:%.*]] = tail call i32 (...) @f2()
201 ; CHECK-NEXT: ret i32 [[RES_0]]
203 ; CHECK-NEXT: ret i32 [[RES_0]]
206 %v0 = tail call i32 (...) @f1()
207 %v1 = icmp eq i32 %v0, 0
208 br i1 %v1, label %bb1, label %bb
211 store atomic i32 42, ptr %P release, align 4
216 %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
217 %v2 = load atomic i32, ptr %P acquire, align 4
218 %v3 = icmp sgt i32 %v2, 36
219 br i1 %v3, label %bb3, label %bb2
222 %v4 = tail call i32 (...) @f2()
229 define i32 @test6(ptr %P) {
231 ; CHECK-LABEL: @test6(
233 ; CHECK-NEXT: [[V0:%.*]] = tail call i32 (...) @f1()
234 ; CHECK-NEXT: [[V1:%.*]] = icmp eq i32 [[V0]], 0
235 ; CHECK-NEXT: br i1 [[V1]], label [[BB1:%.*]], label [[BB:%.*]]
237 ; CHECK-NEXT: store i32 42, ptr [[P:%.*]], align 4
238 ; CHECK-NEXT: br label [[BB1]]
240 ; CHECK-NEXT: [[RES_0:%.*]] = phi i32 [ 1, [[BB]] ], [ 0, [[ENTRY:%.*]] ]
241 ; CHECK-NEXT: [[V2:%.*]] = load atomic i32, ptr [[P]] acquire, align 4
242 ; CHECK-NEXT: [[V3:%.*]] = icmp sgt i32 [[V2]], 36
243 ; CHECK-NEXT: br i1 [[V3]], label [[BB3:%.*]], label [[BB2:%.*]]
245 ; CHECK-NEXT: [[V4:%.*]] = tail call i32 (...) @f2()
246 ; CHECK-NEXT: ret i32 [[RES_0]]
248 ; CHECK-NEXT: ret i32 [[RES_0]]
251 %v0 = tail call i32 (...) @f1()
252 %v1 = icmp eq i32 %v0, 0
253 br i1 %v1, label %bb1, label %bb
261 %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
262 %v2 = load atomic i32, ptr %P acquire, align 4
263 %v3 = icmp sgt i32 %v2, 36
264 br i1 %v3, label %bb3, label %bb2
267 %v4 = tail call i32 (...) @f2()
274 define i32 @test7(ptr %P) {
276 ; CHECK-LABEL: @test7(
278 ; CHECK-NEXT: [[V0:%.*]] = tail call i32 (...) @f1()
279 ; CHECK-NEXT: [[V1:%.*]] = icmp eq i32 [[V0]], 0
280 ; CHECK-NEXT: br i1 [[V1]], label [[BB1:%.*]], label [[BB:%.*]]
282 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[P:%.*]], align 4
283 ; CHECK-NEXT: br label [[BB1]]
285 ; CHECK-NEXT: [[RES_0:%.*]] = phi i32 [ 1, [[BB]] ], [ 0, [[ENTRY:%.*]] ]
286 ; CHECK-NEXT: [[V2:%.*]] = load atomic i32, ptr [[P]] acquire, align 4
287 ; CHECK-NEXT: [[V3:%.*]] = icmp sgt i32 [[V2]], 36
288 ; CHECK-NEXT: br i1 [[V3]], label [[BB3:%.*]], label [[BB2:%.*]]
290 ; CHECK-NEXT: [[V4:%.*]] = tail call i32 (...) @f2()
291 ; CHECK-NEXT: ret i32 [[RES_0]]
293 ; CHECK-NEXT: ret i32 [[RES_0]]
296 %v0 = tail call i32 (...) @f1()
297 %v1 = icmp eq i32 %v0, 0
298 br i1 %v1, label %bb1, label %bb
301 %val = load i32, ptr %P
306 %res.0 = phi i32 [ 1, %bb ], [ 0, %entry ]
307 %v2 = load atomic i32, ptr %P acquire, align 4
308 %v3 = icmp sgt i32 %v2, 36
309 br i1 %v3, label %bb3, label %bb2
312 %v4 = tail call i32 (...) @f2()
319 ; Make sure we merge the aliasing metadata. We keep the range metadata for the
320 ; first load, as it dominates the second load. Hence we can eliminate the
322 define void @test8(ptr, ptr, ptr) {
323 ; CHECK-LABEL: @test8(
325 ; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[TMP0:%.*]], align 4, !range [[RNG4:![0-9]+]], !noundef !5
326 ; CHECK-NEXT: store i32 [[A]], ptr [[TMP1:%.*]], align 4
327 ; CHECK-NEXT: [[XXX:%.*]] = tail call i32 (...) @f1() #[[ATTR0]]
328 ; CHECK-NEXT: ret void
330 %a = load i32, ptr %0, !tbaa !0, !range !4, !alias.scope !9, !noalias !10, !noundef !11
331 %b = load i32, ptr %0, !range !5
333 %c = icmp eq i32 %b, 8
334 br i1 %c, label %ret1, label %ret2
340 %xxx = tail call i32 (...) @f1() nounwind
344 ; Make sure we merge/PRE aliasing metadata correctly. That means that
345 ; we need to remove metadata from the existing load, and add appropriate
346 ; metadata to the newly inserted load.
347 define void @test9(ptr, ptr, ptr, i1 %c) {
348 ; CHECK-LABEL: @test9(
349 ; CHECK-NEXT: br i1 [[C:%.*]], label [[D1:%.*]], label [[D2:%.*]]
351 ; CHECK-NEXT: [[A:%.*]] = load i32, ptr [[TMP0:%.*]], align 4
352 ; CHECK-NEXT: br label [[D3:%.*]]
354 ; CHECK-NEXT: [[XXXX:%.*]] = tail call i32 (...) @f1() #[[ATTR0]]
355 ; CHECK-NEXT: [[B_PR:%.*]] = load i32, ptr [[TMP0]], align 4, !tbaa [[TBAA0]]
356 ; CHECK-NEXT: br label [[D3]]
358 ; CHECK-NEXT: [[B:%.*]] = phi i32 [ [[B_PR]], [[D2]] ], [ [[A]], [[D1]] ]
359 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 1, [[D2]] ], [ [[A]], [[D1]] ]
360 ; CHECK-NEXT: store i32 [[P]], ptr [[TMP1:%.*]], align 4
361 ; CHECK-NEXT: [[C2:%.*]] = icmp eq i32 [[B]], 8
362 ; CHECK-NEXT: br i1 [[C2]], label [[RET1:%.*]], label [[RET2:%.*]]
364 ; CHECK-NEXT: ret void
366 ; CHECK-NEXT: [[XXX:%.*]] = tail call i32 (...) @f1() #[[ATTR0]]
367 ; CHECK-NEXT: ret void
369 br i1 %c, label %d1, label %d2
372 %a = load i32, ptr %0, !range !4, !alias.scope !9, !noalias !10
376 %xxxx = tail call i32 (...) @f1() nounwind
380 %p = phi i32 [ 1, %d2 ], [ %a, %d1 ]
381 %b = load i32, ptr %0, !tbaa !0
383 %c2 = icmp eq i32 %b, 8
384 br i1 %c2, label %ret1, label %ret2
390 %xxx = tail call i32 (...) @f1() nounwind
394 define i32 @fn_noalias(i1 %c2,ptr noalias %P, ptr noalias %P2) {
395 ; CHECK-LABEL: @fn_noalias(
397 ; CHECK-NEXT: br i1 [[C2:%.*]], label [[COND2:%.*]], label [[COND1:%.*]]
399 ; CHECK-NEXT: [[L1:%.*]] = load i64, ptr [[P:%.*]], align 4
400 ; CHECK-NEXT: store i64 42, ptr [[P2:%.*]], align 4
401 ; CHECK-NEXT: [[C:%.*]] = icmp eq i64 [[L1]], 0
402 ; CHECK-NEXT: br i1 [[C]], label [[COND2_THREAD:%.*]], label [[END:%.*]]
403 ; CHECK: cond2.thread:
404 ; CHECK-NEXT: call void @fn2(i64 [[L1]])
405 ; CHECK-NEXT: br label [[COND3:%.*]]
407 ; CHECK-NEXT: [[L2_PR:%.*]] = load i64, ptr [[P]], align 4
408 ; CHECK-NEXT: call void @fn2(i64 [[L2_PR]])
409 ; CHECK-NEXT: [[C3:%.*]] = icmp eq i64 [[L2_PR]], 0
410 ; CHECK-NEXT: br i1 [[C3]], label [[COND3]], label [[END]]
412 ; CHECK-NEXT: [[L23:%.*]] = phi i64 [ [[L1]], [[COND2_THREAD]] ], [ [[L2_PR]], [[COND2]] ]
413 ; CHECK-NEXT: call void @fn3(i64 [[L23]])
414 ; CHECK-NEXT: br label [[END]]
416 ; CHECK-NEXT: ret i32 0
419 br i1 %c2, label %cond2, label %cond1
422 %l1 = load i64, ptr %P
423 store i64 42, ptr %P2
424 %c = icmp eq i64 %l1, 0
425 br i1 %c, label %cond2, label %end
428 %l2 = load i64, ptr %P
429 call void @fn2(i64 %l2)
430 %c3 = icmp eq i64 %l2, 0
431 br i1 %c3, label %cond3, label %end
434 call void @fn3(i64 %l2)
441 ; This tests if we can thread from %sw.bb.i to %do.body.preheader.i67 through
442 ; %sw.bb21.i. To make this happen, %l2 should be detected as a partically
443 ; redundant load with %l3 across the store to %phase in %sw.bb21.i.
445 %struct.NEXT_MOVE = type { i32, i32, ptr }
446 @hash_move = unnamed_addr global [65 x i32] zeroinitializer, align 4
447 @current_move = internal global [65 x i32] zeroinitializer, align 4
448 @last = internal unnamed_addr global [65 x ptr] zeroinitializer, align 8
449 @next_status = internal unnamed_addr global [65 x %struct.NEXT_MOVE] zeroinitializer, align 8
450 define fastcc i32 @Search(i64 %idxprom.i, i64 %idxprom.i89, i32 %c) {
451 ; CHECK-LABEL: @Search(
452 ; CHECK-NEXT: cond.true282:
453 ; CHECK-NEXT: [[ARRAYIDX185:%.*]] = getelementptr inbounds [65 x i32], ptr @hash_move, i64 0, i64 [[IDXPROM_I:%.*]]
454 ; CHECK-NEXT: [[ARRAYIDX307:%.*]] = getelementptr inbounds [65 x i32], ptr @current_move, i64 0, i64 [[IDXPROM_I]]
455 ; CHECK-NEXT: [[ARRAYIDX89:%.*]] = getelementptr inbounds [65 x ptr], ptr @last, i64 0, i64 [[IDXPROM_I]]
456 ; CHECK-NEXT: [[PHASE:%.*]] = getelementptr inbounds [65 x %struct.NEXT_MOVE], ptr @next_status, i64 0, i64 [[IDXPROM_I]], i32 0
457 ; CHECK-NEXT: switch i32 [[C:%.*]], label [[CLEANUP:%.*]] [
458 ; CHECK-NEXT: i32 1, label [[SW_BB_I:%.*]]
459 ; CHECK-NEXT: i32 0, label [[SW_BB21_I:%.*]]
462 ; CHECK-NEXT: [[CALL_I62:%.*]] = call fastcc ptr @GenerateCheckEvasions()
463 ; CHECK-NEXT: store ptr [[CALL_I62]], ptr [[ARRAYIDX89]], align 8
464 ; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[ARRAYIDX185]], align 4
465 ; CHECK-NEXT: [[TOBOOL_I63:%.*]] = icmp eq i32 [[L2]], 0
466 ; CHECK-NEXT: br i1 [[TOBOOL_I63]], label [[SW_BB21_I_THREAD:%.*]], label [[IF_THEN_I64:%.*]]
467 ; CHECK: sw.bb21.i.thread:
468 ; CHECK-NEXT: store i32 10, ptr [[PHASE]], align 8
469 ; CHECK-NEXT: br label [[DO_BODY_PREHEADER_I67:%.*]]
470 ; CHECK: if.then.i64:
471 ; CHECK-NEXT: store i32 7, ptr [[PHASE]], align 8
472 ; CHECK-NEXT: store i32 [[L2]], ptr [[ARRAYIDX307]], align 4
473 ; CHECK-NEXT: [[CALL16_I:%.*]] = call fastcc i32 @ValidMove(i32 [[L2]])
474 ; CHECK-NEXT: [[TOBOOL17_I:%.*]] = icmp eq i32 [[CALL16_I]], 0
475 ; CHECK-NEXT: br i1 [[TOBOOL17_I]], label [[IF_ELSE_I65:%.*]], label [[CLEANUP]]
476 ; CHECK: if.else.i65:
477 ; CHECK-NEXT: call void @f65()
478 ; CHECK-NEXT: br label [[SW_BB21_I]]
480 ; CHECK-NEXT: [[L3_PR:%.*]] = load i32, ptr [[ARRAYIDX185]], align 4
481 ; CHECK-NEXT: store i32 10, ptr [[PHASE]], align 8
482 ; CHECK-NEXT: [[TOBOOL27_I:%.*]] = icmp eq i32 [[L3_PR]], 0
483 ; CHECK-NEXT: br i1 [[TOBOOL27_I]], label [[DO_BODY_PREHEADER_I67]], label [[CLEANUP]]
484 ; CHECK: do.body.preheader.i67:
485 ; CHECK-NEXT: call void @f67()
486 ; CHECK-NEXT: ret i32 67
488 ; CHECK-NEXT: call void @Cleanup()
489 ; CHECK-NEXT: ret i32 0
492 %arrayidx185 = getelementptr inbounds [65 x i32], ptr @hash_move, i64 0, i64 %idxprom.i
493 %arrayidx307 = getelementptr inbounds [65 x i32], ptr @current_move, i64 0, i64 %idxprom.i
494 %arrayidx89 = getelementptr inbounds [65 x ptr], ptr @last, i64 0, i64 %idxprom.i
495 %phase = getelementptr inbounds [65 x %struct.NEXT_MOVE], ptr @next_status, i64 0, i64 %idxprom.i, i32 0
496 br label %cond.true282
499 switch i32 %c, label %sw.default.i [
500 i32 1, label %sw.bb.i
501 i32 0, label %sw.bb21.i
508 %call.i62 = call fastcc ptr @GenerateCheckEvasions()
509 store ptr %call.i62, ptr %arrayidx89, align 8
510 %l2 = load i32, ptr %arrayidx185, align 4
511 %tobool.i63 = icmp eq i32 %l2, 0
512 br i1 %tobool.i63, label %sw.bb21.i, label %if.then.i64
514 if.then.i64: ; preds = %sw.bb.i
515 store i32 7, ptr %phase, align 8
516 store i32 %l2, ptr %arrayidx307, align 4
517 %call16.i = call fastcc i32 @ValidMove(i32 %l2)
518 %tobool17.i = icmp eq i32 %call16.i, 0
519 br i1 %tobool17.i, label %if.else.i65, label %cleanup
526 store i32 10, ptr %phase, align 8
527 %l3= load i32, ptr %arrayidx185, align 4
528 %tobool27.i = icmp eq i32 %l3, 0
529 br i1 %tobool27.i, label %do.body.preheader.i67, label %cleanup
531 do.body.preheader.i67:
540 declare fastcc ptr @GenerateCheckEvasions()
541 declare fastcc i32 @ValidMove(i32 %move)
543 declare void @Cleanup()
546 define i32 @fn_SinglePred(i1 %c2,ptr %P) {
547 ; CHECK-LABEL: @fn_SinglePred(
549 ; CHECK-NEXT: [[L1:%.*]] = load i64, ptr [[P:%.*]], align 4
550 ; CHECK-NEXT: [[C:%.*]] = icmp eq i64 [[L1]], 0
551 ; CHECK-NEXT: br i1 [[C]], label [[COND3:%.*]], label [[COND1:%.*]]
553 ; CHECK-NEXT: br i1 [[C2:%.*]], label [[COND2:%.*]], label [[END:%.*]]
555 ; CHECK-NEXT: [[L2:%.*]] = phi i64 [ [[L1]], [[COND1]] ]
556 ; CHECK-NEXT: call void @fn2(i64 [[L2]])
557 ; CHECK-NEXT: br label [[END]]
559 ; CHECK-NEXT: call void @fn2(i64 [[L1]])
560 ; CHECK-NEXT: call void @fn3(i64 [[L1]])
561 ; CHECK-NEXT: br label [[END]]
563 ; CHECK-NEXT: ret i32 0
567 %l1 = load i64, ptr %P
568 %c = icmp eq i64 %l1, 0
569 br i1 %c, label %cond2, label %cond1
572 br i1 %c2, label %cond2, label %end
575 %l2 = load i64, ptr %P
576 call void @fn2(i64 %l2)
577 %c3 = icmp eq i64 %l2, 0
578 br i1 %c3, label %cond3, label %end
581 call void @fn3(i64 %l2)
588 define i32 @fn_SinglePredMultihop(i1 %c1, i1 %c2,ptr %P) {
589 ; CHECK-LABEL: @fn_SinglePredMultihop(
591 ; CHECK-NEXT: [[L1:%.*]] = load i64, ptr [[P:%.*]], align 4
592 ; CHECK-NEXT: [[C0:%.*]] = icmp eq i64 [[L1]], 0
593 ; CHECK-NEXT: br i1 [[C0]], label [[COND3:%.*]], label [[COND0:%.*]]
595 ; CHECK-NEXT: br i1 [[C1:%.*]], label [[COND1:%.*]], label [[END:%.*]]
597 ; CHECK-NEXT: br i1 [[C2:%.*]], label [[COND2:%.*]], label [[END]]
599 ; CHECK-NEXT: [[L2:%.*]] = phi i64 [ [[L1]], [[COND1]] ]
600 ; CHECK-NEXT: call void @fn2(i64 [[L2]])
601 ; CHECK-NEXT: br label [[END]]
603 ; CHECK-NEXT: call void @fn2(i64 [[L1]])
604 ; CHECK-NEXT: call void @fn3(i64 [[L1]])
605 ; CHECK-NEXT: br label [[END]]
607 ; CHECK-NEXT: ret i32 0
611 %l1 = load i64, ptr %P
612 %c0 = icmp eq i64 %l1, 0
613 br i1 %c0, label %cond2, label %cond0
616 br i1 %c1, label %cond1, label %end
619 br i1 %c2, label %cond2, label %end
622 %l2 = load i64, ptr %P
623 call void @fn2(i64 %l2)
624 %c3 = icmp eq i64 %l2, 0
625 br i1 %c3, label %cond3, label %end
628 call void @fn3(i64 %l2)
635 declare void @fn2(i64)
636 declare void @fn3(i64)
639 ; Make sure we phi-translate and make the partially redundant load in
640 ; merge fully redudant and then we can jump-thread the block with the
643 define i32 @phi_translate_partial_redundant_loads(i32, ptr, ptr) {
644 ; CHECK-LABEL: @phi_translate_partial_redundant_loads(
645 ; CHECK-NEXT: [[CMP0:%.*]] = icmp ne i32 [[TMP0:%.*]], 0
646 ; CHECK-NEXT: br i1 [[CMP0]], label [[MERGE_THREAD:%.*]], label [[MERGE:%.*]]
647 ; CHECK: merge.thread:
648 ; CHECK-NEXT: store i32 1, ptr [[TMP1:%.*]], align 4
649 ; CHECK-NEXT: br label [[LEFT_X:%.*]]
651 ; CHECK-NEXT: [[NEWLOAD_PR:%.*]] = load i32, ptr [[TMP2:%.*]], align 4
652 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i32 [[NEWLOAD_PR]], 5
653 ; CHECK-NEXT: br i1 [[CMP1]], label [[LEFT_X]], label [[RIGHT_X:%.*]]
655 ; CHECK-NEXT: ret i32 20
657 ; CHECK-NEXT: ret i32 10
659 %cmp0 = icmp ne i32 %0, 0
660 br i1 %cmp0, label %left, label %right
663 store i32 1, ptr %1, align 4
670 %phiptr = phi ptr [ %1, %left ], [ %2, %right ]
671 %newload = load i32, ptr %phiptr, align 4
672 %cmp1 = icmp slt i32 %newload, 5
673 br i1 %cmp1, label %left_x, label %right_x
683 ; CHECK: [[RNG4]] = !{i32 0, i32 1}
685 !0 = !{!3, !3, i64 0}
686 !1 = !{!"omnipotent char", !2}
687 !2 = !{!"Simple C/C++ TBAA"}
689 !4 = !{ i32 0, i32 1 }
690 !5 = !{ i32 8, i32 10 }