1 ; RUN: opt -S < %s -indvars | opt -analyze -iv-users | grep "%cmp = icmp slt i32" | grep "= {%\.ph,+,1}<%for.cond>"
4 ; LoopSimplify should invalidate indvars when splitting out the
7 @maxStat = external global i32
9 define i32 @test() nounwind {
13 for.cond: ; preds = %if.then5, %if.end, %entry
14 %cuts.1 = phi i32 [ 0, %entry ], [ %inc, %if.then5 ], [ %cuts.1, %if.end ]
15 %0 = phi i32 [ 0, %entry ], [ %add, %if.end ], [ %add, %if.then5 ]
17 %cmp = icmp slt i32 %0, 1
18 %tmp1 = load i32* @maxStat, align 4
19 br i1 %cmp, label %for.body, label %for.cond14.preheader
21 for.cond14.preheader: ; preds = %for.cond
22 %cmp1726 = icmp sgt i32 %tmp1, 0
23 br i1 %cmp1726, label %for.body18, label %return
25 for.body: ; preds = %for.cond
26 %cmp2 = icmp sgt i32 %tmp1, 100
27 br i1 %cmp2, label %return, label %if.end
29 if.end: ; preds = %for.body
30 %cmp4 = icmp sgt i32 %tmp1, -1
31 br i1 %cmp4, label %if.then5, label %for.cond
33 if.then5: ; preds = %if.end
34 call void @foo() nounwind
35 %inc = add i32 %cuts.1, 1
38 for.body18: ; preds = %for.body18, %for.cond14.preheader
39 %i13.027 = phi i32 [ %1, %for.body18 ], [ 0, %for.cond14.preheader ]
40 call void @foo() nounwind
41 %1 = add nsw i32 %i13.027, 1
42 %tmp16 = load i32* @maxStat, align 4
43 %cmp17 = icmp slt i32 %1, %tmp16
44 br i1 %cmp17, label %for.body18, label %return
46 return: ; preds = %for.body18, %for.body, %for.cond14.preheader
50 declare void @foo() nounwind
52 ; Notify SCEV when removing an ExitingBlock.
53 ; CHECK-LABEL: @mergeExit(
54 ; CHECK: while.cond191:
55 ; CHECK: br i1 %or.cond, label %while.body197
56 ; CHECK-NOT: land.rhs:
58 define void @mergeExit(i32 %MapAttrCount) nounwind uwtable ssp {
60 br i1 undef, label %if.then124, label %if.end126
62 if.then124: ; preds = %entry
65 if.end126: ; preds = %entry
66 br i1 undef, label %while.body.lr.ph, label %if.end591
68 while.body.lr.ph: ; preds = %if.end126
69 br i1 undef, label %if.end140, label %if.then137
71 if.then137: ; preds = %while.body.lr.ph
74 if.end140: ; preds = %while.body.lr.ph
75 br i1 undef, label %while.cond191.outer, label %if.then148
77 if.then148: ; preds = %if.end140
80 while.cond191.outer: ; preds = %if.then205, %if.end140
81 br label %while.cond191
83 while.cond191: ; preds = %while.body197, %while.cond191.outer
84 %CppIndex.0 = phi i32 [ %inc, %while.body197 ], [ undef, %while.cond191.outer ]
85 br i1 undef, label %land.rhs, label %if.then216
87 land.rhs: ; preds = %while.cond191
88 %inc = add i32 %CppIndex.0, 1
89 %cmp196 = icmp ult i32 %inc, %MapAttrCount
90 br i1 %cmp196, label %while.body197, label %if.then216
92 while.body197: ; preds = %land.rhs
93 br i1 undef, label %if.then205, label %while.cond191
95 if.then205: ; preds = %while.body197
96 br label %while.cond191.outer
98 if.then216: ; preds = %land.rhs, %while.cond191
99 br i1 undef, label %if.else, label %if.then221
101 if.then221: ; preds = %if.then216
104 if.else: ; preds = %if.then216
105 br i1 undef, label %if.then266, label %if.end340
107 if.then266: ; preds = %if.else
108 switch i32 undef, label %if.else329 [
109 i32 17, label %if.then285
110 i32 19, label %if.then285
111 i32 18, label %if.then285
112 i32 15, label %if.then285
115 if.then285: ; preds = %if.then266, %if.then266, %if.then266, %if.then266
116 br i1 undef, label %if.then317, label %if.else324
118 if.then317: ; preds = %if.then285
121 if.else324: ; preds = %if.then285
124 if.else329: ; preds = %if.then266
127 if.end340: ; preds = %if.then317, %if.else
130 if.end591: ; preds = %if.end126
131 br i1 undef, label %cond.end, label %cond.false
133 cond.false: ; preds = %if.end591
136 cond.end: ; preds = %if.end591