1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -loop-predication < %s 2>&1 | FileCheck %s
3 ; RUN: opt -S -passes='require<scalar-evolution>,loop(loop-predication)' < %s 2>&1 | FileCheck %s
5 declare void @llvm.experimental.guard(i1, ...)
7 define i32 @signed_loop_0_to_n_nested_0_to_l_inner_index_check(i32* %array, i32 %length, i32 %n, i32 %l) {
8 ; CHECK-LABEL: @signed_loop_0_to_n_nested_0_to_l_inner_index_check(
10 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
11 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[OUTER_LOOP_PREHEADER:%.*]]
12 ; CHECK: outer.loop.preheader:
13 ; CHECK-NEXT: br label [[OUTER_LOOP:%.*]]
15 ; CHECK-NEXT: [[OUTER_LOOP_ACC:%.*]] = phi i32 [ [[OUTER_LOOP_ACC_NEXT:%.*]], [[OUTER_LOOP_INC:%.*]] ], [ 0, [[OUTER_LOOP_PREHEADER]] ]
16 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[OUTER_LOOP_INC]] ], [ 0, [[OUTER_LOOP_PREHEADER]] ]
17 ; CHECK-NEXT: [[TMP6:%.*]] = icmp sle i32 [[L:%.*]], 0
18 ; CHECK-NEXT: br i1 [[TMP6]], label [[OUTER_LOOP_INC]], label [[INNER_LOOP_PREHEADER:%.*]]
19 ; CHECK: inner.loop.preheader:
20 ; CHECK-NEXT: [[TMP0:%.*]] = icmp sle i32 [[L]], [[LENGTH:%.*]]
21 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
22 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
23 ; CHECK-NEXT: br label [[INNER_LOOP:%.*]]
25 ; CHECK-NEXT: [[INNER_LOOP_ACC:%.*]] = phi i32 [ [[INNER_LOOP_ACC_NEXT:%.*]], [[INNER_LOOP]] ], [ [[OUTER_LOOP_ACC]], [[INNER_LOOP_PREHEADER]] ]
26 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[INNER_LOOP]] ], [ 0, [[INNER_LOOP_PREHEADER]] ]
27 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[TMP2]], i32 9) [ "deopt"() ]
28 ; CHECK-NEXT: [[J_I64:%.*]] = zext i32 [[J]] to i64
29 ; CHECK-NEXT: [[ARRAY_J_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[J_I64]]
30 ; CHECK-NEXT: [[ARRAY_J:%.*]] = load i32, i32* [[ARRAY_J_PTR]], align 4
31 ; CHECK-NEXT: [[INNER_LOOP_ACC_NEXT]] = add i32 [[INNER_LOOP_ACC]], [[ARRAY_J]]
32 ; CHECK-NEXT: [[J_NEXT]] = add nsw i32 [[J]], 1
33 ; CHECK-NEXT: [[INNER_CONTINUE:%.*]] = icmp slt i32 [[J_NEXT]], [[L]]
34 ; CHECK-NEXT: br i1 [[INNER_CONTINUE]], label [[INNER_LOOP]], label [[OUTER_LOOP_INC_LOOPEXIT:%.*]]
35 ; CHECK: outer.loop.inc.loopexit:
36 ; CHECK-NEXT: [[INNER_LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[INNER_LOOP_ACC_NEXT]], [[INNER_LOOP]] ]
37 ; CHECK-NEXT: br label [[OUTER_LOOP_INC]]
38 ; CHECK: outer.loop.inc:
39 ; CHECK-NEXT: [[OUTER_LOOP_ACC_NEXT]] = phi i32 [ [[OUTER_LOOP_ACC]], [[OUTER_LOOP]] ], [ [[INNER_LOOP_ACC_NEXT_LCSSA]], [[OUTER_LOOP_INC_LOOPEXIT]] ]
40 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1
41 ; CHECK-NEXT: [[OUTER_CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
42 ; CHECK-NEXT: br i1 [[OUTER_CONTINUE]], label [[OUTER_LOOP]], label [[EXIT_LOOPEXIT:%.*]]
43 ; CHECK: exit.loopexit:
44 ; CHECK-NEXT: [[OUTER_LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[OUTER_LOOP_ACC_NEXT]], [[OUTER_LOOP_INC]] ]
45 ; CHECK-NEXT: br label [[EXIT]]
47 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[OUTER_LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
48 ; CHECK-NEXT: ret i32 [[RESULT]]
51 %tmp5 = icmp sle i32 %n, 0
52 br i1 %tmp5, label %exit, label %outer.loop.preheader
58 %outer.loop.acc = phi i32 [ %outer.loop.acc.next, %outer.loop.inc ], [ 0, %outer.loop.preheader ]
59 %i = phi i32 [ %i.next, %outer.loop.inc ], [ 0, %outer.loop.preheader ]
60 %tmp6 = icmp sle i32 %l, 0
61 br i1 %tmp6, label %outer.loop.inc, label %inner.loop.preheader
67 %inner.loop.acc = phi i32 [ %inner.loop.acc.next, %inner.loop ], [ %outer.loop.acc, %inner.loop.preheader ]
68 %j = phi i32 [ %j.next, %inner.loop ], [ 0, %inner.loop.preheader ]
70 %within.bounds = icmp ult i32 %j, %length
71 call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ]
73 %j.i64 = zext i32 %j to i64
74 %array.j.ptr = getelementptr inbounds i32, i32* %array, i64 %j.i64
75 %array.j = load i32, i32* %array.j.ptr, align 4
76 %inner.loop.acc.next = add i32 %inner.loop.acc, %array.j
78 %j.next = add nsw i32 %j, 1
79 %inner.continue = icmp slt i32 %j.next, %l
80 br i1 %inner.continue, label %inner.loop, label %outer.loop.inc
83 %outer.loop.acc.next = phi i32 [ %inner.loop.acc.next, %inner.loop ], [ %outer.loop.acc, %outer.loop ]
84 %i.next = add nsw i32 %i, 1
85 %outer.continue = icmp slt i32 %i.next, %n
86 br i1 %outer.continue, label %outer.loop, label %exit
89 %result = phi i32 [ 0, %entry ], [ %outer.loop.acc.next, %outer.loop.inc ]
93 define i32 @signed_loop_0_to_n_nested_0_to_l_outer_index_check(i32* %array, i32 %length, i32 %n, i32 %l) {
94 ; CHECK-LABEL: @signed_loop_0_to_n_nested_0_to_l_outer_index_check(
96 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
97 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[OUTER_LOOP_PREHEADER:%.*]]
98 ; CHECK: outer.loop.preheader:
99 ; CHECK-NEXT: [[TMP0:%.*]] = icmp sle i32 [[N]], [[LENGTH:%.*]]
100 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
101 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
102 ; CHECK-NEXT: br label [[OUTER_LOOP:%.*]]
104 ; CHECK-NEXT: [[OUTER_LOOP_ACC:%.*]] = phi i32 [ [[OUTER_LOOP_ACC_NEXT:%.*]], [[OUTER_LOOP_INC:%.*]] ], [ 0, [[OUTER_LOOP_PREHEADER]] ]
105 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[OUTER_LOOP_INC]] ], [ 0, [[OUTER_LOOP_PREHEADER]] ]
106 ; CHECK-NEXT: [[TMP6:%.*]] = icmp sle i32 [[L:%.*]], 0
107 ; CHECK-NEXT: br i1 [[TMP6]], label [[OUTER_LOOP_INC]], label [[INNER_LOOP_PREHEADER:%.*]]
108 ; CHECK: inner.loop.preheader:
109 ; CHECK-NEXT: br label [[INNER_LOOP:%.*]]
111 ; CHECK-NEXT: [[INNER_LOOP_ACC:%.*]] = phi i32 [ [[INNER_LOOP_ACC_NEXT:%.*]], [[INNER_LOOP]] ], [ [[OUTER_LOOP_ACC]], [[INNER_LOOP_PREHEADER]] ]
112 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[INNER_LOOP]] ], [ 0, [[INNER_LOOP_PREHEADER]] ]
113 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[TMP2]], i32 9) [ "deopt"() ]
114 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
115 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
116 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
117 ; CHECK-NEXT: [[INNER_LOOP_ACC_NEXT]] = add i32 [[INNER_LOOP_ACC]], [[ARRAY_I]]
118 ; CHECK-NEXT: [[J_NEXT]] = add nsw i32 [[J]], 1
119 ; CHECK-NEXT: [[INNER_CONTINUE:%.*]] = icmp slt i32 [[J_NEXT]], [[L]]
120 ; CHECK-NEXT: br i1 [[INNER_CONTINUE]], label [[INNER_LOOP]], label [[OUTER_LOOP_INC_LOOPEXIT:%.*]]
121 ; CHECK: outer.loop.inc.loopexit:
122 ; CHECK-NEXT: [[INNER_LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[INNER_LOOP_ACC_NEXT]], [[INNER_LOOP]] ]
123 ; CHECK-NEXT: br label [[OUTER_LOOP_INC]]
124 ; CHECK: outer.loop.inc:
125 ; CHECK-NEXT: [[OUTER_LOOP_ACC_NEXT]] = phi i32 [ [[OUTER_LOOP_ACC]], [[OUTER_LOOP]] ], [ [[INNER_LOOP_ACC_NEXT_LCSSA]], [[OUTER_LOOP_INC_LOOPEXIT]] ]
126 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1
127 ; CHECK-NEXT: [[OUTER_CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
128 ; CHECK-NEXT: br i1 [[OUTER_CONTINUE]], label [[OUTER_LOOP]], label [[EXIT_LOOPEXIT:%.*]]
129 ; CHECK: exit.loopexit:
130 ; CHECK-NEXT: [[OUTER_LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[OUTER_LOOP_ACC_NEXT]], [[OUTER_LOOP_INC]] ]
131 ; CHECK-NEXT: br label [[EXIT]]
133 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[OUTER_LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
134 ; CHECK-NEXT: ret i32 [[RESULT]]
137 %tmp5 = icmp sle i32 %n, 0
138 br i1 %tmp5, label %exit, label %outer.loop.preheader
140 outer.loop.preheader:
144 %outer.loop.acc = phi i32 [ %outer.loop.acc.next, %outer.loop.inc ], [ 0, %outer.loop.preheader ]
145 %i = phi i32 [ %i.next, %outer.loop.inc ], [ 0, %outer.loop.preheader ]
146 %tmp6 = icmp sle i32 %l, 0
147 br i1 %tmp6, label %outer.loop.inc, label %inner.loop.preheader
149 inner.loop.preheader:
154 %inner.loop.acc = phi i32 [ %inner.loop.acc.next, %inner.loop ], [ %outer.loop.acc, %inner.loop.preheader ]
155 %j = phi i32 [ %j.next, %inner.loop ], [ 0, %inner.loop.preheader ]
157 %within.bounds = icmp ult i32 %i, %length
158 call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ]
160 %i.i64 = zext i32 %i to i64
161 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
162 %array.i = load i32, i32* %array.i.ptr, align 4
163 %inner.loop.acc.next = add i32 %inner.loop.acc, %array.i
165 %j.next = add nsw i32 %j, 1
166 %inner.continue = icmp slt i32 %j.next, %l
167 br i1 %inner.continue, label %inner.loop, label %outer.loop.inc
170 %outer.loop.acc.next = phi i32 [ %inner.loop.acc.next, %inner.loop ], [ %outer.loop.acc, %outer.loop ]
171 %i.next = add nsw i32 %i, 1
172 %outer.continue = icmp slt i32 %i.next, %n
173 br i1 %outer.continue, label %outer.loop, label %exit
176 %result = phi i32 [ 0, %entry ], [ %outer.loop.acc.next, %outer.loop.inc ]
180 define i32 @signed_loop_0_to_n_nested_i_to_l_inner_index_check(i32* %array, i32 %length, i32 %n, i32 %l) {
181 ; CHECK-LABEL: @signed_loop_0_to_n_nested_i_to_l_inner_index_check(
183 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
184 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[OUTER_LOOP_PREHEADER:%.*]]
185 ; CHECK: outer.loop.preheader:
186 ; CHECK-NEXT: [[TMP0:%.*]] = icmp sle i32 [[N]], [[LENGTH:%.*]]
187 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
188 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
189 ; CHECK-NEXT: br label [[OUTER_LOOP:%.*]]
191 ; CHECK-NEXT: [[OUTER_LOOP_ACC:%.*]] = phi i32 [ [[OUTER_LOOP_ACC_NEXT:%.*]], [[OUTER_LOOP_INC:%.*]] ], [ 0, [[OUTER_LOOP_PREHEADER]] ]
192 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[OUTER_LOOP_INC]] ], [ 0, [[OUTER_LOOP_PREHEADER]] ]
193 ; CHECK-NEXT: [[TMP6:%.*]] = icmp sle i32 [[L:%.*]], 0
194 ; CHECK-NEXT: br i1 [[TMP6]], label [[OUTER_LOOP_INC]], label [[INNER_LOOP_PREHEADER:%.*]]
195 ; CHECK: inner.loop.preheader:
196 ; CHECK-NEXT: [[TMP3:%.*]] = icmp sle i32 [[L]], [[LENGTH]]
197 ; CHECK-NEXT: br label [[INNER_LOOP:%.*]]
199 ; CHECK-NEXT: [[INNER_LOOP_ACC:%.*]] = phi i32 [ [[INNER_LOOP_ACC_NEXT:%.*]], [[INNER_LOOP]] ], [ [[OUTER_LOOP_ACC]], [[INNER_LOOP_PREHEADER]] ]
200 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[INNER_LOOP]] ], [ [[I]], [[INNER_LOOP_PREHEADER]] ]
201 ; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[TMP2]]
202 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[TMP4]], i32 9) [ "deopt"() ]
203 ; CHECK-NEXT: [[J_I64:%.*]] = zext i32 [[J]] to i64
204 ; CHECK-NEXT: [[ARRAY_J_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[J_I64]]
205 ; CHECK-NEXT: [[ARRAY_J:%.*]] = load i32, i32* [[ARRAY_J_PTR]], align 4
206 ; CHECK-NEXT: [[INNER_LOOP_ACC_NEXT]] = add i32 [[INNER_LOOP_ACC]], [[ARRAY_J]]
207 ; CHECK-NEXT: [[J_NEXT]] = add nsw i32 [[J]], 1
208 ; CHECK-NEXT: [[INNER_CONTINUE:%.*]] = icmp slt i32 [[J_NEXT]], [[L]]
209 ; CHECK-NEXT: br i1 [[INNER_CONTINUE]], label [[INNER_LOOP]], label [[OUTER_LOOP_INC_LOOPEXIT:%.*]]
210 ; CHECK: outer.loop.inc.loopexit:
211 ; CHECK-NEXT: [[INNER_LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[INNER_LOOP_ACC_NEXT]], [[INNER_LOOP]] ]
212 ; CHECK-NEXT: br label [[OUTER_LOOP_INC]]
213 ; CHECK: outer.loop.inc:
214 ; CHECK-NEXT: [[OUTER_LOOP_ACC_NEXT]] = phi i32 [ [[OUTER_LOOP_ACC]], [[OUTER_LOOP]] ], [ [[INNER_LOOP_ACC_NEXT_LCSSA]], [[OUTER_LOOP_INC_LOOPEXIT]] ]
215 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1
216 ; CHECK-NEXT: [[OUTER_CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
217 ; CHECK-NEXT: br i1 [[OUTER_CONTINUE]], label [[OUTER_LOOP]], label [[EXIT_LOOPEXIT:%.*]]
218 ; CHECK: exit.loopexit:
219 ; CHECK-NEXT: [[OUTER_LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[OUTER_LOOP_ACC_NEXT]], [[OUTER_LOOP_INC]] ]
220 ; CHECK-NEXT: br label [[EXIT]]
222 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[OUTER_LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
223 ; CHECK-NEXT: ret i32 [[RESULT]]
226 %tmp5 = icmp sle i32 %n, 0
227 br i1 %tmp5, label %exit, label %outer.loop.preheader
229 outer.loop.preheader:
233 %outer.loop.acc = phi i32 [ %outer.loop.acc.next, %outer.loop.inc ], [ 0, %outer.loop.preheader ]
234 %i = phi i32 [ %i.next, %outer.loop.inc ], [ 0, %outer.loop.preheader ]
235 %tmp6 = icmp sle i32 %l, 0
236 br i1 %tmp6, label %outer.loop.inc, label %inner.loop.preheader
238 inner.loop.preheader:
242 %inner.loop.acc = phi i32 [ %inner.loop.acc.next, %inner.loop ], [ %outer.loop.acc, %inner.loop.preheader ]
243 %j = phi i32 [ %j.next, %inner.loop ], [ %i, %inner.loop.preheader ]
245 %within.bounds = icmp ult i32 %j, %length
246 call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ]
248 %j.i64 = zext i32 %j to i64
249 %array.j.ptr = getelementptr inbounds i32, i32* %array, i64 %j.i64
250 %array.j = load i32, i32* %array.j.ptr, align 4
251 %inner.loop.acc.next = add i32 %inner.loop.acc, %array.j
253 %j.next = add nsw i32 %j, 1
254 %inner.continue = icmp slt i32 %j.next, %l
255 br i1 %inner.continue, label %inner.loop, label %outer.loop.inc
258 %outer.loop.acc.next = phi i32 [ %inner.loop.acc.next, %inner.loop ], [ %outer.loop.acc, %outer.loop ]
259 %i.next = add nsw i32 %i, 1
260 %outer.continue = icmp slt i32 %i.next, %n
261 br i1 %outer.continue, label %outer.loop, label %exit
264 %result = phi i32 [ 0, %entry ], [ %outer.loop.acc.next, %outer.loop.inc ]
268 define i32 @cant_expand_guard_check_start(i32* %array, i32 %length, i32 %n, i32 %l, i32 %maybezero) {
269 ; CHECK-LABEL: @cant_expand_guard_check_start(
271 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
272 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[OUTER_LOOP_PREHEADER:%.*]]
273 ; CHECK: outer.loop.preheader:
274 ; CHECK-NEXT: br label [[OUTER_LOOP:%.*]]
276 ; CHECK-NEXT: [[OUTER_LOOP_ACC:%.*]] = phi i32 [ [[OUTER_LOOP_ACC_NEXT:%.*]], [[OUTER_LOOP_INC:%.*]] ], [ 0, [[OUTER_LOOP_PREHEADER]] ]
277 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[OUTER_LOOP_INC]] ], [ 0, [[OUTER_LOOP_PREHEADER]] ]
278 ; CHECK-NEXT: [[TMP6:%.*]] = icmp sle i32 [[L:%.*]], 0
279 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[I]], [[MAYBEZERO:%.*]]
280 ; CHECK-NEXT: br i1 [[TMP6]], label [[OUTER_LOOP_INC]], label [[INNER_LOOP_PREHEADER:%.*]]
281 ; CHECK: inner.loop.preheader:
282 ; CHECK-NEXT: br label [[INNER_LOOP:%.*]]
284 ; CHECK-NEXT: [[INNER_LOOP_ACC:%.*]] = phi i32 [ [[INNER_LOOP_ACC_NEXT:%.*]], [[INNER_LOOP]] ], [ [[OUTER_LOOP_ACC]], [[INNER_LOOP_PREHEADER]] ]
285 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[INNER_LOOP]] ], [ [[DIV]], [[INNER_LOOP_PREHEADER]] ]
286 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[J]], [[LENGTH:%.*]]
287 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WITHIN_BOUNDS]], i32 9) [ "deopt"() ]
288 ; CHECK-NEXT: [[J_I64:%.*]] = zext i32 [[J]] to i64
289 ; CHECK-NEXT: [[ARRAY_J_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[J_I64]]
290 ; CHECK-NEXT: [[ARRAY_J:%.*]] = load i32, i32* [[ARRAY_J_PTR]], align 4
291 ; CHECK-NEXT: [[INNER_LOOP_ACC_NEXT]] = add i32 [[INNER_LOOP_ACC]], [[ARRAY_J]]
292 ; CHECK-NEXT: [[J_NEXT]] = add nsw i32 [[J]], 1
293 ; CHECK-NEXT: [[INNER_CONTINUE:%.*]] = icmp slt i32 [[J_NEXT]], [[L]]
294 ; CHECK-NEXT: br i1 [[INNER_CONTINUE]], label [[INNER_LOOP]], label [[OUTER_LOOP_INC_LOOPEXIT:%.*]]
295 ; CHECK: outer.loop.inc.loopexit:
296 ; CHECK-NEXT: [[INNER_LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[INNER_LOOP_ACC_NEXT]], [[INNER_LOOP]] ]
297 ; CHECK-NEXT: br label [[OUTER_LOOP_INC]]
298 ; CHECK: outer.loop.inc:
299 ; CHECK-NEXT: [[OUTER_LOOP_ACC_NEXT]] = phi i32 [ [[OUTER_LOOP_ACC]], [[OUTER_LOOP]] ], [ [[INNER_LOOP_ACC_NEXT_LCSSA]], [[OUTER_LOOP_INC_LOOPEXIT]] ]
300 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1
301 ; CHECK-NEXT: [[OUTER_CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
302 ; CHECK-NEXT: br i1 [[OUTER_CONTINUE]], label [[OUTER_LOOP]], label [[EXIT_LOOPEXIT:%.*]]
303 ; CHECK: exit.loopexit:
304 ; CHECK-NEXT: [[OUTER_LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[OUTER_LOOP_ACC_NEXT]], [[OUTER_LOOP_INC]] ]
305 ; CHECK-NEXT: br label [[EXIT]]
307 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[OUTER_LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
308 ; CHECK-NEXT: ret i32 [[RESULT]]
311 %tmp5 = icmp sle i32 %n, 0
312 br i1 %tmp5, label %exit, label %outer.loop.preheader
314 outer.loop.preheader:
318 %outer.loop.acc = phi i32 [ %outer.loop.acc.next, %outer.loop.inc ], [ 0, %outer.loop.preheader ]
319 %i = phi i32 [ %i.next, %outer.loop.inc ], [ 0, %outer.loop.preheader ]
320 %tmp6 = icmp sle i32 %l, 0
321 %div = udiv i32 %i, %maybezero
322 br i1 %tmp6, label %outer.loop.inc, label %inner.loop.preheader
324 inner.loop.preheader:
328 %inner.loop.acc = phi i32 [ %inner.loop.acc.next, %inner.loop ], [ %outer.loop.acc, %inner.loop.preheader ]
329 %j = phi i32 [ %j.next, %inner.loop ], [ %div, %inner.loop.preheader ]
331 %within.bounds = icmp ult i32 %j, %length
332 call void (i1, ...) @llvm.experimental.guard(i1 %within.bounds, i32 9) [ "deopt"() ]
334 %j.i64 = zext i32 %j to i64
335 %array.j.ptr = getelementptr inbounds i32, i32* %array, i64 %j.i64
336 %array.j = load i32, i32* %array.j.ptr, align 4
337 %inner.loop.acc.next = add i32 %inner.loop.acc, %array.j
339 %j.next = add nsw i32 %j, 1
340 %inner.continue = icmp slt i32 %j.next, %l
341 br i1 %inner.continue, label %inner.loop, label %outer.loop.inc
344 %outer.loop.acc.next = phi i32 [ %inner.loop.acc.next, %inner.loop ], [ %outer.loop.acc, %outer.loop ]
345 %i.next = add nsw i32 %i, 1
346 %outer.continue = icmp slt i32 %i.next, %n
347 br i1 %outer.continue, label %outer.loop, label %exit
350 %result = phi i32 [ 0, %entry ], [ %outer.loop.acc.next, %outer.loop.inc ]