1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -mtriple=thumbv8m.main -mcpu=cortex-m33 -passes=loop-unroll -S < %s -o - | FileCheck %s
3 ; RUN: opt -mtriple=thumbv7em -mcpu=cortex-m7 -passes=loop-unroll -S < %s -o - | FileCheck %s
5 define void @test_three_blocks(ptr nocapture %Output, ptr nocapture readonly %Condition, ptr nocapture readonly %Input, i32 %MaxJ) {
6 ; CHECK-LABEL: @test_three_blocks(
8 ; CHECK-NEXT: [[CMP8:%.*]] = icmp eq i32 [[MAXJ:%.*]], 0
9 ; CHECK-NEXT: br i1 [[CMP8]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
10 ; CHECK: for.body.preheader:
11 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[MAXJ]], -1
12 ; CHECK-NEXT: [[XTRAITER:%.*]] = and i32 [[MAXJ]], 3
13 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[TMP0]], 3
14 ; CHECK-NEXT: br i1 [[TMP1]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA:%.*]], label [[FOR_BODY_PREHEADER_NEW:%.*]]
15 ; CHECK: for.body.preheader.new:
16 ; CHECK-NEXT: [[UNROLL_ITER:%.*]] = sub i32 [[MAXJ]], [[XTRAITER]]
17 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
18 ; CHECK: for.cond.cleanup.loopexit.unr-lcssa.loopexit:
19 ; CHECK-NEXT: [[TEMP_1_LCSSA_PH_PH:%.*]] = phi i32 [ [[TEMP_1_3:%.*]], [[FOR_INC_3:%.*]] ]
20 ; CHECK-NEXT: [[J_010_UNR_PH:%.*]] = phi i32 [ [[INC_3:%.*]], [[FOR_INC_3]] ]
21 ; CHECK-NEXT: [[TEMP_09_UNR_PH:%.*]] = phi i32 [ [[TEMP_1_3]], [[FOR_INC_3]] ]
22 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]]
23 ; CHECK: for.cond.cleanup.loopexit.unr-lcssa:
24 ; CHECK-NEXT: [[TEMP_1_LCSSA_PH:%.*]] = phi i32 [ poison, [[FOR_BODY_PREHEADER]] ], [ [[TEMP_1_LCSSA_PH_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA_LOOPEXIT:%.*]] ]
25 ; CHECK-NEXT: [[J_010_UNR:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[J_010_UNR_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA_LOOPEXIT]] ]
26 ; CHECK-NEXT: [[TEMP_09_UNR:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[TEMP_09_UNR_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA_LOOPEXIT]] ]
27 ; CHECK-NEXT: [[LCMP_MOD:%.*]] = icmp ne i32 [[XTRAITER]], 0
28 ; CHECK-NEXT: br i1 [[LCMP_MOD]], label [[FOR_BODY_EPIL_PREHEADER:%.*]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
29 ; CHECK: for.body.epil.preheader:
30 ; CHECK-NEXT: br label [[FOR_BODY_EPIL:%.*]]
31 ; CHECK: for.body.epil:
32 ; CHECK-NEXT: [[ARRAYIDX_EPIL:%.*]] = getelementptr inbounds i32, ptr [[CONDITION:%.*]], i32 [[J_010_UNR]]
33 ; CHECK-NEXT: [[I_EPIL:%.*]] = load i32, ptr [[ARRAYIDX_EPIL]], align 4
34 ; CHECK-NEXT: [[TOBOOL_EPIL:%.*]] = icmp eq i32 [[I_EPIL]], 0
35 ; CHECK-NEXT: br i1 [[TOBOOL_EPIL]], label [[FOR_INC_EPIL:%.*]], label [[IF_THEN_EPIL:%.*]]
36 ; CHECK: if.then.epil:
37 ; CHECK-NEXT: [[ARRAYIDX1_EPIL:%.*]] = getelementptr inbounds i32, ptr [[INPUT:%.*]], i32 [[J_010_UNR]]
38 ; CHECK-NEXT: [[I1_EPIL:%.*]] = load i32, ptr [[ARRAYIDX1_EPIL]], align 4
39 ; CHECK-NEXT: [[ADD_EPIL:%.*]] = add i32 [[I1_EPIL]], [[TEMP_09_UNR]]
40 ; CHECK-NEXT: br label [[FOR_INC_EPIL]]
41 ; CHECK: for.inc.epil:
42 ; CHECK-NEXT: [[TEMP_1_EPIL:%.*]] = phi i32 [ [[ADD_EPIL]], [[IF_THEN_EPIL]] ], [ [[TEMP_09_UNR]], [[FOR_BODY_EPIL]] ]
43 ; CHECK-NEXT: [[INC_EPIL:%.*]] = add nuw i32 [[J_010_UNR]], 1
44 ; CHECK-NEXT: [[EPIL_ITER_CMP:%.*]] = icmp ne i32 1, [[XTRAITER]]
45 ; CHECK-NEXT: br i1 [[EPIL_ITER_CMP]], label [[FOR_BODY_EPIL_1:%.*]], label [[FOR_COND_CLEANUP_LOOPEXIT_EPILOG_LCSSA:%.*]]
46 ; CHECK: for.body.epil.1:
47 ; CHECK-NEXT: [[ARRAYIDX_EPIL_1:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_EPIL]]
48 ; CHECK-NEXT: [[I_EPIL_1:%.*]] = load i32, ptr [[ARRAYIDX_EPIL_1]], align 4
49 ; CHECK-NEXT: [[TOBOOL_EPIL_1:%.*]] = icmp eq i32 [[I_EPIL_1]], 0
50 ; CHECK-NEXT: br i1 [[TOBOOL_EPIL_1]], label [[FOR_INC_EPIL_1:%.*]], label [[IF_THEN_EPIL_1:%.*]]
51 ; CHECK: if.then.epil.1:
52 ; CHECK-NEXT: [[ARRAYIDX1_EPIL_1:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_EPIL]]
53 ; CHECK-NEXT: [[I1_EPIL_1:%.*]] = load i32, ptr [[ARRAYIDX1_EPIL_1]], align 4
54 ; CHECK-NEXT: [[ADD_EPIL_1:%.*]] = add i32 [[I1_EPIL_1]], [[TEMP_1_EPIL]]
55 ; CHECK-NEXT: br label [[FOR_INC_EPIL_1]]
56 ; CHECK: for.inc.epil.1:
57 ; CHECK-NEXT: [[TEMP_1_EPIL_1:%.*]] = phi i32 [ [[ADD_EPIL_1]], [[IF_THEN_EPIL_1]] ], [ [[TEMP_1_EPIL]], [[FOR_BODY_EPIL_1]] ]
58 ; CHECK-NEXT: [[INC_EPIL_1:%.*]] = add nuw i32 [[J_010_UNR]], 2
59 ; CHECK-NEXT: [[EPIL_ITER_CMP_1:%.*]] = icmp ne i32 2, [[XTRAITER]]
60 ; CHECK-NEXT: br i1 [[EPIL_ITER_CMP_1]], label [[FOR_BODY_EPIL_2:%.*]], label [[FOR_COND_CLEANUP_LOOPEXIT_EPILOG_LCSSA]]
61 ; CHECK: for.body.epil.2:
62 ; CHECK-NEXT: [[ARRAYIDX_EPIL_2:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_EPIL_1]]
63 ; CHECK-NEXT: [[I_EPIL_2:%.*]] = load i32, ptr [[ARRAYIDX_EPIL_2]], align 4
64 ; CHECK-NEXT: [[TOBOOL_EPIL_2:%.*]] = icmp eq i32 [[I_EPIL_2]], 0
65 ; CHECK-NEXT: br i1 [[TOBOOL_EPIL_2]], label [[FOR_INC_EPIL_2:%.*]], label [[IF_THEN_EPIL_2:%.*]]
66 ; CHECK: if.then.epil.2:
67 ; CHECK-NEXT: [[ARRAYIDX1_EPIL_2:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_EPIL_1]]
68 ; CHECK-NEXT: [[I1_EPIL_2:%.*]] = load i32, ptr [[ARRAYIDX1_EPIL_2]], align 4
69 ; CHECK-NEXT: [[ADD_EPIL_2:%.*]] = add i32 [[I1_EPIL_2]], [[TEMP_1_EPIL_1]]
70 ; CHECK-NEXT: br label [[FOR_INC_EPIL_2]]
71 ; CHECK: for.inc.epil.2:
72 ; CHECK-NEXT: [[TEMP_1_EPIL_2:%.*]] = phi i32 [ [[ADD_EPIL_2]], [[IF_THEN_EPIL_2]] ], [ [[TEMP_1_EPIL_1]], [[FOR_BODY_EPIL_2]] ]
73 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT_EPILOG_LCSSA]]
74 ; CHECK: for.cond.cleanup.loopexit.epilog-lcssa:
75 ; CHECK-NEXT: [[TEMP_1_LCSSA_PH1:%.*]] = phi i32 [ [[TEMP_1_EPIL]], [[FOR_INC_EPIL]] ], [ [[TEMP_1_EPIL_1]], [[FOR_INC_EPIL_1]] ], [ [[TEMP_1_EPIL_2]], [[FOR_INC_EPIL_2]] ]
76 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT]]
77 ; CHECK: for.cond.cleanup.loopexit:
78 ; CHECK-NEXT: [[TEMP_1_LCSSA:%.*]] = phi i32 [ [[TEMP_1_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ], [ [[TEMP_1_LCSSA_PH1]], [[FOR_COND_CLEANUP_LOOPEXIT_EPILOG_LCSSA]] ]
79 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
80 ; CHECK: for.cond.cleanup:
81 ; CHECK-NEXT: [[TEMP_0_LCSSA:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[TEMP_1_LCSSA]], [[FOR_COND_CLEANUP_LOOPEXIT]] ]
82 ; CHECK-NEXT: store i32 [[TEMP_0_LCSSA]], ptr [[OUTPUT:%.*]], align 4
83 ; CHECK-NEXT: ret void
85 ; CHECK-NEXT: [[J_010:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER_NEW]] ], [ [[INC_3]], [[FOR_INC_3]] ]
86 ; CHECK-NEXT: [[TEMP_09:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER_NEW]] ], [ [[TEMP_1_3]], [[FOR_INC_3]] ]
87 ; CHECK-NEXT: [[NITER:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER_NEW]] ], [ [[NITER_NEXT_3:%.*]], [[FOR_INC_3]] ]
88 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[J_010]]
89 ; CHECK-NEXT: [[I:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
90 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[I]], 0
91 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[FOR_INC:%.*]], label [[IF_THEN:%.*]]
93 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[J_010]]
94 ; CHECK-NEXT: [[I1:%.*]] = load i32, ptr [[ARRAYIDX1]], align 4
95 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[I1]], [[TEMP_09]]
96 ; CHECK-NEXT: br label [[FOR_INC]]
98 ; CHECK-NEXT: [[TEMP_1:%.*]] = phi i32 [ [[ADD]], [[IF_THEN]] ], [ [[TEMP_09]], [[FOR_BODY]] ]
99 ; CHECK-NEXT: [[INC:%.*]] = add nuw nsw i32 [[J_010]], 1
100 ; CHECK-NEXT: [[ARRAYIDX_1:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC]]
101 ; CHECK-NEXT: [[I_1:%.*]] = load i32, ptr [[ARRAYIDX_1]], align 4
102 ; CHECK-NEXT: [[TOBOOL_1:%.*]] = icmp eq i32 [[I_1]], 0
103 ; CHECK-NEXT: br i1 [[TOBOOL_1]], label [[FOR_INC_1:%.*]], label [[IF_THEN_1:%.*]]
105 ; CHECK-NEXT: [[ARRAYIDX1_1:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC]]
106 ; CHECK-NEXT: [[I1_1:%.*]] = load i32, ptr [[ARRAYIDX1_1]], align 4
107 ; CHECK-NEXT: [[ADD_1:%.*]] = add i32 [[I1_1]], [[TEMP_1]]
108 ; CHECK-NEXT: br label [[FOR_INC_1]]
110 ; CHECK-NEXT: [[TEMP_1_1:%.*]] = phi i32 [ [[ADD_1]], [[IF_THEN_1]] ], [ [[TEMP_1]], [[FOR_INC]] ]
111 ; CHECK-NEXT: [[INC_1:%.*]] = add nuw nsw i32 [[J_010]], 2
112 ; CHECK-NEXT: [[ARRAYIDX_2:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_1]]
113 ; CHECK-NEXT: [[I_2:%.*]] = load i32, ptr [[ARRAYIDX_2]], align 4
114 ; CHECK-NEXT: [[TOBOOL_2:%.*]] = icmp eq i32 [[I_2]], 0
115 ; CHECK-NEXT: br i1 [[TOBOOL_2]], label [[FOR_INC_2:%.*]], label [[IF_THEN_2:%.*]]
117 ; CHECK-NEXT: [[ARRAYIDX1_2:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_1]]
118 ; CHECK-NEXT: [[I1_2:%.*]] = load i32, ptr [[ARRAYIDX1_2]], align 4
119 ; CHECK-NEXT: [[ADD_2:%.*]] = add i32 [[I1_2]], [[TEMP_1_1]]
120 ; CHECK-NEXT: br label [[FOR_INC_2]]
122 ; CHECK-NEXT: [[TEMP_1_2:%.*]] = phi i32 [ [[ADD_2]], [[IF_THEN_2]] ], [ [[TEMP_1_1]], [[FOR_INC_1]] ]
123 ; CHECK-NEXT: [[INC_2:%.*]] = add nuw nsw i32 [[J_010]], 3
124 ; CHECK-NEXT: [[ARRAYIDX_3:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_2]]
125 ; CHECK-NEXT: [[I_3:%.*]] = load i32, ptr [[ARRAYIDX_3]], align 4
126 ; CHECK-NEXT: [[TOBOOL_3:%.*]] = icmp eq i32 [[I_3]], 0
127 ; CHECK-NEXT: br i1 [[TOBOOL_3]], label [[FOR_INC_3]], label [[IF_THEN_3:%.*]]
129 ; CHECK-NEXT: [[ARRAYIDX1_3:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_2]]
130 ; CHECK-NEXT: [[I1_3:%.*]] = load i32, ptr [[ARRAYIDX1_3]], align 4
131 ; CHECK-NEXT: [[ADD_3:%.*]] = add i32 [[I1_3]], [[TEMP_1_2]]
132 ; CHECK-NEXT: br label [[FOR_INC_3]]
134 ; CHECK-NEXT: [[TEMP_1_3]] = phi i32 [ [[ADD_3]], [[IF_THEN_3]] ], [ [[TEMP_1_2]], [[FOR_INC_2]] ]
135 ; CHECK-NEXT: [[INC_3]] = add nuw i32 [[J_010]], 4
136 ; CHECK-NEXT: [[NITER_NEXT_3]] = add i32 [[NITER]], 4
137 ; CHECK-NEXT: [[NITER_NCMP_3:%.*]] = icmp eq i32 [[NITER_NEXT_3]], [[UNROLL_ITER]]
138 ; CHECK-NEXT: br i1 [[NITER_NCMP_3]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA_LOOPEXIT]], label [[FOR_BODY]]
141 %cmp8 = icmp eq i32 %MaxJ, 0
142 br i1 %cmp8, label %for.cond.cleanup, label %for.body.preheader
144 for.body.preheader: ; preds = %entry
147 for.cond.cleanup: ; preds = %for.inc, %entry
148 %temp.0.lcssa = phi i32 [ 0, %entry ], [ %temp.1, %for.inc ]
149 store i32 %temp.0.lcssa, ptr %Output, align 4
152 for.body: ; preds = %for.inc, %for.body.preheader
153 %j.010 = phi i32 [ %inc, %for.inc ], [ 0, %for.body.preheader ]
154 %temp.09 = phi i32 [ %temp.1, %for.inc ], [ 0, %for.body.preheader ]
155 %arrayidx = getelementptr inbounds i32, ptr %Condition, i32 %j.010
156 %i = load i32, ptr %arrayidx, align 4
157 %tobool = icmp eq i32 %i, 0
158 br i1 %tobool, label %for.inc, label %if.then
160 if.then: ; preds = %for.body
161 %arrayidx1 = getelementptr inbounds i32, ptr %Input, i32 %j.010
162 %i1 = load i32, ptr %arrayidx1, align 4
163 %add = add i32 %i1, %temp.09
166 for.inc: ; preds = %if.then, %for.body
167 %temp.1 = phi i32 [ %add, %if.then ], [ %temp.09, %for.body ]
168 %inc = add nuw i32 %j.010, 1
169 %exitcond = icmp eq i32 %inc, %MaxJ
170 br i1 %exitcond, label %for.cond.cleanup, label %for.body
173 define void @test_two_exits(ptr nocapture %Output, ptr nocapture readonly %Condition, ptr nocapture readonly %Input, i32 %MaxJ) {
174 ; CHECK-LABEL: @test_two_exits(
176 ; CHECK-NEXT: [[CMP14:%.*]] = icmp eq i32 [[MAXJ:%.*]], 0
177 ; CHECK-NEXT: br i1 [[CMP14]], label [[CLEANUP:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
178 ; CHECK: for.body.preheader:
179 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
181 ; CHECK-NEXT: [[J_016:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[INC_3:%.*]], [[IF_END_3:%.*]] ]
182 ; CHECK-NEXT: [[TEMP_015:%.*]] = phi i32 [ 0, [[FOR_BODY_PREHEADER]] ], [ [[TEMP_0_ADD_3:%.*]], [[IF_END_3]] ]
183 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[INPUT:%.*]], i32 [[J_016]]
184 ; CHECK-NEXT: [[I:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
185 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[I]], 65535
186 ; CHECK-NEXT: br i1 [[CMP1]], label [[CLEANUP_LOOPEXIT:%.*]], label [[IF_END:%.*]]
188 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[CONDITION:%.*]], i32 [[J_016]]
189 ; CHECK-NEXT: [[I1:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
190 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[I1]], 0
191 ; CHECK-NEXT: [[ADD:%.*]] = select i1 [[TOBOOL]], i32 0, i32 [[I]]
192 ; CHECK-NEXT: [[TEMP_0_ADD:%.*]] = add i32 [[ADD]], [[TEMP_015]]
193 ; CHECK-NEXT: [[INC:%.*]] = add nuw nsw i32 [[J_016]], 1
194 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[INC]], [[MAXJ]]
195 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY_1:%.*]], label [[CLEANUP_LOOPEXIT]]
197 ; CHECK-NEXT: [[ARRAYIDX_1:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC]]
198 ; CHECK-NEXT: [[I_1:%.*]] = load i32, ptr [[ARRAYIDX_1]], align 4
199 ; CHECK-NEXT: [[CMP1_1:%.*]] = icmp ugt i32 [[I_1]], 65535
200 ; CHECK-NEXT: br i1 [[CMP1_1]], label [[CLEANUP_LOOPEXIT]], label [[IF_END_1:%.*]]
202 ; CHECK-NEXT: [[ARRAYIDX2_1:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC]]
203 ; CHECK-NEXT: [[I1_1:%.*]] = load i32, ptr [[ARRAYIDX2_1]], align 4
204 ; CHECK-NEXT: [[TOBOOL_1:%.*]] = icmp eq i32 [[I1_1]], 0
205 ; CHECK-NEXT: [[ADD_1:%.*]] = select i1 [[TOBOOL_1]], i32 0, i32 [[I_1]]
206 ; CHECK-NEXT: [[TEMP_0_ADD_1:%.*]] = add i32 [[ADD_1]], [[TEMP_0_ADD]]
207 ; CHECK-NEXT: [[INC_1:%.*]] = add nuw nsw i32 [[J_016]], 2
208 ; CHECK-NEXT: [[CMP_1:%.*]] = icmp ult i32 [[INC_1]], [[MAXJ]]
209 ; CHECK-NEXT: br i1 [[CMP_1]], label [[FOR_BODY_2:%.*]], label [[CLEANUP_LOOPEXIT]]
211 ; CHECK-NEXT: [[ARRAYIDX_2:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_1]]
212 ; CHECK-NEXT: [[I_2:%.*]] = load i32, ptr [[ARRAYIDX_2]], align 4
213 ; CHECK-NEXT: [[CMP1_2:%.*]] = icmp ugt i32 [[I_2]], 65535
214 ; CHECK-NEXT: br i1 [[CMP1_2]], label [[CLEANUP_LOOPEXIT]], label [[IF_END_2:%.*]]
216 ; CHECK-NEXT: [[ARRAYIDX2_2:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_1]]
217 ; CHECK-NEXT: [[I1_2:%.*]] = load i32, ptr [[ARRAYIDX2_2]], align 4
218 ; CHECK-NEXT: [[TOBOOL_2:%.*]] = icmp eq i32 [[I1_2]], 0
219 ; CHECK-NEXT: [[ADD_2:%.*]] = select i1 [[TOBOOL_2]], i32 0, i32 [[I_2]]
220 ; CHECK-NEXT: [[TEMP_0_ADD_2:%.*]] = add i32 [[ADD_2]], [[TEMP_0_ADD_1]]
221 ; CHECK-NEXT: [[INC_2:%.*]] = add nuw nsw i32 [[J_016]], 3
222 ; CHECK-NEXT: [[CMP_2:%.*]] = icmp ult i32 [[INC_2]], [[MAXJ]]
223 ; CHECK-NEXT: br i1 [[CMP_2]], label [[FOR_BODY_3:%.*]], label [[CLEANUP_LOOPEXIT]]
225 ; CHECK-NEXT: [[ARRAYIDX_3:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_2]]
226 ; CHECK-NEXT: [[I_3:%.*]] = load i32, ptr [[ARRAYIDX_3]], align 4
227 ; CHECK-NEXT: [[CMP1_3:%.*]] = icmp ugt i32 [[I_3]], 65535
228 ; CHECK-NEXT: br i1 [[CMP1_3]], label [[CLEANUP_LOOPEXIT]], label [[IF_END_3]]
230 ; CHECK-NEXT: [[ARRAYIDX2_3:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_2]]
231 ; CHECK-NEXT: [[I1_3:%.*]] = load i32, ptr [[ARRAYIDX2_3]], align 4
232 ; CHECK-NEXT: [[TOBOOL_3:%.*]] = icmp eq i32 [[I1_3]], 0
233 ; CHECK-NEXT: [[ADD_3:%.*]] = select i1 [[TOBOOL_3]], i32 0, i32 [[I_3]]
234 ; CHECK-NEXT: [[TEMP_0_ADD_3]] = add i32 [[ADD_3]], [[TEMP_0_ADD_2]]
235 ; CHECK-NEXT: [[INC_3]] = add nuw i32 [[J_016]], 4
236 ; CHECK-NEXT: [[CMP_3:%.*]] = icmp ult i32 [[INC_3]], [[MAXJ]]
237 ; CHECK-NEXT: br i1 [[CMP_3]], label [[FOR_BODY]], label [[CLEANUP_LOOPEXIT]]
238 ; CHECK: cleanup.loopexit:
239 ; CHECK-NEXT: [[TEMP_0_LCSSA_PH:%.*]] = phi i32 [ [[TEMP_0_ADD]], [[IF_END]] ], [ [[TEMP_015]], [[FOR_BODY]] ], [ [[TEMP_0_ADD]], [[FOR_BODY_1]] ], [ [[TEMP_0_ADD_1]], [[IF_END_1]] ], [ [[TEMP_0_ADD_1]], [[FOR_BODY_2]] ], [ [[TEMP_0_ADD_2]], [[IF_END_2]] ], [ [[TEMP_0_ADD_2]], [[FOR_BODY_3]] ], [ [[TEMP_0_ADD_3]], [[IF_END_3]] ]
240 ; CHECK-NEXT: br label [[CLEANUP]]
242 ; CHECK-NEXT: [[TEMP_0_LCSSA:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[TEMP_0_LCSSA_PH]], [[CLEANUP_LOOPEXIT]] ]
243 ; CHECK-NEXT: store i32 [[TEMP_0_LCSSA]], ptr [[OUTPUT:%.*]], align 4
244 ; CHECK-NEXT: ret void
247 %cmp14 = icmp eq i32 %MaxJ, 0
248 br i1 %cmp14, label %cleanup, label %for.body.preheader
250 for.body.preheader: ; preds = %entry
253 for.body: ; preds = %if.end, %for.body.preheader
254 %j.016 = phi i32 [ %inc, %if.end ], [ 0, %for.body.preheader ]
255 %temp.015 = phi i32 [ %temp.0.add, %if.end ], [ 0, %for.body.preheader ]
256 %arrayidx = getelementptr inbounds i32, ptr %Input, i32 %j.016
257 %i = load i32, ptr %arrayidx, align 4
258 %cmp1 = icmp ugt i32 %i, 65535
259 br i1 %cmp1, label %cleanup, label %if.end
261 if.end: ; preds = %for.body
262 %arrayidx2 = getelementptr inbounds i32, ptr %Condition, i32 %j.016
263 %i1 = load i32, ptr %arrayidx2, align 4
264 %tobool = icmp eq i32 %i1, 0
265 %add = select i1 %tobool, i32 0, i32 %i
266 %temp.0.add = add i32 %add, %temp.015
267 %inc = add nuw i32 %j.016, 1
268 %cmp = icmp ult i32 %inc, %MaxJ
269 br i1 %cmp, label %for.body, label %cleanup
271 cleanup: ; preds = %if.end, %for.body, %entry
272 %temp.0.lcssa = phi i32 [ 0, %entry ], [ %temp.015, %for.body ], [ %temp.0.add, %if.end ]
273 store i32 %temp.0.lcssa, ptr %Output, align 4
277 define void @test_three_exits(ptr nocapture %Output, ptr nocapture readonly %Condition, ptr nocapture readonly %Input, i32 %MaxJ) {
278 ; CHECK-LABEL: @test_three_exits(
280 ; CHECK-NEXT: [[CMP20:%.*]] = icmp eq i32 [[MAXJ:%.*]], 0
281 ; CHECK-NEXT: br i1 [[CMP20]], label [[CLEANUP:%.*]], label [[FOR_BODY_PREHEADER:%.*]]
282 ; CHECK: for.body.preheader:
283 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
285 ; CHECK-NEXT: [[J_022:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END5:%.*]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
286 ; CHECK-NEXT: [[TEMP_021:%.*]] = phi i32 [ [[TEMP_0_ADD:%.*]], [[IF_END5]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
287 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[CONDITION:%.*]], i32 [[J_022]]
288 ; CHECK-NEXT: [[I:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
289 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[I]], 65535
290 ; CHECK-NEXT: br i1 [[CMP1]], label [[CLEANUP_LOOPEXIT:%.*]], label [[IF_END:%.*]]
292 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[INPUT:%.*]], i32 [[J_022]]
293 ; CHECK-NEXT: [[I1:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
294 ; CHECK-NEXT: [[CMP3:%.*]] = icmp ugt i32 [[I1]], 65535
295 ; CHECK-NEXT: br i1 [[CMP3]], label [[CLEANUP_LOOPEXIT]], label [[IF_END5]]
297 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[I]], 0
298 ; CHECK-NEXT: [[ADD:%.*]] = select i1 [[TOBOOL]], i32 0, i32 [[I1]]
299 ; CHECK-NEXT: [[TEMP_0_ADD]] = add i32 [[ADD]], [[TEMP_021]]
300 ; CHECK-NEXT: [[INC]] = add nuw i32 [[J_022]], 1
301 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[INC]], [[MAXJ]]
302 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[CLEANUP_LOOPEXIT]]
303 ; CHECK: cleanup.loopexit:
304 ; CHECK-NEXT: [[TEMP_0_LCSSA_PH:%.*]] = phi i32 [ [[TEMP_0_ADD]], [[IF_END5]] ], [ [[TEMP_021]], [[FOR_BODY]] ], [ [[TEMP_021]], [[IF_END]] ]
305 ; CHECK-NEXT: br label [[CLEANUP]]
307 ; CHECK-NEXT: [[TEMP_0_LCSSA:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[TEMP_0_LCSSA_PH]], [[CLEANUP_LOOPEXIT]] ]
308 ; CHECK-NEXT: store i32 [[TEMP_0_LCSSA]], ptr [[OUTPUT:%.*]], align 4
309 ; CHECK-NEXT: ret void
312 %cmp20 = icmp eq i32 %MaxJ, 0
313 br i1 %cmp20, label %cleanup, label %for.body.preheader
315 for.body.preheader: ; preds = %entry
318 for.body: ; preds = %if.end5, %for.body.preheader
319 %j.022 = phi i32 [ %inc, %if.end5 ], [ 0, %for.body.preheader ]
320 %temp.021 = phi i32 [ %temp.0.add, %if.end5 ], [ 0, %for.body.preheader ]
321 %arrayidx = getelementptr inbounds i32, ptr %Condition, i32 %j.022
322 %i = load i32, ptr %arrayidx, align 4
323 %cmp1 = icmp ugt i32 %i, 65535
324 br i1 %cmp1, label %cleanup, label %if.end
326 if.end: ; preds = %for.body
327 %arrayidx2 = getelementptr inbounds i32, ptr %Input, i32 %j.022
328 %i1 = load i32, ptr %arrayidx2, align 4
329 %cmp3 = icmp ugt i32 %i1, 65535
330 br i1 %cmp3, label %cleanup, label %if.end5
332 if.end5: ; preds = %if.end
333 %tobool = icmp eq i32 %i, 0
334 %add = select i1 %tobool, i32 0, i32 %i1
335 %temp.0.add = add i32 %add, %temp.021
336 %inc = add nuw i32 %j.022, 1
337 %cmp = icmp ult i32 %inc, %MaxJ
338 br i1 %cmp, label %for.body, label %cleanup
340 cleanup: ; preds = %if.end5, %if.end, %for.body, %entry
341 %temp.0.lcssa = phi i32 [ 0, %entry ], [ %temp.021, %if.end ], [ %temp.021, %for.body ], [ %temp.0.add, %if.end5 ]
342 store i32 %temp.0.lcssa, ptr %Output, align 4
346 define void @test_four_blocks(ptr nocapture %Output, ptr nocapture readonly %Condition, ptr nocapture readonly %Input, i32 %MaxJ) {
347 ; CHECK-LABEL: @test_four_blocks(
349 ; CHECK-NEXT: [[CMP25:%.*]] = icmp ugt i32 [[MAXJ:%.*]], 1
350 ; CHECK-NEXT: br i1 [[CMP25]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_COND_CLEANUP:%.*]]
351 ; CHECK: for.body.lr.ph:
352 ; CHECK-NEXT: [[DOTPRE:%.*]] = load i32, ptr [[INPUT:%.*]], align 4
353 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[MAXJ]], -1
354 ; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[MAXJ]], -2
355 ; CHECK-NEXT: [[XTRAITER:%.*]] = and i32 [[TMP0]], 3
356 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 [[TMP1]], 3
357 ; CHECK-NEXT: br i1 [[TMP2]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA:%.*]], label [[FOR_BODY_LR_PH_NEW:%.*]]
358 ; CHECK: for.body.lr.ph.new:
359 ; CHECK-NEXT: [[UNROLL_ITER:%.*]] = sub i32 [[TMP0]], [[XTRAITER]]
360 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
361 ; CHECK: for.cond.cleanup.loopexit.unr-lcssa.loopexit:
362 ; CHECK-NEXT: [[TEMP_1_LCSSA_PH_PH:%.*]] = phi i32 [ [[TEMP_1_3:%.*]], [[FOR_INC_3:%.*]] ]
363 ; CHECK-NEXT: [[I_UNR_PH:%.*]] = phi i32 [ [[I2_3:%.*]], [[FOR_INC_3]] ]
364 ; CHECK-NEXT: [[J_027_UNR_PH:%.*]] = phi i32 [ [[INC_3:%.*]], [[FOR_INC_3]] ]
365 ; CHECK-NEXT: [[TEMP_026_UNR_PH:%.*]] = phi i32 [ [[TEMP_1_3]], [[FOR_INC_3]] ]
366 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]]
367 ; CHECK: for.cond.cleanup.loopexit.unr-lcssa:
368 ; CHECK-NEXT: [[TEMP_1_LCSSA_PH:%.*]] = phi i32 [ poison, [[FOR_BODY_LR_PH]] ], [ [[TEMP_1_LCSSA_PH_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA_LOOPEXIT:%.*]] ]
369 ; CHECK-NEXT: [[I_UNR:%.*]] = phi i32 [ [[DOTPRE]], [[FOR_BODY_LR_PH]] ], [ [[I_UNR_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA_LOOPEXIT]] ]
370 ; CHECK-NEXT: [[J_027_UNR:%.*]] = phi i32 [ 1, [[FOR_BODY_LR_PH]] ], [ [[J_027_UNR_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA_LOOPEXIT]] ]
371 ; CHECK-NEXT: [[TEMP_026_UNR:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH]] ], [ [[TEMP_026_UNR_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA_LOOPEXIT]] ]
372 ; CHECK-NEXT: [[LCMP_MOD:%.*]] = icmp ne i32 [[XTRAITER]], 0
373 ; CHECK-NEXT: br i1 [[LCMP_MOD]], label [[FOR_BODY_EPIL_PREHEADER:%.*]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]]
374 ; CHECK: for.body.epil.preheader:
375 ; CHECK-NEXT: br label [[FOR_BODY_EPIL:%.*]]
376 ; CHECK: for.body.epil:
377 ; CHECK-NEXT: [[ARRAYIDX_EPIL:%.*]] = getelementptr inbounds i32, ptr [[CONDITION:%.*]], i32 [[J_027_UNR]]
378 ; CHECK-NEXT: [[I1_EPIL:%.*]] = load i32, ptr [[ARRAYIDX_EPIL]], align 4
379 ; CHECK-NEXT: [[CMP1_EPIL:%.*]] = icmp ugt i32 [[I1_EPIL]], 65535
380 ; CHECK-NEXT: [[ARRAYIDX2_EPIL:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[J_027_UNR]]
381 ; CHECK-NEXT: [[I2_EPIL:%.*]] = load i32, ptr [[ARRAYIDX2_EPIL]], align 4
382 ; CHECK-NEXT: [[CMP4_EPIL:%.*]] = icmp ugt i32 [[I2_EPIL]], [[I_UNR]]
383 ; CHECK-NEXT: br i1 [[CMP1_EPIL]], label [[IF_THEN_EPIL:%.*]], label [[IF_ELSE_EPIL:%.*]]
384 ; CHECK: if.else.epil:
385 ; CHECK-NEXT: [[NOT_CMP4_EPIL:%.*]] = xor i1 [[CMP4_EPIL]], true
386 ; CHECK-NEXT: [[SUB_EPIL:%.*]] = sext i1 [[NOT_CMP4_EPIL]] to i32
387 ; CHECK-NEXT: [[SUB10_SINK_EPIL:%.*]] = add i32 [[J_027_UNR]], [[SUB_EPIL]]
388 ; CHECK-NEXT: [[ARRAYIDX11_EPIL:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[SUB10_SINK_EPIL]]
389 ; CHECK-NEXT: [[I3_EPIL:%.*]] = load i32, ptr [[ARRAYIDX11_EPIL]], align 4
390 ; CHECK-NEXT: [[SUB13_EPIL:%.*]] = sub i32 [[TEMP_026_UNR]], [[I3_EPIL]]
391 ; CHECK-NEXT: br label [[FOR_INC_EPIL:%.*]]
392 ; CHECK: if.then.epil:
393 ; CHECK-NEXT: [[COND_EPIL:%.*]] = zext i1 [[CMP4_EPIL]] to i32
394 ; CHECK-NEXT: [[ADD_EPIL:%.*]] = add i32 [[TEMP_026_UNR]], [[COND_EPIL]]
395 ; CHECK-NEXT: br label [[FOR_INC_EPIL]]
396 ; CHECK: for.inc.epil:
397 ; CHECK-NEXT: [[TEMP_1_EPIL:%.*]] = phi i32 [ [[ADD_EPIL]], [[IF_THEN_EPIL]] ], [ [[SUB13_EPIL]], [[IF_ELSE_EPIL]] ]
398 ; CHECK-NEXT: [[INC_EPIL:%.*]] = add nuw i32 [[J_027_UNR]], 1
399 ; CHECK-NEXT: [[EPIL_ITER_CMP:%.*]] = icmp ne i32 1, [[XTRAITER]]
400 ; CHECK-NEXT: br i1 [[EPIL_ITER_CMP]], label [[FOR_BODY_EPIL_1:%.*]], label [[FOR_COND_CLEANUP_LOOPEXIT_EPILOG_LCSSA:%.*]]
401 ; CHECK: for.body.epil.1:
402 ; CHECK-NEXT: [[ARRAYIDX_EPIL_1:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_EPIL]]
403 ; CHECK-NEXT: [[I1_EPIL_1:%.*]] = load i32, ptr [[ARRAYIDX_EPIL_1]], align 4
404 ; CHECK-NEXT: [[CMP1_EPIL_1:%.*]] = icmp ugt i32 [[I1_EPIL_1]], 65535
405 ; CHECK-NEXT: [[ARRAYIDX2_EPIL_1:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_EPIL]]
406 ; CHECK-NEXT: [[I2_EPIL_1:%.*]] = load i32, ptr [[ARRAYIDX2_EPIL_1]], align 4
407 ; CHECK-NEXT: [[CMP4_EPIL_1:%.*]] = icmp ugt i32 [[I2_EPIL_1]], [[I2_EPIL]]
408 ; CHECK-NEXT: br i1 [[CMP1_EPIL_1]], label [[IF_THEN_EPIL_1:%.*]], label [[IF_ELSE_EPIL_1:%.*]]
409 ; CHECK: if.else.epil.1:
410 ; CHECK-NEXT: [[NOT_CMP4_EPIL_1:%.*]] = xor i1 [[CMP4_EPIL_1]], true
411 ; CHECK-NEXT: [[SUB_EPIL_1:%.*]] = sext i1 [[NOT_CMP4_EPIL_1]] to i32
412 ; CHECK-NEXT: [[SUB10_SINK_EPIL_1:%.*]] = add i32 [[INC_EPIL]], [[SUB_EPIL_1]]
413 ; CHECK-NEXT: [[ARRAYIDX11_EPIL_1:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[SUB10_SINK_EPIL_1]]
414 ; CHECK-NEXT: [[I3_EPIL_1:%.*]] = load i32, ptr [[ARRAYIDX11_EPIL_1]], align 4
415 ; CHECK-NEXT: [[SUB13_EPIL_1:%.*]] = sub i32 [[TEMP_1_EPIL]], [[I3_EPIL_1]]
416 ; CHECK-NEXT: br label [[FOR_INC_EPIL_1:%.*]]
417 ; CHECK: if.then.epil.1:
418 ; CHECK-NEXT: [[COND_EPIL_1:%.*]] = zext i1 [[CMP4_EPIL_1]] to i32
419 ; CHECK-NEXT: [[ADD_EPIL_1:%.*]] = add i32 [[TEMP_1_EPIL]], [[COND_EPIL_1]]
420 ; CHECK-NEXT: br label [[FOR_INC_EPIL_1]]
421 ; CHECK: for.inc.epil.1:
422 ; CHECK-NEXT: [[TEMP_1_EPIL_1:%.*]] = phi i32 [ [[ADD_EPIL_1]], [[IF_THEN_EPIL_1]] ], [ [[SUB13_EPIL_1]], [[IF_ELSE_EPIL_1]] ]
423 ; CHECK-NEXT: [[INC_EPIL_1:%.*]] = add nuw i32 [[J_027_UNR]], 2
424 ; CHECK-NEXT: [[EPIL_ITER_CMP_1:%.*]] = icmp ne i32 2, [[XTRAITER]]
425 ; CHECK-NEXT: br i1 [[EPIL_ITER_CMP_1]], label [[FOR_BODY_EPIL_2:%.*]], label [[FOR_COND_CLEANUP_LOOPEXIT_EPILOG_LCSSA]]
426 ; CHECK: for.body.epil.2:
427 ; CHECK-NEXT: [[ARRAYIDX_EPIL_2:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_EPIL_1]]
428 ; CHECK-NEXT: [[I1_EPIL_2:%.*]] = load i32, ptr [[ARRAYIDX_EPIL_2]], align 4
429 ; CHECK-NEXT: [[CMP1_EPIL_2:%.*]] = icmp ugt i32 [[I1_EPIL_2]], 65535
430 ; CHECK-NEXT: [[ARRAYIDX2_EPIL_2:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_EPIL_1]]
431 ; CHECK-NEXT: [[I2_EPIL_2:%.*]] = load i32, ptr [[ARRAYIDX2_EPIL_2]], align 4
432 ; CHECK-NEXT: [[CMP4_EPIL_2:%.*]] = icmp ugt i32 [[I2_EPIL_2]], [[I2_EPIL_1]]
433 ; CHECK-NEXT: br i1 [[CMP1_EPIL_2]], label [[IF_THEN_EPIL_2:%.*]], label [[IF_ELSE_EPIL_2:%.*]]
434 ; CHECK: if.else.epil.2:
435 ; CHECK-NEXT: [[NOT_CMP4_EPIL_2:%.*]] = xor i1 [[CMP4_EPIL_2]], true
436 ; CHECK-NEXT: [[SUB_EPIL_2:%.*]] = sext i1 [[NOT_CMP4_EPIL_2]] to i32
437 ; CHECK-NEXT: [[SUB10_SINK_EPIL_2:%.*]] = add i32 [[INC_EPIL_1]], [[SUB_EPIL_2]]
438 ; CHECK-NEXT: [[ARRAYIDX11_EPIL_2:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[SUB10_SINK_EPIL_2]]
439 ; CHECK-NEXT: [[I3_EPIL_2:%.*]] = load i32, ptr [[ARRAYIDX11_EPIL_2]], align 4
440 ; CHECK-NEXT: [[SUB13_EPIL_2:%.*]] = sub i32 [[TEMP_1_EPIL_1]], [[I3_EPIL_2]]
441 ; CHECK-NEXT: br label [[FOR_INC_EPIL_2:%.*]]
442 ; CHECK: if.then.epil.2:
443 ; CHECK-NEXT: [[COND_EPIL_2:%.*]] = zext i1 [[CMP4_EPIL_2]] to i32
444 ; CHECK-NEXT: [[ADD_EPIL_2:%.*]] = add i32 [[TEMP_1_EPIL_1]], [[COND_EPIL_2]]
445 ; CHECK-NEXT: br label [[FOR_INC_EPIL_2]]
446 ; CHECK: for.inc.epil.2:
447 ; CHECK-NEXT: [[TEMP_1_EPIL_2:%.*]] = phi i32 [ [[ADD_EPIL_2]], [[IF_THEN_EPIL_2]] ], [ [[SUB13_EPIL_2]], [[IF_ELSE_EPIL_2]] ]
448 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT_EPILOG_LCSSA]]
449 ; CHECK: for.cond.cleanup.loopexit.epilog-lcssa:
450 ; CHECK-NEXT: [[TEMP_1_LCSSA_PH1:%.*]] = phi i32 [ [[TEMP_1_EPIL]], [[FOR_INC_EPIL]] ], [ [[TEMP_1_EPIL_1]], [[FOR_INC_EPIL_1]] ], [ [[TEMP_1_EPIL_2]], [[FOR_INC_EPIL_2]] ]
451 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP_LOOPEXIT]]
452 ; CHECK: for.cond.cleanup.loopexit:
453 ; CHECK-NEXT: [[TEMP_1_LCSSA:%.*]] = phi i32 [ [[TEMP_1_LCSSA_PH]], [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA]] ], [ [[TEMP_1_LCSSA_PH1]], [[FOR_COND_CLEANUP_LOOPEXIT_EPILOG_LCSSA]] ]
454 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
455 ; CHECK: for.cond.cleanup:
456 ; CHECK-NEXT: [[TEMP_0_LCSSA:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[TEMP_1_LCSSA]], [[FOR_COND_CLEANUP_LOOPEXIT]] ]
457 ; CHECK-NEXT: store i32 [[TEMP_0_LCSSA]], ptr [[OUTPUT:%.*]], align 4
458 ; CHECK-NEXT: ret void
460 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[DOTPRE]], [[FOR_BODY_LR_PH_NEW]] ], [ [[I2_3]], [[FOR_INC_3]] ]
461 ; CHECK-NEXT: [[J_027:%.*]] = phi i32 [ 1, [[FOR_BODY_LR_PH_NEW]] ], [ [[INC_3]], [[FOR_INC_3]] ]
462 ; CHECK-NEXT: [[TEMP_026:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH_NEW]] ], [ [[TEMP_1_3]], [[FOR_INC_3]] ]
463 ; CHECK-NEXT: [[NITER:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH_NEW]] ], [ [[NITER_NEXT_3:%.*]], [[FOR_INC_3]] ]
464 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[J_027]]
465 ; CHECK-NEXT: [[I1:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
466 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[I1]], 65535
467 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[J_027]]
468 ; CHECK-NEXT: [[I2:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
469 ; CHECK-NEXT: [[CMP4:%.*]] = icmp ugt i32 [[I2]], [[I]]
470 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
472 ; CHECK-NEXT: [[COND:%.*]] = zext i1 [[CMP4]] to i32
473 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[TEMP_026]], [[COND]]
474 ; CHECK-NEXT: br label [[FOR_INC:%.*]]
476 ; CHECK-NEXT: [[NOT_CMP4:%.*]] = xor i1 [[CMP4]], true
477 ; CHECK-NEXT: [[SUB:%.*]] = sext i1 [[NOT_CMP4]] to i32
478 ; CHECK-NEXT: [[SUB10_SINK:%.*]] = add i32 [[J_027]], [[SUB]]
479 ; CHECK-NEXT: [[ARRAYIDX11:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[SUB10_SINK]]
480 ; CHECK-NEXT: [[I3:%.*]] = load i32, ptr [[ARRAYIDX11]], align 4
481 ; CHECK-NEXT: [[SUB13:%.*]] = sub i32 [[TEMP_026]], [[I3]]
482 ; CHECK-NEXT: br label [[FOR_INC]]
484 ; CHECK-NEXT: [[TEMP_1:%.*]] = phi i32 [ [[ADD]], [[IF_THEN]] ], [ [[SUB13]], [[IF_ELSE]] ]
485 ; CHECK-NEXT: [[INC:%.*]] = add nuw nsw i32 [[J_027]], 1
486 ; CHECK-NEXT: [[ARRAYIDX_1:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC]]
487 ; CHECK-NEXT: [[I1_1:%.*]] = load i32, ptr [[ARRAYIDX_1]], align 4
488 ; CHECK-NEXT: [[CMP1_1:%.*]] = icmp ugt i32 [[I1_1]], 65535
489 ; CHECK-NEXT: [[ARRAYIDX2_1:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC]]
490 ; CHECK-NEXT: [[I2_1:%.*]] = load i32, ptr [[ARRAYIDX2_1]], align 4
491 ; CHECK-NEXT: [[CMP4_1:%.*]] = icmp ugt i32 [[I2_1]], [[I2]]
492 ; CHECK-NEXT: br i1 [[CMP1_1]], label [[IF_THEN_1:%.*]], label [[IF_ELSE_1:%.*]]
494 ; CHECK-NEXT: [[NOT_CMP4_1:%.*]] = xor i1 [[CMP4_1]], true
495 ; CHECK-NEXT: [[SUB_1:%.*]] = sext i1 [[NOT_CMP4_1]] to i32
496 ; CHECK-NEXT: [[SUB10_SINK_1:%.*]] = add i32 [[INC]], [[SUB_1]]
497 ; CHECK-NEXT: [[ARRAYIDX11_1:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[SUB10_SINK_1]]
498 ; CHECK-NEXT: [[I3_1:%.*]] = load i32, ptr [[ARRAYIDX11_1]], align 4
499 ; CHECK-NEXT: [[SUB13_1:%.*]] = sub i32 [[TEMP_1]], [[I3_1]]
500 ; CHECK-NEXT: br label [[FOR_INC_1:%.*]]
502 ; CHECK-NEXT: [[COND_1:%.*]] = zext i1 [[CMP4_1]] to i32
503 ; CHECK-NEXT: [[ADD_1:%.*]] = add i32 [[TEMP_1]], [[COND_1]]
504 ; CHECK-NEXT: br label [[FOR_INC_1]]
506 ; CHECK-NEXT: [[TEMP_1_1:%.*]] = phi i32 [ [[ADD_1]], [[IF_THEN_1]] ], [ [[SUB13_1]], [[IF_ELSE_1]] ]
507 ; CHECK-NEXT: [[INC_1:%.*]] = add nuw nsw i32 [[J_027]], 2
508 ; CHECK-NEXT: [[ARRAYIDX_2:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_1]]
509 ; CHECK-NEXT: [[I1_2:%.*]] = load i32, ptr [[ARRAYIDX_2]], align 4
510 ; CHECK-NEXT: [[CMP1_2:%.*]] = icmp ugt i32 [[I1_2]], 65535
511 ; CHECK-NEXT: [[ARRAYIDX2_2:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_1]]
512 ; CHECK-NEXT: [[I2_2:%.*]] = load i32, ptr [[ARRAYIDX2_2]], align 4
513 ; CHECK-NEXT: [[CMP4_2:%.*]] = icmp ugt i32 [[I2_2]], [[I2_1]]
514 ; CHECK-NEXT: br i1 [[CMP1_2]], label [[IF_THEN_2:%.*]], label [[IF_ELSE_2:%.*]]
516 ; CHECK-NEXT: [[NOT_CMP4_2:%.*]] = xor i1 [[CMP4_2]], true
517 ; CHECK-NEXT: [[SUB_2:%.*]] = sext i1 [[NOT_CMP4_2]] to i32
518 ; CHECK-NEXT: [[SUB10_SINK_2:%.*]] = add i32 [[INC_1]], [[SUB_2]]
519 ; CHECK-NEXT: [[ARRAYIDX11_2:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[SUB10_SINK_2]]
520 ; CHECK-NEXT: [[I3_2:%.*]] = load i32, ptr [[ARRAYIDX11_2]], align 4
521 ; CHECK-NEXT: [[SUB13_2:%.*]] = sub i32 [[TEMP_1_1]], [[I3_2]]
522 ; CHECK-NEXT: br label [[FOR_INC_2:%.*]]
524 ; CHECK-NEXT: [[COND_2:%.*]] = zext i1 [[CMP4_2]] to i32
525 ; CHECK-NEXT: [[ADD_2:%.*]] = add i32 [[TEMP_1_1]], [[COND_2]]
526 ; CHECK-NEXT: br label [[FOR_INC_2]]
528 ; CHECK-NEXT: [[TEMP_1_2:%.*]] = phi i32 [ [[ADD_2]], [[IF_THEN_2]] ], [ [[SUB13_2]], [[IF_ELSE_2]] ]
529 ; CHECK-NEXT: [[INC_2:%.*]] = add nuw i32 [[J_027]], 3
530 ; CHECK-NEXT: [[ARRAYIDX_3:%.*]] = getelementptr inbounds i32, ptr [[CONDITION]], i32 [[INC_2]]
531 ; CHECK-NEXT: [[I1_3:%.*]] = load i32, ptr [[ARRAYIDX_3]], align 4
532 ; CHECK-NEXT: [[CMP1_3:%.*]] = icmp ugt i32 [[I1_3]], 65535
533 ; CHECK-NEXT: [[ARRAYIDX2_3:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[INC_2]]
534 ; CHECK-NEXT: [[I2_3]] = load i32, ptr [[ARRAYIDX2_3]], align 4
535 ; CHECK-NEXT: [[CMP4_3:%.*]] = icmp ugt i32 [[I2_3]], [[I2_2]]
536 ; CHECK-NEXT: br i1 [[CMP1_3]], label [[IF_THEN_3:%.*]], label [[IF_ELSE_3:%.*]]
538 ; CHECK-NEXT: [[NOT_CMP4_3:%.*]] = xor i1 [[CMP4_3]], true
539 ; CHECK-NEXT: [[SUB_3:%.*]] = sext i1 [[NOT_CMP4_3]] to i32
540 ; CHECK-NEXT: [[SUB10_SINK_3:%.*]] = add i32 [[INC_2]], [[SUB_3]]
541 ; CHECK-NEXT: [[ARRAYIDX11_3:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[SUB10_SINK_3]]
542 ; CHECK-NEXT: [[I3_3:%.*]] = load i32, ptr [[ARRAYIDX11_3]], align 4
543 ; CHECK-NEXT: [[SUB13_3:%.*]] = sub i32 [[TEMP_1_2]], [[I3_3]]
544 ; CHECK-NEXT: br label [[FOR_INC_3]]
546 ; CHECK-NEXT: [[COND_3:%.*]] = zext i1 [[CMP4_3]] to i32
547 ; CHECK-NEXT: [[ADD_3:%.*]] = add i32 [[TEMP_1_2]], [[COND_3]]
548 ; CHECK-NEXT: br label [[FOR_INC_3]]
550 ; CHECK-NEXT: [[TEMP_1_3]] = phi i32 [ [[ADD_3]], [[IF_THEN_3]] ], [ [[SUB13_3]], [[IF_ELSE_3]] ]
551 ; CHECK-NEXT: [[INC_3]] = add nuw i32 [[J_027]], 4
552 ; CHECK-NEXT: [[NITER_NEXT_3]] = add i32 [[NITER]], 4
553 ; CHECK-NEXT: [[NITER_NCMP_3:%.*]] = icmp eq i32 [[NITER_NEXT_3]], [[UNROLL_ITER]]
554 ; CHECK-NEXT: br i1 [[NITER_NCMP_3]], label [[FOR_COND_CLEANUP_LOOPEXIT_UNR_LCSSA_LOOPEXIT]], label [[FOR_BODY]]
557 %cmp25 = icmp ugt i32 %MaxJ, 1
558 br i1 %cmp25, label %for.body.lr.ph, label %for.cond.cleanup
560 for.body.lr.ph: ; preds = %entry
561 %.pre = load i32, ptr %Input, align 4
564 for.cond.cleanup: ; preds = %for.inc, %entry
565 %temp.0.lcssa = phi i32 [ 0, %entry ], [ %temp.1, %for.inc ]
566 store i32 %temp.0.lcssa, ptr %Output, align 4
569 for.body: ; preds = %for.inc, %for.body.lr.ph
570 %i = phi i32 [ %.pre, %for.body.lr.ph ], [ %i2, %for.inc ]
571 %j.027 = phi i32 [ 1, %for.body.lr.ph ], [ %inc, %for.inc ]
572 %temp.026 = phi i32 [ 0, %for.body.lr.ph ], [ %temp.1, %for.inc ]
573 %arrayidx = getelementptr inbounds i32, ptr %Condition, i32 %j.027
574 %i1 = load i32, ptr %arrayidx, align 4
575 %cmp1 = icmp ugt i32 %i1, 65535
576 %arrayidx2 = getelementptr inbounds i32, ptr %Input, i32 %j.027
577 %i2 = load i32, ptr %arrayidx2, align 4
578 %cmp4 = icmp ugt i32 %i2, %i
579 br i1 %cmp1, label %if.then, label %if.else
581 if.then: ; preds = %for.body
582 %cond = zext i1 %cmp4 to i32
583 %add = add i32 %temp.026, %cond
586 if.else: ; preds = %for.body
587 %not.cmp4 = xor i1 %cmp4, true
588 %sub = sext i1 %not.cmp4 to i32
589 %sub10.sink = add i32 %j.027, %sub
590 %arrayidx11 = getelementptr inbounds i32, ptr %Input, i32 %sub10.sink
591 %i3 = load i32, ptr %arrayidx11, align 4
592 %sub13 = sub i32 %temp.026, %i3
595 for.inc: ; preds = %if.else, %if.then
596 %temp.1 = phi i32 [ %add, %if.then ], [ %sub13, %if.else ]
597 %inc = add nuw i32 %j.027, 1
598 %exitcond = icmp eq i32 %inc, %MaxJ
599 br i1 %exitcond, label %for.cond.cleanup, label %for.body
602 define void @test_five_blocks(ptr nocapture %Output, ptr nocapture readonly %Condition, ptr nocapture readonly %Input, i32 %MaxJ) {
603 ; CHECK-LABEL: @test_five_blocks(
605 ; CHECK-NEXT: [[CMP24:%.*]] = icmp ugt i32 [[MAXJ:%.*]], 1
606 ; CHECK-NEXT: br i1 [[CMP24]], label [[FOR_BODY_PREHEADER:%.*]], label [[CLEANUP:%.*]]
607 ; CHECK: for.body.preheader:
608 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
610 ; CHECK-NEXT: [[J_026:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_INC:%.*]] ], [ 1, [[FOR_BODY_PREHEADER]] ]
611 ; CHECK-NEXT: [[TEMP_025:%.*]] = phi i32 [ [[TEMP_1:%.*]], [[FOR_INC]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
612 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[INPUT:%.*]], i32 [[J_026]]
613 ; CHECK-NEXT: [[I:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
614 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[I]], [[TEMP_025]]
615 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[ADD]], 16777215
616 ; CHECK-NEXT: br i1 [[CMP1]], label [[CLEANUP_LOOPEXIT:%.*]], label [[IF_END:%.*]]
618 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds i32, ptr [[CONDITION:%.*]], i32 [[J_026]]
619 ; CHECK-NEXT: [[I1:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
620 ; CHECK-NEXT: [[CMP3:%.*]] = icmp ugt i32 [[I1]], 65535
621 ; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN4:%.*]], label [[IF_ELSE:%.*]]
623 ; CHECK-NEXT: [[SUB:%.*]] = add i32 [[J_026]], -1
624 ; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds i32, ptr [[INPUT]], i32 [[SUB]]
625 ; CHECK-NEXT: [[I2:%.*]] = load i32, ptr [[ARRAYIDX6]], align 4
626 ; CHECK-NEXT: [[CMP7:%.*]] = icmp ugt i32 [[I]], [[I2]]
627 ; CHECK-NEXT: [[COND:%.*]] = zext i1 [[CMP7]] to i32
628 ; CHECK-NEXT: [[ADD8:%.*]] = add i32 [[ADD]], [[COND]]
629 ; CHECK-NEXT: br label [[FOR_INC]]
631 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[ADD]], [[I]]
632 ; CHECK-NEXT: br label [[FOR_INC]]
634 ; CHECK-NEXT: [[TEMP_1]] = phi i32 [ [[ADD8]], [[IF_THEN4]] ], [ [[AND]], [[IF_ELSE]] ]
635 ; CHECK-NEXT: [[INC]] = add nuw i32 [[J_026]], 1
636 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[INC]], [[MAXJ]]
637 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[CLEANUP_LOOPEXIT]]
638 ; CHECK: cleanup.loopexit:
639 ; CHECK-NEXT: [[TEMP_2_PH:%.*]] = phi i32 [ [[TEMP_1]], [[FOR_INC]] ], [ [[ADD]], [[FOR_BODY]] ]
640 ; CHECK-NEXT: br label [[CLEANUP]]
642 ; CHECK-NEXT: [[TEMP_2:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[TEMP_2_PH]], [[CLEANUP_LOOPEXIT]] ]
643 ; CHECK-NEXT: store i32 [[TEMP_2]], ptr [[OUTPUT:%.*]], align 4
644 ; CHECK-NEXT: ret void
647 %cmp24 = icmp ugt i32 %MaxJ, 1
648 br i1 %cmp24, label %for.body.preheader, label %cleanup
650 for.body.preheader: ; preds = %entry
653 for.body: ; preds = %for.inc, %for.body.preheader
654 %j.026 = phi i32 [ %inc, %for.inc ], [ 1, %for.body.preheader ]
655 %temp.025 = phi i32 [ %temp.1, %for.inc ], [ 0, %for.body.preheader ]
656 %arrayidx = getelementptr inbounds i32, ptr %Input, i32 %j.026
657 %i = load i32, ptr %arrayidx, align 4
658 %add = add i32 %i, %temp.025
659 %cmp1 = icmp ugt i32 %add, 16777215
660 br i1 %cmp1, label %cleanup, label %if.end
662 if.end: ; preds = %for.body
663 %arrayidx2 = getelementptr inbounds i32, ptr %Condition, i32 %j.026
664 %i1 = load i32, ptr %arrayidx2, align 4
665 %cmp3 = icmp ugt i32 %i1, 65535
666 br i1 %cmp3, label %if.then4, label %if.else
668 if.then4: ; preds = %if.end
669 %sub = add i32 %j.026, -1
670 %arrayidx6 = getelementptr inbounds i32, ptr %Input, i32 %sub
671 %i2 = load i32, ptr %arrayidx6, align 4
672 %cmp7 = icmp ugt i32 %i, %i2
673 %cond = zext i1 %cmp7 to i32
674 %add8 = add i32 %add, %cond
677 if.else: ; preds = %if.end
678 %and = and i32 %add, %i
681 for.inc: ; preds = %if.else, %if.then4
682 %temp.1 = phi i32 [ %add8, %if.then4 ], [ %and, %if.else ]
683 %inc = add nuw i32 %j.026, 1
684 %cmp = icmp ult i32 %inc, %MaxJ
685 br i1 %cmp, label %for.body, label %cleanup
687 cleanup: ; preds = %for.inc, %for.body, %entry
688 %temp.2 = phi i32 [ 0, %entry ], [ %add, %for.body ], [ %temp.1, %for.inc ]
689 store i32 %temp.2, ptr %Output, align 4
693 %struct.Node = type { ptr, i32 }
694 define void @iterate_inc(ptr %n, i32 %limit) {
695 ; CHECK-LABEL: @iterate_inc(
697 ; CHECK-NEXT: [[TOBOOL5:%.*]] = icmp eq ptr [[N:%.*]], null
698 ; CHECK-NEXT: br i1 [[TOBOOL5]], label [[WHILE_END:%.*]], label [[LAND_RHS_PREHEADER:%.*]]
699 ; CHECK: land.rhs.preheader:
700 ; CHECK-NEXT: br label [[LAND_RHS:%.*]]
702 ; CHECK-NEXT: [[LIST_ADDR_06:%.*]] = phi ptr [ [[N]], [[LAND_RHS_PREHEADER]] ], [ [[I2_3:%.*]], [[WHILE_BODY_3:%.*]] ]
703 ; CHECK-NEXT: [[VAL:%.*]] = getelementptr inbounds [[STRUCT_NODE:%.*]], ptr [[LIST_ADDR_06]], i32 0, i32 1
704 ; CHECK-NEXT: [[I:%.*]] = load i32, ptr [[VAL]], align 4
705 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I]], [[LIMIT:%.*]]
706 ; CHECK-NEXT: br i1 [[CMP]], label [[WHILE_BODY:%.*]], label [[WHILE_END_LOOPEXIT:%.*]]
708 ; CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[I]], 1
709 ; CHECK-NEXT: store i32 [[INC]], ptr [[VAL]], align 4
710 ; CHECK-NEXT: [[I2:%.*]] = load ptr, ptr [[LIST_ADDR_06]], align 4
711 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq ptr [[I2]], null
712 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[WHILE_END_LOOPEXIT]], label [[LAND_RHS_1:%.*]]
714 ; CHECK-NEXT: [[VAL_1:%.*]] = getelementptr inbounds [[STRUCT_NODE]], ptr [[I2]], i32 0, i32 1
715 ; CHECK-NEXT: [[I_1:%.*]] = load i32, ptr [[VAL_1]], align 4
716 ; CHECK-NEXT: [[CMP_1:%.*]] = icmp slt i32 [[I_1]], [[LIMIT]]
717 ; CHECK-NEXT: br i1 [[CMP_1]], label [[WHILE_BODY_1:%.*]], label [[WHILE_END_LOOPEXIT]]
718 ; CHECK: while.body.1:
719 ; CHECK-NEXT: [[INC_1:%.*]] = add nsw i32 [[I_1]], 1
720 ; CHECK-NEXT: store i32 [[INC_1]], ptr [[VAL_1]], align 4
721 ; CHECK-NEXT: [[I2_1:%.*]] = load ptr, ptr [[I2]], align 4
722 ; CHECK-NEXT: [[TOBOOL_1:%.*]] = icmp eq ptr [[I2_1]], null
723 ; CHECK-NEXT: br i1 [[TOBOOL_1]], label [[WHILE_END_LOOPEXIT]], label [[LAND_RHS_2:%.*]]
725 ; CHECK-NEXT: [[VAL_2:%.*]] = getelementptr inbounds [[STRUCT_NODE]], ptr [[I2_1]], i32 0, i32 1
726 ; CHECK-NEXT: [[I_2:%.*]] = load i32, ptr [[VAL_2]], align 4
727 ; CHECK-NEXT: [[CMP_2:%.*]] = icmp slt i32 [[I_2]], [[LIMIT]]
728 ; CHECK-NEXT: br i1 [[CMP_2]], label [[WHILE_BODY_2:%.*]], label [[WHILE_END_LOOPEXIT]]
729 ; CHECK: while.body.2:
730 ; CHECK-NEXT: [[INC_2:%.*]] = add nsw i32 [[I_2]], 1
731 ; CHECK-NEXT: store i32 [[INC_2]], ptr [[VAL_2]], align 4
732 ; CHECK-NEXT: [[I2_2:%.*]] = load ptr, ptr [[I2_1]], align 4
733 ; CHECK-NEXT: [[TOBOOL_2:%.*]] = icmp eq ptr [[I2_2]], null
734 ; CHECK-NEXT: br i1 [[TOBOOL_2]], label [[WHILE_END_LOOPEXIT]], label [[LAND_RHS_3:%.*]]
736 ; CHECK-NEXT: [[VAL_3:%.*]] = getelementptr inbounds [[STRUCT_NODE]], ptr [[I2_2]], i32 0, i32 1
737 ; CHECK-NEXT: [[I_3:%.*]] = load i32, ptr [[VAL_3]], align 4
738 ; CHECK-NEXT: [[CMP_3:%.*]] = icmp slt i32 [[I_3]], [[LIMIT]]
739 ; CHECK-NEXT: br i1 [[CMP_3]], label [[WHILE_BODY_3]], label [[WHILE_END_LOOPEXIT]]
740 ; CHECK: while.body.3:
741 ; CHECK-NEXT: [[INC_3:%.*]] = add nsw i32 [[I_3]], 1
742 ; CHECK-NEXT: store i32 [[INC_3]], ptr [[VAL_3]], align 4
743 ; CHECK-NEXT: [[I2_3]] = load ptr, ptr [[I2_2]], align 4
744 ; CHECK-NEXT: [[TOBOOL_3:%.*]] = icmp eq ptr [[I2_3]], null
745 ; CHECK-NEXT: br i1 [[TOBOOL_3]], label [[WHILE_END_LOOPEXIT]], label [[LAND_RHS]]
746 ; CHECK: while.end.loopexit:
747 ; CHECK-NEXT: br label [[WHILE_END]]
749 ; CHECK-NEXT: ret void
752 %tobool5 = icmp eq ptr %n, null
753 br i1 %tobool5, label %while.end, label %land.rhs.preheader
755 land.rhs.preheader: ; preds = %entry
758 land.rhs: ; preds = %while.body, %land.rhs.preheader
759 %list.addr.06 = phi ptr [ %i2, %while.body ], [ %n, %land.rhs.preheader ]
760 %val = getelementptr inbounds %struct.Node, ptr %list.addr.06, i32 0, i32 1
761 %i = load i32, ptr %val, align 4
762 %cmp = icmp slt i32 %i, %limit
763 br i1 %cmp, label %while.body, label %while.end
765 while.body: ; preds = %land.rhs
766 %inc = add nsw i32 %i, 1
767 store i32 %inc, ptr %val, align 4
768 %i2 = load ptr, ptr %list.addr.06, align 4
769 %tobool = icmp eq ptr %i2, null
770 br i1 %tobool, label %while.end, label %land.rhs
772 while.end: ; preds = %while.body, %land.rhs, %entry