1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -keep-loops=false -sink-common-insts=true -S | FileCheck %s
4 ; This would infinite-loop because we allowed code sinking to examine an infinite-loop block (%j).
6 define void @PR49541(ptr %t1, i32 %a, i1 %bool) {
7 ; CHECK-LABEL: @PR49541(
9 ; CHECK-NEXT: br label [[I:%.*]]
11 ; CHECK-NEXT: [[T3:%.*]] = phi i32 [ [[B:%.*]], [[J:%.*]] ], [ [[A:%.*]], [[COND_TRUE:%.*]] ], [ [[A]], [[COND_FALSE:%.*]] ]
12 ; CHECK-NEXT: [[T2:%.*]] = phi i32 [ [[T2]], [[J]] ], [ [[PRE2:%.*]], [[COND_TRUE]] ], [ 0, [[COND_FALSE]] ]
13 ; CHECK-NEXT: [[B]] = load i32, ptr [[T1:%.*]], align 4
14 ; CHECK-NEXT: br label [[J]]
16 ; CHECK-NEXT: [[G_1:%.*]] = phi i16 [ undef, [[ENTRY:%.*]] ], [ [[G_1]], [[COND_FALSE]] ]
17 ; CHECK-NEXT: br i1 [[BOOL:%.*]], label [[COND_FALSE]], label [[COND_TRUE]]
19 ; CHECK-NEXT: [[TOBOOL9_NOT:%.*]] = icmp eq i16 [[G_1]], 0
20 ; CHECK-NEXT: [[PRE2]] = load i32, ptr [[T1]], align 4
21 ; CHECK-NEXT: br label [[J]]
23 ; CHECK-NEXT: [[T5:%.*]] = load i32, ptr [[T1]], align 4
24 ; CHECK-NEXT: [[B2:%.*]] = icmp eq i32 [[T5]], 0
25 ; CHECK-NEXT: br i1 [[B2]], label [[J]], label [[I]]
31 %t3 = phi i32 [ %b, %j ], [ %a, %cond.true ], [ %a, %cond.false ]
32 %t2 = phi i32 [ %t2, %j ], [ %pre2, %cond.true ], [ 0, %cond.false ]
33 %b = load i32, ptr %t1, align 4
37 %g.1 = phi i16 [ undef, %entry ], [ %g.1, %cond.false ]
38 br i1 %bool, label %cond.false, label %cond.true
41 %tobool9.not = icmp eq i16 %g.1, 0
42 %pre2 = load i32, ptr %t1, align 4
46 %t5 = load i32, ptr %t1, align 4
47 %b2 = icmp eq i32 %t5, 0
48 br i1 %b2, label %j, label %i