1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -loop-predication -loop-predication-predicate-widenable-branches-to-deopt=true < %s 2>&1 | FileCheck %s
3 ; RUN: opt -S -passes='require<scalar-evolution>,loop(loop-predication)' -loop-predication-predicate-widenable-branches-to-deopt=true < %s 2>&1 | FileCheck %s
4 ; RUN: opt -S -passes='require<scalar-evolution>,require<branch-prob>,loop(loop-predication)' -loop-predication-predicate-widenable-branches-to-deopt=true < %s 2>&1 | FileCheck %s
6 declare void @llvm.experimental.guard(i1, ...)
8 define i32 @unsigned_loop_0_to_n_ult_check(i32* %array, i32 %length, i32 %n) {
9 ; CHECK-LABEL: @unsigned_loop_0_to_n_ult_check(
11 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
12 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
13 ; CHECK: loop.preheader:
14 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH:%.*]]
15 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
16 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
17 ; CHECK-NEXT: br label [[LOOP:%.*]]
19 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
20 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
21 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
22 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
23 ; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
25 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
26 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
28 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
29 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
30 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
31 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
32 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
33 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
34 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
35 ; CHECK: exit.loopexit:
36 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
37 ; CHECK-NEXT: br label [[EXIT]]
39 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
40 ; CHECK-NEXT: ret i32 [[RESULT]]
43 %tmp5 = icmp eq i32 %n, 0
44 br i1 %tmp5, label %exit, label %loop.preheader
46 loop.preheader: ; preds = %entry
49 loop: ; preds = %guarded, %loop.preheader
50 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
51 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
52 %within.bounds = icmp ult i32 %i, %length
53 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
54 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
55 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
57 deopt: ; preds = %loop
58 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
61 guarded: ; preds = %loop
62 %i.i64 = zext i32 %i to i64
63 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
64 %array.i = load i32, i32* %array.i.ptr, align 4
65 %loop.acc.next = add i32 %loop.acc, %array.i
66 %i.next = add nuw i32 %i, 1
67 %continue = icmp ult i32 %i.next, %n
68 br i1 %continue, label %loop, label %exit, !prof !2
70 exit: ; preds = %guarded, %entry
71 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
75 define i32 @unsigned_loop_0_to_n_ule_latch_ult_check(i32* %array, i32 %length, i32 %n) {
76 ; CHECK-LABEL: @unsigned_loop_0_to_n_ule_latch_ult_check(
78 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
79 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
80 ; CHECK: loop.preheader:
81 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ult i32 [[N]], [[LENGTH:%.*]]
82 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
83 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
84 ; CHECK-NEXT: br label [[LOOP:%.*]]
86 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
87 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
88 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
89 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
90 ; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
92 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
93 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
95 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
96 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
97 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
98 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
99 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
100 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ule i32 [[I_NEXT]], [[N]]
101 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
102 ; CHECK: exit.loopexit:
103 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
104 ; CHECK-NEXT: br label [[EXIT]]
106 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
107 ; CHECK-NEXT: ret i32 [[RESULT]]
110 %tmp5 = icmp eq i32 %n, 0
111 br i1 %tmp5, label %exit, label %loop.preheader
113 loop.preheader: ; preds = %entry
116 loop: ; preds = %guarded, %loop.preheader
117 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
118 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
119 %within.bounds = icmp ult i32 %i, %length
120 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
121 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
122 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
124 deopt: ; preds = %loop
125 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
128 guarded: ; preds = %loop
129 %i.i64 = zext i32 %i to i64
130 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
131 %array.i = load i32, i32* %array.i.ptr, align 4
132 %loop.acc.next = add i32 %loop.acc, %array.i
133 %i.next = add nuw i32 %i, 1
134 %continue = icmp ule i32 %i.next, %n
135 br i1 %continue, label %loop, label %exit, !prof !2
137 exit: ; preds = %guarded, %entry
138 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
142 define i32 @unsigned_loop_0_to_n_ugt_check(i32* %array, i32 %length, i32 %n) {
143 ; CHECK-LABEL: @unsigned_loop_0_to_n_ugt_check(
145 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
146 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
147 ; CHECK: loop.preheader:
148 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH:%.*]]
149 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
150 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
151 ; CHECK-NEXT: br label [[LOOP:%.*]]
153 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
154 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
155 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
156 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
157 ; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
159 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
160 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
162 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
163 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
164 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
165 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
166 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
167 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
168 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
169 ; CHECK: exit.loopexit:
170 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
171 ; CHECK-NEXT: br label [[EXIT]]
173 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
174 ; CHECK-NEXT: ret i32 [[RESULT]]
177 %tmp5 = icmp eq i32 %n, 0
178 br i1 %tmp5, label %exit, label %loop.preheader
180 loop.preheader: ; preds = %entry
183 loop: ; preds = %guarded, %loop.preheader
184 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
185 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
186 %within.bounds = icmp ugt i32 %length, %i
187 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
188 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
189 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
191 deopt: ; preds = %loop
192 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
195 guarded: ; preds = %loop
196 %i.i64 = zext i32 %i to i64
197 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
198 %array.i = load i32, i32* %array.i.ptr, align 4
199 %loop.acc.next = add i32 %loop.acc, %array.i
200 %i.next = add nuw i32 %i, 1
201 %continue = icmp ult i32 %i.next, %n
202 br i1 %continue, label %loop, label %exit, !prof !2
204 exit: ; preds = %guarded, %entry
205 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
209 define i32 @signed_loop_0_to_n_ult_check(i32* %array, i32 %length, i32 %n) {
210 ; CHECK-LABEL: @signed_loop_0_to_n_ult_check(
212 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
213 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
214 ; CHECK: loop.preheader:
215 ; CHECK-NEXT: [[TMP0:%.*]] = icmp sle i32 [[N]], [[LENGTH:%.*]]
216 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
217 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
218 ; CHECK-NEXT: br label [[LOOP:%.*]]
220 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
221 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
222 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
223 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
224 ; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
226 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
227 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
229 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
230 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
231 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
232 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
233 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
234 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
235 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
236 ; CHECK: exit.loopexit:
237 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
238 ; CHECK-NEXT: br label [[EXIT]]
240 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
241 ; CHECK-NEXT: ret i32 [[RESULT]]
245 %tmp5 = icmp sle i32 %n, 0
246 br i1 %tmp5, label %exit, label %loop.preheader
248 loop.preheader: ; preds = %entry
251 loop: ; preds = %guarded, %loop.preheader
252 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
253 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
254 %within.bounds = icmp ult i32 %i, %length
255 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
256 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
257 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
259 deopt: ; preds = %loop
260 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
263 guarded: ; preds = %loop
264 %i.i64 = zext i32 %i to i64
265 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
266 %array.i = load i32, i32* %array.i.ptr, align 4
267 %loop.acc.next = add i32 %loop.acc, %array.i
268 %i.next = add nuw i32 %i, 1
269 %continue = icmp slt i32 %i.next, %n
270 br i1 %continue, label %loop, label %exit, !prof !2
272 exit: ; preds = %guarded, %entry
273 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
277 define i32 @signed_loop_0_to_n_ult_check_length_range_known(i32* %array, i32* %length.ptr, i32 %n) {
278 ; CHECK-LABEL: @signed_loop_0_to_n_ult_check_length_range_known(
280 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
281 ; CHECK-NEXT: [[LENGTH:%.*]] = load i32, i32* [[LENGTH_PTR:%.*]], !range !2
282 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
283 ; CHECK: loop.preheader:
284 ; CHECK-NEXT: [[TMP0:%.*]] = icmp sle i32 [[N]], [[LENGTH]]
285 ; CHECK-NEXT: [[TMP1:%.*]] = and i1 true, [[TMP0]]
286 ; CHECK-NEXT: br label [[LOOP:%.*]]
288 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
289 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
290 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
291 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[WIDENABLE_COND]]
292 ; CHECK-NEXT: br i1 [[TMP2]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
294 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
295 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
297 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
298 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
299 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
300 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
301 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
302 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
303 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
304 ; CHECK: exit.loopexit:
305 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
306 ; CHECK-NEXT: br label [[EXIT]]
308 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
309 ; CHECK-NEXT: ret i32 [[RESULT]]
312 %tmp5 = icmp sle i32 %n, 0
313 %length = load i32, i32* %length.ptr, !range !1
314 br i1 %tmp5, label %exit, label %loop.preheader
316 loop.preheader: ; preds = %entry
319 loop: ; preds = %guarded, %loop.preheader
320 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
321 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
322 %within.bounds = icmp ult i32 %i, %length
323 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
324 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
325 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
327 deopt: ; preds = %loop
328 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
331 guarded: ; preds = %loop
332 %i.i64 = zext i32 %i to i64
333 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
334 %array.i = load i32, i32* %array.i.ptr, align 4
335 %loop.acc.next = add i32 %loop.acc, %array.i
336 %i.next = add nuw i32 %i, 1
337 %continue = icmp slt i32 %i.next, %n
338 br i1 %continue, label %loop, label %exit, !prof !2
340 exit: ; preds = %guarded, %entry
341 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
345 define i32 @signed_loop_0_to_n_inverse_latch_predicate(i32* %array, i32 %length, i32 %n) {
346 ; CHECK-LABEL: @signed_loop_0_to_n_inverse_latch_predicate(
348 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
349 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
350 ; CHECK: loop.preheader:
351 ; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[N]], [[LENGTH:%.*]]
352 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
353 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
354 ; CHECK-NEXT: br label [[LOOP:%.*]]
356 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
357 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
358 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
359 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
360 ; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
362 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
363 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
365 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
366 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
367 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
368 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
369 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
370 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp sgt i32 [[I_NEXT]], [[N]]
371 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[EXIT_LOOPEXIT:%.*]], label [[LOOP]], !prof !1
372 ; CHECK: exit.loopexit:
373 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
374 ; CHECK-NEXT: br label [[EXIT]]
376 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
377 ; CHECK-NEXT: ret i32 [[RESULT]]
380 %tmp5 = icmp sle i32 %n, 0
381 br i1 %tmp5, label %exit, label %loop.preheader
383 loop.preheader: ; preds = %entry
386 loop: ; preds = %guarded, %loop.preheader
387 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
388 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
389 %within.bounds = icmp ult i32 %i, %length
390 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
391 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
392 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
394 deopt: ; preds = %loop
395 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
398 guarded: ; preds = %loop
399 %i.i64 = zext i32 %i to i64
400 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
401 %array.i = load i32, i32* %array.i.ptr, align 4
402 %loop.acc.next = add i32 %loop.acc, %array.i
403 %i.next = add nuw i32 %i, 1
404 %continue = icmp sgt i32 %i.next, %n
405 br i1 %continue, label %exit, label %loop, !prof !2
407 exit: ; preds = %guarded, %entry
408 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
412 define i32 @signed_loop_0_to_n_sle_latch_ult_check(i32* %array, i32 %length, i32 %n) {
413 ; CHECK-LABEL: @signed_loop_0_to_n_sle_latch_ult_check(
415 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
416 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
417 ; CHECK: loop.preheader:
418 ; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[N]], [[LENGTH:%.*]]
419 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
420 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
421 ; CHECK-NEXT: br label [[LOOP:%.*]]
423 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
424 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
425 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
426 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
427 ; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
429 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
430 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
432 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
433 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
434 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
435 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
436 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
437 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp sle i32 [[I_NEXT]], [[N]]
438 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
439 ; CHECK: exit.loopexit:
440 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
441 ; CHECK-NEXT: br label [[EXIT]]
443 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
444 ; CHECK-NEXT: ret i32 [[RESULT]]
447 %tmp5 = icmp sle i32 %n, 0
448 br i1 %tmp5, label %exit, label %loop.preheader
450 loop.preheader: ; preds = %entry
453 loop: ; preds = %guarded, %loop.preheader
454 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
455 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
456 %within.bounds = icmp ult i32 %i, %length
457 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
458 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
459 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
461 deopt: ; preds = %loop
462 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
465 guarded: ; preds = %loop
466 %i.i64 = zext i32 %i to i64
467 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
468 %array.i = load i32, i32* %array.i.ptr, align 4
469 %loop.acc.next = add i32 %loop.acc, %array.i
470 %i.next = add nuw i32 %i, 1
471 %continue = icmp sle i32 %i.next, %n
472 br i1 %continue, label %loop, label %exit, !prof !2
474 exit: ; preds = %guarded, %entry
475 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
479 define i32 @signed_loop_0_to_n_preincrement_latch_check(i32* %array, i32 %length, i32 %n) {
480 ; CHECK-LABEL: @signed_loop_0_to_n_preincrement_latch_check(
482 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
483 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
484 ; CHECK: loop.preheader:
485 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LENGTH:%.*]], -1
486 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sle i32 [[N]], [[TMP0]]
487 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 0, [[LENGTH]]
488 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[TMP1]]
489 ; CHECK-NEXT: br label [[LOOP:%.*]]
491 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
492 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
493 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
494 ; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]]
495 ; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
497 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
498 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
500 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
501 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
502 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
503 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
504 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1
505 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I]], [[N]]
506 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
507 ; CHECK: exit.loopexit:
508 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
509 ; CHECK-NEXT: br label [[EXIT]]
511 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
512 ; CHECK-NEXT: ret i32 [[RESULT]]
515 %tmp5 = icmp sle i32 %n, 0
516 br i1 %tmp5, label %exit, label %loop.preheader
518 loop.preheader: ; preds = %entry
521 loop: ; preds = %guarded, %loop.preheader
522 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
523 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
524 %within.bounds = icmp ult i32 %i, %length
525 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
526 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
527 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
529 deopt: ; preds = %loop
530 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
533 guarded: ; preds = %loop
534 %i.i64 = zext i32 %i to i64
535 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
536 %array.i = load i32, i32* %array.i.ptr, align 4
537 %loop.acc.next = add i32 %loop.acc, %array.i
538 %i.next = add i32 %i, 1
539 %continue = icmp slt i32 %i, %n
540 br i1 %continue, label %loop, label %exit, !prof !2
542 exit: ; preds = %guarded, %entry
543 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
547 define i32 @signed_loop_0_to_n_preincrement_latch_check_postincrement_guard_check(i32* %array, i32 %length, i32 %n) {
548 ; CHECK-LABEL: @signed_loop_0_to_n_preincrement_latch_check_postincrement_guard_check(
550 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
551 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
552 ; CHECK: loop.preheader:
553 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LENGTH:%.*]], -2
554 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sle i32 [[N]], [[TMP0]]
555 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 1, [[LENGTH]]
556 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[TMP1]]
557 ; CHECK-NEXT: br label [[LOOP:%.*]]
559 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
560 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
561 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1
562 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
563 ; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]]
564 ; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
566 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
567 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
569 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
570 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
571 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
572 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
573 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I]], [[N]]
574 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
575 ; CHECK: exit.loopexit:
576 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
577 ; CHECK-NEXT: br label [[EXIT]]
579 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
580 ; CHECK-NEXT: ret i32 [[RESULT]]
583 %tmp5 = icmp sle i32 %n, 0
584 br i1 %tmp5, label %exit, label %loop.preheader
586 loop.preheader: ; preds = %entry
589 loop: ; preds = %guarded, %loop.preheader
590 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
591 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
592 %i.next = add i32 %i, 1
593 %within.bounds = icmp ult i32 %i.next, %length
594 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
595 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
596 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
598 deopt: ; preds = %loop
599 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
602 guarded: ; preds = %loop
603 %i.i64 = zext i32 %i to i64
604 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
605 %array.i = load i32, i32* %array.i.ptr, align 4
606 %loop.acc.next = add i32 %loop.acc, %array.i
607 %continue = icmp slt i32 %i, %n
608 br i1 %continue, label %loop, label %exit, !prof !2
610 exit: ; preds = %guarded, %entry
611 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
615 define i32 @signed_loop_0_to_n_sle_latch_offset_ult_check(i32* %array, i32 %length, i32 %n) {
616 ; CHECK-LABEL: @signed_loop_0_to_n_sle_latch_offset_ult_check(
618 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
619 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
620 ; CHECK: loop.preheader:
621 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LENGTH:%.*]], -1
622 ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 [[N]], [[TMP0]]
623 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 1, [[LENGTH]]
624 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[TMP1]]
625 ; CHECK-NEXT: br label [[LOOP:%.*]]
627 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
628 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
629 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
630 ; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]]
631 ; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
633 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
634 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
636 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
637 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
638 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
639 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
640 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1
641 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp sle i32 [[I_NEXT]], [[N]]
642 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
643 ; CHECK: exit.loopexit:
644 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
645 ; CHECK-NEXT: br label [[EXIT]]
647 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
648 ; CHECK-NEXT: ret i32 [[RESULT]]
651 %tmp5 = icmp sle i32 %n, 0
652 br i1 %tmp5, label %exit, label %loop.preheader
654 loop.preheader: ; preds = %entry
657 loop: ; preds = %guarded, %loop.preheader
658 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
659 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
660 %i.offset = add i32 %i, 1
661 %within.bounds = icmp ult i32 %i.offset, %length
662 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
663 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
664 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
666 deopt: ; preds = %loop
667 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
670 guarded: ; preds = %loop
671 %i.i64 = zext i32 %i to i64
672 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
673 %array.i = load i32, i32* %array.i.ptr, align 4
674 %loop.acc.next = add i32 %loop.acc, %array.i
675 %i.next = add i32 %i, 1
676 %continue = icmp sle i32 %i.next, %n
677 br i1 %continue, label %loop, label %exit, !prof !2
679 exit: ; preds = %guarded, %entry
680 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
684 define i32 @signed_loop_0_to_n_offset_sle_latch_offset_ult_check(i32* %array, i32 %length, i32 %n) {
685 ; CHECK-LABEL: @signed_loop_0_to_n_offset_sle_latch_offset_ult_check(
687 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
688 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
689 ; CHECK: loop.preheader:
690 ; CHECK-NEXT: [[TMP0:%.*]] = icmp slt i32 [[N]], [[LENGTH:%.*]]
691 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 1, [[LENGTH]]
692 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
693 ; CHECK-NEXT: br label [[LOOP:%.*]]
695 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
696 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
697 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
698 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
699 ; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
701 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
702 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
704 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
705 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
706 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
707 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
708 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1
709 ; CHECK-NEXT: [[I_NEXT_OFFSET:%.*]] = add i32 [[I_NEXT]], 1
710 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp sle i32 [[I_NEXT_OFFSET]], [[N]]
711 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
712 ; CHECK: exit.loopexit:
713 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
714 ; CHECK-NEXT: br label [[EXIT]]
716 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
717 ; CHECK-NEXT: ret i32 [[RESULT]]
720 %tmp5 = icmp sle i32 %n, 0
721 br i1 %tmp5, label %exit, label %loop.preheader
723 loop.preheader: ; preds = %entry
726 loop: ; preds = %guarded, %loop.preheader
727 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
728 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
729 %i.offset = add i32 %i, 1
730 %within.bounds = icmp ult i32 %i.offset, %length
731 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
732 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
733 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
735 deopt: ; preds = %loop
736 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
739 guarded: ; preds = %loop
740 %i.i64 = zext i32 %i to i64
741 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
742 %array.i = load i32, i32* %array.i.ptr, align 4
743 %loop.acc.next = add i32 %loop.acc, %array.i
744 %i.next = add i32 %i, 1
745 %i.next.offset = add i32 %i.next, 1
746 %continue = icmp sle i32 %i.next.offset, %n
747 br i1 %continue, label %loop, label %exit, !prof !2
749 exit: ; preds = %guarded, %entry
750 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
754 define i32 @unsupported_latch_pred_loop_0_to_n(i32* %array, i32 %length, i32 %n) {
755 ; CHECK-LABEL: @unsupported_latch_pred_loop_0_to_n(
757 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
758 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
759 ; CHECK: loop.preheader:
760 ; CHECK-NEXT: br label [[LOOP:%.*]]
762 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
763 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
764 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]]
765 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
766 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]]
767 ; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
769 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
770 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
772 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
773 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
774 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
775 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
776 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1
777 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ne i32 [[I_NEXT]], [[N]]
778 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
779 ; CHECK: exit.loopexit:
780 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
781 ; CHECK-NEXT: br label [[EXIT]]
783 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
784 ; CHECK-NEXT: ret i32 [[RESULT]]
787 %tmp5 = icmp sle i32 %n, 0
788 br i1 %tmp5, label %exit, label %loop.preheader
790 loop.preheader: ; preds = %entry
793 loop: ; preds = %guarded, %loop.preheader
794 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
795 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
796 %within.bounds = icmp ult i32 %i, %length
797 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
798 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
799 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
801 deopt: ; preds = %loop
802 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
805 guarded: ; preds = %loop
806 %i.i64 = zext i32 %i to i64
807 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
808 %array.i = load i32, i32* %array.i.ptr, align 4
809 %loop.acc.next = add i32 %loop.acc, %array.i
810 %i.next = add nsw i32 %i, 1
811 %continue = icmp ne i32 %i.next, %n
812 br i1 %continue, label %loop, label %exit, !prof !2
814 exit: ; preds = %guarded, %entry
815 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
819 define i32 @signed_loop_0_to_n_unsupported_iv_step(i32* %array, i32 %length, i32 %n) {
820 ; CHECK-LABEL: @signed_loop_0_to_n_unsupported_iv_step(
822 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
823 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
824 ; CHECK: loop.preheader:
825 ; CHECK-NEXT: br label [[LOOP:%.*]]
827 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
828 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
829 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]]
830 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
831 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]]
832 ; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
834 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
835 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
837 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
838 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
839 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
840 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
841 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 2
842 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
843 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
844 ; CHECK: exit.loopexit:
845 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
846 ; CHECK-NEXT: br label [[EXIT]]
848 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
849 ; CHECK-NEXT: ret i32 [[RESULT]]
852 %tmp5 = icmp sle i32 %n, 0
853 br i1 %tmp5, label %exit, label %loop.preheader
855 loop.preheader: ; preds = %entry
858 loop: ; preds = %guarded, %loop.preheader
859 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
860 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
861 %within.bounds = icmp ult i32 %i, %length
862 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
863 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
864 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
866 deopt: ; preds = %loop
867 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
870 guarded: ; preds = %loop
871 %i.i64 = zext i32 %i to i64
872 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
873 %array.i = load i32, i32* %array.i.ptr, align 4
874 %loop.acc.next = add i32 %loop.acc, %array.i
875 %i.next = add nsw i32 %i, 2
876 %continue = icmp slt i32 %i.next, %n
877 br i1 %continue, label %loop, label %exit, !prof !2
879 exit: ; preds = %guarded, %entry
880 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
884 define i32 @signed_loop_0_to_n_equal_iv_range_check(i32* %array, i32 %length, i32 %n) {
885 ; CHECK-LABEL: @signed_loop_0_to_n_equal_iv_range_check(
887 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
888 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
889 ; CHECK: loop.preheader:
890 ; CHECK-NEXT: [[TMP0:%.*]] = icmp sle i32 [[N]], [[LENGTH:%.*]]
891 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
892 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
893 ; CHECK-NEXT: br label [[LOOP:%.*]]
895 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
896 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
897 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
898 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
899 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
900 ; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
902 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
903 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
905 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
906 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
907 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
908 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
909 ; CHECK-NEXT: [[J_NEXT]] = add nsw i32 [[J]], 1
910 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1
911 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
912 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
913 ; CHECK: exit.loopexit:
914 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
915 ; CHECK-NEXT: br label [[EXIT]]
917 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
918 ; CHECK-NEXT: ret i32 [[RESULT]]
921 %tmp5 = icmp sle i32 %n, 0
922 br i1 %tmp5, label %exit, label %loop.preheader
924 loop.preheader: ; preds = %entry
927 loop: ; preds = %guarded, %loop.preheader
928 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
929 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
930 %j = phi i32 [ %j.next, %guarded ], [ 0, %loop.preheader ]
931 %within.bounds = icmp ult i32 %j, %length
932 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
933 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
934 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
936 deopt: ; preds = %loop
937 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
940 guarded: ; preds = %loop
941 %i.i64 = zext i32 %i to i64
942 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
943 %array.i = load i32, i32* %array.i.ptr, align 4
944 %loop.acc.next = add i32 %loop.acc, %array.i
945 %j.next = add nsw i32 %j, 1
946 %i.next = add nsw i32 %i, 1
947 %continue = icmp slt i32 %i.next, %n
948 br i1 %continue, label %loop, label %exit, !prof !2
950 exit: ; preds = %guarded, %entry
951 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
955 define i32 @signed_loop_start_to_n_offset_iv_range_check(i32* %array, i32 %start.i, i32 %start.j, i32 %length, i32 %n) {
956 ; CHECK-LABEL: @signed_loop_start_to_n_offset_iv_range_check(
958 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
959 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
960 ; CHECK: loop.preheader:
961 ; CHECK-NEXT: [[TMP0:%.*]] = add i32 [[LENGTH:%.*]], [[START_I:%.*]]
962 ; CHECK-NEXT: [[TMP1:%.*]] = sub i32 [[TMP0]], [[START_J:%.*]]
963 ; CHECK-NEXT: [[TMP2:%.*]] = icmp sle i32 [[N]], [[TMP1]]
964 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ult i32 [[START_J]], [[LENGTH]]
965 ; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[TMP2]]
966 ; CHECK-NEXT: br label [[LOOP:%.*]]
968 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
969 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ [[START_I]], [[LOOP_PREHEADER]] ]
970 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[GUARDED]] ], [ [[START_J]], [[LOOP_PREHEADER]] ]
971 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
972 ; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP4]], [[WIDENABLE_COND]]
973 ; CHECK-NEXT: br i1 [[TMP5]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
975 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
976 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
978 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
979 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
980 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
981 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
982 ; CHECK-NEXT: [[J_NEXT]] = add i32 [[J]], 1
983 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1
984 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
985 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
986 ; CHECK: exit.loopexit:
987 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
988 ; CHECK-NEXT: br label [[EXIT]]
990 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
991 ; CHECK-NEXT: ret i32 [[RESULT]]
994 %tmp5 = icmp sle i32 %n, 0
995 br i1 %tmp5, label %exit, label %loop.preheader
997 loop.preheader: ; preds = %entry
1000 loop: ; preds = %guarded, %loop.preheader
1001 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1002 %i = phi i32 [ %i.next, %guarded ], [ %start.i, %loop.preheader ]
1003 %j = phi i32 [ %j.next, %guarded ], [ %start.j, %loop.preheader ]
1004 %within.bounds = icmp ult i32 %j, %length
1005 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1006 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
1007 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1009 deopt: ; preds = %loop
1010 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1013 guarded: ; preds = %loop
1014 %i.i64 = zext i32 %i to i64
1015 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1016 %array.i = load i32, i32* %array.i.ptr, align 4
1017 %loop.acc.next = add i32 %loop.acc, %array.i
1018 %j.next = add i32 %j, 1
1019 %i.next = add i32 %i, 1
1020 %continue = icmp slt i32 %i.next, %n
1021 br i1 %continue, label %loop, label %exit, !prof !2
1023 exit: ; preds = %guarded, %entry
1024 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1028 define i32 @signed_loop_0_to_n_different_iv_types(i32* %array, i16 %length, i32 %n) {
1029 ; CHECK-LABEL: @signed_loop_0_to_n_different_iv_types(
1030 ; CHECK-NEXT: entry:
1031 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
1032 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1033 ; CHECK: loop.preheader:
1034 ; CHECK-NEXT: br label [[LOOP:%.*]]
1036 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1037 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1038 ; CHECK-NEXT: [[J:%.*]] = phi i16 [ [[J_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1039 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i16 [[J]], [[LENGTH:%.*]]
1040 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1041 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]]
1042 ; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1044 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1045 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1047 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1048 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
1049 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
1050 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
1051 ; CHECK-NEXT: [[J_NEXT]] = add i16 [[J]], 1
1052 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1
1053 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
1054 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1055 ; CHECK: exit.loopexit:
1056 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1057 ; CHECK-NEXT: br label [[EXIT]]
1059 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1060 ; CHECK-NEXT: ret i32 [[RESULT]]
1063 %tmp5 = icmp sle i32 %n, 0
1064 br i1 %tmp5, label %exit, label %loop.preheader
1066 loop.preheader: ; preds = %entry
1069 loop: ; preds = %guarded, %loop.preheader
1070 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1071 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
1072 %j = phi i16 [ %j.next, %guarded ], [ 0, %loop.preheader ]
1073 %within.bounds = icmp ult i16 %j, %length
1074 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1075 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
1076 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1078 deopt: ; preds = %loop
1079 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1082 guarded: ; preds = %loop
1083 %i.i64 = zext i32 %i to i64
1084 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1085 %array.i = load i32, i32* %array.i.ptr, align 4
1086 %loop.acc.next = add i32 %loop.acc, %array.i
1087 %j.next = add i16 %j, 1
1088 %i.next = add i32 %i, 1
1089 %continue = icmp slt i32 %i.next, %n
1090 br i1 %continue, label %loop, label %exit, !prof !2
1092 exit: ; preds = %guarded, %entry
1093 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1097 define i32 @signed_loop_0_to_n_different_iv_strides(i32* %array, i32 %length, i32 %n) {
1098 ; CHECK-LABEL: @signed_loop_0_to_n_different_iv_strides(
1099 ; CHECK-NEXT: entry:
1100 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
1101 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1102 ; CHECK: loop.preheader:
1103 ; CHECK-NEXT: br label [[LOOP:%.*]]
1105 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1106 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1107 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ [[J_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1108 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[J]], [[LENGTH:%.*]]
1109 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1110 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]]
1111 ; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1113 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1114 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1116 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1117 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
1118 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
1119 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
1120 ; CHECK-NEXT: [[J_NEXT]] = add nsw i32 [[J]], 2
1121 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1
1122 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
1123 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1124 ; CHECK: exit.loopexit:
1125 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1126 ; CHECK-NEXT: br label [[EXIT]]
1128 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1129 ; CHECK-NEXT: ret i32 [[RESULT]]
1132 %tmp5 = icmp sle i32 %n, 0
1133 br i1 %tmp5, label %exit, label %loop.preheader
1135 loop.preheader: ; preds = %entry
1138 loop: ; preds = %guarded, %loop.preheader
1139 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1140 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
1141 %j = phi i32 [ %j.next, %guarded ], [ 0, %loop.preheader ]
1142 %within.bounds = icmp ult i32 %j, %length
1143 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1144 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
1145 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1147 deopt: ; preds = %loop
1148 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1151 guarded: ; preds = %loop
1152 %i.i64 = zext i32 %i to i64
1153 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1154 %array.i = load i32, i32* %array.i.ptr, align 4
1155 %loop.acc.next = add i32 %loop.acc, %array.i
1156 %j.next = add nsw i32 %j, 2
1157 %i.next = add nsw i32 %i, 1
1158 %continue = icmp slt i32 %i.next, %n
1159 br i1 %continue, label %loop, label %exit, !prof !2
1161 exit: ; preds = %guarded, %entry
1162 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1166 define i32 @two_range_checks(i32* %array.1, i32 %length.1, i32* %array.2, i32 %length.2, i32 %n) {
1167 ; CHECK-LABEL: @two_range_checks(
1168 ; CHECK-NEXT: entry:
1169 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
1170 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1171 ; CHECK: loop.preheader:
1172 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH_2:%.*]]
1173 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH_2]]
1174 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
1175 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ule i32 [[N]], [[LENGTH_1:%.*]]
1176 ; CHECK-NEXT: [[TMP4:%.*]] = icmp ult i32 0, [[LENGTH_1]]
1177 ; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP4]], [[TMP3]]
1178 ; CHECK-NEXT: br label [[LOOP:%.*]]
1180 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1181 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1182 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1183 ; CHECK-NEXT: [[TMP6:%.*]] = and i1 [[TMP2]], [[TMP5]]
1184 ; CHECK-NEXT: [[TMP7:%.*]] = and i1 [[TMP6]], [[WIDENABLE_COND]]
1185 ; CHECK-NEXT: br i1 [[TMP7]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1187 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1188 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1190 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1191 ; CHECK-NEXT: [[ARRAY_1_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_1:%.*]], i64 [[I_I64]]
1192 ; CHECK-NEXT: [[ARRAY_1_I:%.*]] = load i32, i32* [[ARRAY_1_I_PTR]], align 4
1193 ; CHECK-NEXT: [[LOOP_ACC_1:%.*]] = add i32 [[LOOP_ACC]], [[ARRAY_1_I]]
1194 ; CHECK-NEXT: [[ARRAY_2_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_2:%.*]], i64 [[I_I64]]
1195 ; CHECK-NEXT: [[ARRAY_2_I:%.*]] = load i32, i32* [[ARRAY_2_I_PTR]], align 4
1196 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC_1]], [[ARRAY_2_I]]
1197 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1198 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
1199 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1200 ; CHECK: exit.loopexit:
1201 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1202 ; CHECK-NEXT: br label [[EXIT]]
1204 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1205 ; CHECK-NEXT: ret i32 [[RESULT]]
1208 %tmp5 = icmp eq i32 %n, 0
1209 br i1 %tmp5, label %exit, label %loop.preheader
1211 loop.preheader: ; preds = %entry
1214 loop: ; preds = %guarded, %loop.preheader
1215 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1216 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
1217 %within.bounds.1 = icmp ult i32 %i, %length.1
1218 %within.bounds.2 = icmp ult i32 %i, %length.2
1219 %within.bounds = and i1 %within.bounds.1, %within.bounds.2
1220 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1221 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
1222 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1224 deopt: ; preds = %loop
1225 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1228 guarded: ; preds = %loop
1229 %i.i64 = zext i32 %i to i64
1230 %array.1.i.ptr = getelementptr inbounds i32, i32* %array.1, i64 %i.i64
1231 %array.1.i = load i32, i32* %array.1.i.ptr, align 4
1232 %loop.acc.1 = add i32 %loop.acc, %array.1.i
1233 %array.2.i.ptr = getelementptr inbounds i32, i32* %array.2, i64 %i.i64
1234 %array.2.i = load i32, i32* %array.2.i.ptr, align 4
1235 %loop.acc.next = add i32 %loop.acc.1, %array.2.i
1236 %i.next = add nuw i32 %i, 1
1237 %continue = icmp ult i32 %i.next, %n
1238 br i1 %continue, label %loop, label %exit, !prof !2
1240 exit: ; preds = %guarded, %entry
1241 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1245 define i32 @three_range_checks(i32* %array.1, i32 %length.1, i32* %array.2, i32 %length.2, i32* %array.3, i32 %length.3, i32 %n) {
1246 ; CHECK-LABEL: @three_range_checks(
1247 ; CHECK-NEXT: entry:
1248 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
1249 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1250 ; CHECK: loop.preheader:
1251 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH_3:%.*]]
1252 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH_3]]
1253 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
1254 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ule i32 [[N]], [[LENGTH_2:%.*]]
1255 ; CHECK-NEXT: [[TMP4:%.*]] = icmp ult i32 0, [[LENGTH_2]]
1256 ; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP4]], [[TMP3]]
1257 ; CHECK-NEXT: [[TMP6:%.*]] = icmp ule i32 [[N]], [[LENGTH_1:%.*]]
1258 ; CHECK-NEXT: [[TMP7:%.*]] = icmp ult i32 0, [[LENGTH_1]]
1259 ; CHECK-NEXT: [[TMP8:%.*]] = and i1 [[TMP7]], [[TMP6]]
1260 ; CHECK-NEXT: br label [[LOOP:%.*]]
1262 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1263 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1264 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1265 ; CHECK-NEXT: [[TMP9:%.*]] = and i1 [[TMP2]], [[TMP5]]
1266 ; CHECK-NEXT: [[TMP10:%.*]] = and i1 [[TMP9]], [[TMP8]]
1267 ; CHECK-NEXT: [[TMP11:%.*]] = and i1 [[TMP10]], [[WIDENABLE_COND]]
1268 ; CHECK-NEXT: br i1 [[TMP11]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1270 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1271 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1273 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1274 ; CHECK-NEXT: [[ARRAY_1_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_1:%.*]], i64 [[I_I64]]
1275 ; CHECK-NEXT: [[ARRAY_1_I:%.*]] = load i32, i32* [[ARRAY_1_I_PTR]], align 4
1276 ; CHECK-NEXT: [[LOOP_ACC_1:%.*]] = add i32 [[LOOP_ACC]], [[ARRAY_1_I]]
1277 ; CHECK-NEXT: [[ARRAY_2_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_2:%.*]], i64 [[I_I64]]
1278 ; CHECK-NEXT: [[ARRAY_2_I:%.*]] = load i32, i32* [[ARRAY_2_I_PTR]], align 4
1279 ; CHECK-NEXT: [[LOOP_ACC_2:%.*]] = add i32 [[LOOP_ACC_1]], [[ARRAY_2_I]]
1280 ; CHECK-NEXT: [[ARRAY_3_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_3:%.*]], i64 [[I_I64]]
1281 ; CHECK-NEXT: [[ARRAY_3_I:%.*]] = load i32, i32* [[ARRAY_3_I_PTR]], align 4
1282 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC_2]], [[ARRAY_3_I]]
1283 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1284 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
1285 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1286 ; CHECK: exit.loopexit:
1287 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1288 ; CHECK-NEXT: br label [[EXIT]]
1290 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1291 ; CHECK-NEXT: ret i32 [[RESULT]]
1294 %tmp5 = icmp eq i32 %n, 0
1295 br i1 %tmp5, label %exit, label %loop.preheader
1297 loop.preheader: ; preds = %entry
1300 loop: ; preds = %guarded, %loop.preheader
1301 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1302 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
1303 %within.bounds.1 = icmp ult i32 %i, %length.1
1304 %within.bounds.2 = icmp ult i32 %i, %length.2
1305 %within.bounds.3 = icmp ult i32 %i, %length.3
1306 %within.bounds.1.and.2 = and i1 %within.bounds.1, %within.bounds.2
1307 %within.bounds = and i1 %within.bounds.1.and.2, %within.bounds.3
1308 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1309 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
1310 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1312 deopt: ; preds = %loop
1313 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1316 guarded: ; preds = %loop
1317 %i.i64 = zext i32 %i to i64
1318 %array.1.i.ptr = getelementptr inbounds i32, i32* %array.1, i64 %i.i64
1319 %array.1.i = load i32, i32* %array.1.i.ptr, align 4
1320 %loop.acc.1 = add i32 %loop.acc, %array.1.i
1321 %array.2.i.ptr = getelementptr inbounds i32, i32* %array.2, i64 %i.i64
1322 %array.2.i = load i32, i32* %array.2.i.ptr, align 4
1323 %loop.acc.2 = add i32 %loop.acc.1, %array.2.i
1324 %array.3.i.ptr = getelementptr inbounds i32, i32* %array.3, i64 %i.i64
1325 %array.3.i = load i32, i32* %array.3.i.ptr, align 4
1326 %loop.acc.next = add i32 %loop.acc.2, %array.3.i
1327 %i.next = add nuw i32 %i, 1
1328 %continue = icmp ult i32 %i.next, %n
1329 br i1 %continue, label %loop, label %exit, !prof !2
1331 exit: ; preds = %guarded, %entry
1332 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1336 define i32 @three_guards(i32* %array.1, i32 %length.1, i32* %array.2, i32 %length.2, i32* %array.3, i32 %length.3, i32 %n) {
1337 ; CHECK-LABEL: @three_guards(
1338 ; CHECK-NEXT: entry:
1339 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
1340 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1341 ; CHECK: loop.preheader:
1342 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH_1:%.*]]
1343 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH_1]]
1344 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
1345 ; CHECK-NEXT: [[TMP3:%.*]] = icmp ule i32 [[N]], [[LENGTH_2:%.*]]
1346 ; CHECK-NEXT: [[TMP4:%.*]] = icmp ult i32 0, [[LENGTH_2]]
1347 ; CHECK-NEXT: [[TMP5:%.*]] = and i1 [[TMP4]], [[TMP3]]
1348 ; CHECK-NEXT: [[TMP6:%.*]] = icmp ule i32 [[N]], [[LENGTH_3:%.*]]
1349 ; CHECK-NEXT: [[TMP7:%.*]] = icmp ult i32 0, [[LENGTH_3]]
1350 ; CHECK-NEXT: [[TMP8:%.*]] = and i1 [[TMP7]], [[TMP6]]
1351 ; CHECK-NEXT: br label [[LOOP:%.*]]
1353 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED6:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1354 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED6]] ], [ 0, [[LOOP_PREHEADER]] ]
1355 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1356 ; CHECK-NEXT: [[TMP9:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
1357 ; CHECK-NEXT: br i1 [[TMP9]], label [[GUARDED:%.*]], label [[DEOPT:%.*]], !prof !0
1359 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1360 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1362 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1363 ; CHECK-NEXT: [[ARRAY_1_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_1:%.*]], i64 [[I_I64]]
1364 ; CHECK-NEXT: [[ARRAY_1_I:%.*]] = load i32, i32* [[ARRAY_1_I_PTR]], align 4
1365 ; CHECK-NEXT: [[LOOP_ACC_1:%.*]] = add i32 [[LOOP_ACC]], [[ARRAY_1_I]]
1366 ; CHECK-NEXT: [[WIDENABLE_COND4:%.*]] = call i1 @llvm.experimental.widenable.condition()
1367 ; CHECK-NEXT: [[TMP10:%.*]] = and i1 [[TMP5]], [[WIDENABLE_COND4]]
1368 ; CHECK-NEXT: br i1 [[TMP10]], label [[GUARDED1:%.*]], label [[DEOPT2:%.*]], !prof !0
1370 ; CHECK-NEXT: [[DEOPTCALL3:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1371 ; CHECK-NEXT: ret i32 [[DEOPTCALL3]]
1373 ; CHECK-NEXT: [[ARRAY_2_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_2:%.*]], i64 [[I_I64]]
1374 ; CHECK-NEXT: [[ARRAY_2_I:%.*]] = load i32, i32* [[ARRAY_2_I_PTR]], align 4
1375 ; CHECK-NEXT: [[LOOP_ACC_2:%.*]] = add i32 [[LOOP_ACC_1]], [[ARRAY_2_I]]
1376 ; CHECK-NEXT: [[WIDENABLE_COND9:%.*]] = call i1 @llvm.experimental.widenable.condition()
1377 ; CHECK-NEXT: [[TMP11:%.*]] = and i1 [[TMP8]], [[WIDENABLE_COND9]]
1378 ; CHECK-NEXT: br i1 [[TMP11]], label [[GUARDED6]], label [[DEOPT7:%.*]], !prof !0
1380 ; CHECK-NEXT: [[DEOPTCALL8:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1381 ; CHECK-NEXT: ret i32 [[DEOPTCALL8]]
1383 ; CHECK-NEXT: [[ARRAY_3_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY_3:%.*]], i64 [[I_I64]]
1384 ; CHECK-NEXT: [[ARRAY_3_I:%.*]] = load i32, i32* [[ARRAY_3_I_PTR]], align 4
1385 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC_2]], [[ARRAY_3_I]]
1386 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1387 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
1388 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1389 ; CHECK: exit.loopexit:
1390 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED6]] ]
1391 ; CHECK-NEXT: br label [[EXIT]]
1393 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1394 ; CHECK-NEXT: ret i32 [[RESULT]]
1397 %tmp5 = icmp eq i32 %n, 0
1398 br i1 %tmp5, label %exit, label %loop.preheader
1400 loop.preheader: ; preds = %entry
1403 loop: ; preds = %guarded6, %loop.preheader
1404 %loop.acc = phi i32 [ %loop.acc.next, %guarded6 ], [ 0, %loop.preheader ]
1405 %i = phi i32 [ %i.next, %guarded6 ], [ 0, %loop.preheader ]
1406 %within.bounds.1 = icmp ult i32 %i, %length.1
1407 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1408 %exiplicit_guard_cond = and i1 %within.bounds.1, %widenable_cond
1409 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1411 deopt: ; preds = %loop
1412 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1415 guarded: ; preds = %loop
1416 %i.i64 = zext i32 %i to i64
1417 %array.1.i.ptr = getelementptr inbounds i32, i32* %array.1, i64 %i.i64
1418 %array.1.i = load i32, i32* %array.1.i.ptr, align 4
1419 %loop.acc.1 = add i32 %loop.acc, %array.1.i
1420 %within.bounds.2 = icmp ult i32 %i, %length.2
1421 %widenable_cond4 = call i1 @llvm.experimental.widenable.condition()
1422 %exiplicit_guard_cond5 = and i1 %within.bounds.2, %widenable_cond4
1423 br i1 %exiplicit_guard_cond5, label %guarded1, label %deopt2, !prof !0
1425 deopt2: ; preds = %guarded
1426 %deoptcall3 = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1429 guarded1: ; preds = %guarded
1430 %array.2.i.ptr = getelementptr inbounds i32, i32* %array.2, i64 %i.i64
1431 %array.2.i = load i32, i32* %array.2.i.ptr, align 4
1432 %loop.acc.2 = add i32 %loop.acc.1, %array.2.i
1433 %within.bounds.3 = icmp ult i32 %i, %length.3
1434 %widenable_cond9 = call i1 @llvm.experimental.widenable.condition()
1435 %exiplicit_guard_cond10 = and i1 %within.bounds.3, %widenable_cond9
1436 br i1 %exiplicit_guard_cond10, label %guarded6, label %deopt7, !prof !0
1438 deopt7: ; preds = %guarded1
1439 %deoptcall8 = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1442 guarded6: ; preds = %guarded1
1443 %array.3.i.ptr = getelementptr inbounds i32, i32* %array.3, i64 %i.i64
1444 %array.3.i = load i32, i32* %array.3.i.ptr, align 4
1445 %loop.acc.next = add i32 %loop.acc.2, %array.3.i
1446 %i.next = add nuw i32 %i, 1
1447 %continue = icmp ult i32 %i.next, %n
1448 br i1 %continue, label %loop, label %exit, !prof !2
1450 exit: ; preds = %guarded6, %entry
1451 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded6 ]
1455 define i32 @unsigned_loop_0_to_n_unrelated_condition(i32* %array, i32 %length, i32 %n, i32 %x) {
1456 ; CHECK-LABEL: @unsigned_loop_0_to_n_unrelated_condition(
1457 ; CHECK-NEXT: entry:
1458 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
1459 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1460 ; CHECK: loop.preheader:
1461 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH:%.*]]
1462 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH]]
1463 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
1464 ; CHECK-NEXT: br label [[LOOP:%.*]]
1466 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1467 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1468 ; CHECK-NEXT: [[UNRELATED_COND:%.*]] = icmp ult i32 [[X:%.*]], [[LENGTH]]
1469 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1470 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[UNRELATED_COND]], [[TMP2]]
1471 ; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]]
1472 ; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1474 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1475 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1477 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1478 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
1479 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
1480 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
1481 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1482 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
1483 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1484 ; CHECK: exit.loopexit:
1485 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1486 ; CHECK-NEXT: br label [[EXIT]]
1488 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1489 ; CHECK-NEXT: ret i32 [[RESULT]]
1492 %tmp5 = icmp eq i32 %n, 0
1493 br i1 %tmp5, label %exit, label %loop.preheader
1495 loop.preheader: ; preds = %entry
1498 loop: ; preds = %guarded, %loop.preheader
1499 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1500 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
1501 %within.bounds = icmp ult i32 %i, %length
1502 %unrelated.cond = icmp ult i32 %x, %length
1503 %guard.cond = and i1 %within.bounds, %unrelated.cond
1504 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1505 %exiplicit_guard_cond = and i1 %guard.cond, %widenable_cond
1506 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1508 deopt: ; preds = %loop
1509 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1512 guarded: ; preds = %loop
1513 %i.i64 = zext i32 %i to i64
1514 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1515 %array.i = load i32, i32* %array.i.ptr, align 4
1516 %loop.acc.next = add i32 %loop.acc, %array.i
1517 %i.next = add nuw i32 %i, 1
1518 %continue = icmp ult i32 %i.next, %n
1519 br i1 %continue, label %loop, label %exit, !prof !2
1521 exit: ; preds = %guarded, %entry
1522 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1526 define i32 @test_no_widened_conditions(i32* %array, i32 %length, i32 %n, i32 %x1, i32 %x2, i32 %x3) {
1527 ; CHECK-LABEL: @test_no_widened_conditions(
1528 ; CHECK-NEXT: entry:
1529 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
1530 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1531 ; CHECK: loop.preheader:
1532 ; CHECK-NEXT: br label [[LOOP:%.*]]
1534 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1535 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1536 ; CHECK-NEXT: [[UNRELATED_COND_1:%.*]] = icmp eq i32 [[X1:%.*]], [[I]]
1537 ; CHECK-NEXT: [[UNRELATED_COND_2:%.*]] = icmp eq i32 [[X2:%.*]], [[I]]
1538 ; CHECK-NEXT: [[UNRELATED_COND_3:%.*]] = icmp eq i32 [[X3:%.*]], [[I]]
1539 ; CHECK-NEXT: [[UNRELATED_COND_AND_1:%.*]] = and i1 [[UNRELATED_COND_1]], [[UNRELATED_COND_2]]
1540 ; CHECK-NEXT: [[GUARD_COND:%.*]] = and i1 [[UNRELATED_COND_AND_1]], [[UNRELATED_COND_3]]
1541 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1542 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[GUARD_COND]], [[WIDENABLE_COND]]
1543 ; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1545 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1546 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1548 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1549 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
1550 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
1551 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
1552 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1553 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
1554 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1555 ; CHECK: exit.loopexit:
1556 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1557 ; CHECK-NEXT: br label [[EXIT]]
1559 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1560 ; CHECK-NEXT: ret i32 [[RESULT]]
1563 %tmp5 = icmp eq i32 %n, 0
1564 br i1 %tmp5, label %exit, label %loop.preheader
1566 loop.preheader: ; preds = %entry
1569 loop: ; preds = %guarded, %loop.preheader
1570 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1571 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
1572 %unrelated.cond.1 = icmp eq i32 %x1, %i
1573 %unrelated.cond.2 = icmp eq i32 %x2, %i
1574 %unrelated.cond.3 = icmp eq i32 %x3, %i
1575 %unrelated.cond.and.1 = and i1 %unrelated.cond.1, %unrelated.cond.2
1576 %guard.cond = and i1 %unrelated.cond.and.1, %unrelated.cond.3
1577 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1578 %exiplicit_guard_cond = and i1 %guard.cond, %widenable_cond
1579 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1581 deopt: ; preds = %loop
1582 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1585 guarded: ; preds = %loop
1586 %i.i64 = zext i32 %i to i64
1587 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1588 %array.i = load i32, i32* %array.i.ptr, align 4
1589 %loop.acc.next = add i32 %loop.acc, %array.i
1590 %i.next = add nuw i32 %i, 1
1591 %continue = icmp ult i32 %i.next, %n
1592 br i1 %continue, label %loop, label %exit, !prof !2
1594 exit: ; preds = %guarded, %entry
1595 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1599 define i32 @signed_loop_start_to_n_loop_variant_bound(i32* %array, i32 %x, i32 %start, i32 %n) {
1600 ; CHECK-LABEL: @signed_loop_start_to_n_loop_variant_bound(
1601 ; CHECK-NEXT: entry:
1602 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
1603 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1604 ; CHECK: loop.preheader:
1605 ; CHECK-NEXT: br label [[LOOP:%.*]]
1607 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1608 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ [[START:%.*]], [[LOOP_PREHEADER]] ]
1609 ; CHECK-NEXT: [[BOUND:%.*]] = add i32 [[I]], [[X:%.*]]
1610 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[BOUND]]
1611 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1612 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[WITHIN_BOUNDS]], [[WIDENABLE_COND]]
1613 ; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1615 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1616 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1618 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1619 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
1620 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
1621 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
1622 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1
1623 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
1624 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1625 ; CHECK: exit.loopexit:
1626 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1627 ; CHECK-NEXT: br label [[EXIT]]
1629 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1630 ; CHECK-NEXT: ret i32 [[RESULT]]
1633 %tmp5 = icmp sle i32 %n, 0
1634 br i1 %tmp5, label %exit, label %loop.preheader
1636 loop.preheader: ; preds = %entry
1639 loop: ; preds = %guarded, %loop.preheader
1640 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1641 %i = phi i32 [ %i.next, %guarded ], [ %start, %loop.preheader ]
1642 %bound = add i32 %i, %x
1643 %within.bounds = icmp ult i32 %i, %bound
1644 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1645 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
1646 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1648 deopt: ; preds = %loop
1649 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1652 guarded: ; preds = %loop
1653 %i.i64 = zext i32 %i to i64
1654 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1655 %array.i = load i32, i32* %array.i.ptr, align 4
1656 %loop.acc.next = add i32 %loop.acc, %array.i
1657 %i.next = add nsw i32 %i, 1
1658 %continue = icmp slt i32 %i.next, %n
1659 br i1 %continue, label %loop, label %exit, !prof !2
1661 exit: ; preds = %guarded, %entry
1662 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1666 define i32 @signed_loop_start_to_n_non_monotonic_predicate(i32* %array, i32 %x, i32 %start, i32 %n) {
1667 ; CHECK-LABEL: @signed_loop_start_to_n_non_monotonic_predicate(
1668 ; CHECK-NEXT: entry:
1669 ; CHECK-NEXT: [[TMP5:%.*]] = icmp sle i32 [[N:%.*]], 0
1670 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1671 ; CHECK: loop.preheader:
1672 ; CHECK-NEXT: br label [[LOOP:%.*]]
1674 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1675 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ [[START:%.*]], [[LOOP_PREHEADER]] ]
1676 ; CHECK-NEXT: [[GUARD_COND:%.*]] = icmp eq i32 [[I]], [[X:%.*]]
1677 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1678 ; CHECK-NEXT: [[EXIPLICIT_GUARD_COND:%.*]] = and i1 [[GUARD_COND]], [[WIDENABLE_COND]]
1679 ; CHECK-NEXT: br i1 [[EXIPLICIT_GUARD_COND]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1681 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1682 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1684 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1685 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
1686 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
1687 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
1688 ; CHECK-NEXT: [[I_NEXT]] = add nsw i32 [[I]], 1
1689 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp slt i32 [[I_NEXT]], [[N]]
1690 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1691 ; CHECK: exit.loopexit:
1692 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1693 ; CHECK-NEXT: br label [[EXIT]]
1695 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1696 ; CHECK-NEXT: ret i32 [[RESULT]]
1699 %tmp5 = icmp sle i32 %n, 0
1700 br i1 %tmp5, label %exit, label %loop.preheader
1702 loop.preheader: ; preds = %entry
1705 loop: ; preds = %guarded, %loop.preheader
1706 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1707 %i = phi i32 [ %i.next, %guarded ], [ %start, %loop.preheader ]
1708 %guard.cond = icmp eq i32 %i, %x
1709 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1710 %exiplicit_guard_cond = and i1 %guard.cond, %widenable_cond
1711 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1713 deopt: ; preds = %loop
1714 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1717 guarded: ; preds = %loop
1718 %i.i64 = zext i32 %i to i64
1719 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1720 %array.i = load i32, i32* %array.i.ptr, align 4
1721 %loop.acc.next = add i32 %loop.acc, %array.i
1722 %i.next = add nsw i32 %i, 1
1723 %continue = icmp slt i32 %i.next, %n
1724 br i1 %continue, label %loop, label %exit, !prof !2
1726 exit: ; preds = %guarded, %entry
1727 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1731 define i32 @unsigned_loop_0_to_n_hoist_length(i32* %array, i16 %length.i16, i32 %n) {
1732 ; CHECK-LABEL: @unsigned_loop_0_to_n_hoist_length(
1733 ; CHECK-NEXT: entry:
1734 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
1735 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1736 ; CHECK: loop.preheader:
1737 ; CHECK-NEXT: [[TMP0:%.*]] = zext i16 [[LENGTH_I16:%.*]] to i32
1738 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i32 [[N]], [[TMP0]]
1739 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 0, [[TMP0]]
1740 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[TMP1]]
1741 ; CHECK-NEXT: br label [[LOOP:%.*]]
1743 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1744 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1745 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1746 ; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[TMP3]], [[WIDENABLE_COND]]
1747 ; CHECK-NEXT: br i1 [[TMP4]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1749 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1750 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1752 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1753 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
1754 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
1755 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
1756 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1757 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
1758 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1759 ; CHECK: exit.loopexit:
1760 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1761 ; CHECK-NEXT: br label [[EXIT]]
1763 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1764 ; CHECK-NEXT: ret i32 [[RESULT]]
1767 %tmp5 = icmp eq i32 %n, 0
1768 br i1 %tmp5, label %exit, label %loop.preheader
1770 loop.preheader: ; preds = %entry
1773 loop: ; preds = %guarded, %loop.preheader
1774 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1775 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
1776 %length = zext i16 %length.i16 to i32
1777 %within.bounds = icmp ult i32 %i, %length
1778 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1779 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
1780 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1782 deopt: ; preds = %loop
1783 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1786 guarded: ; preds = %loop
1787 %i.i64 = zext i32 %i to i64
1788 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1789 %array.i = load i32, i32* %array.i.ptr, align 4
1790 %loop.acc.next = add i32 %loop.acc, %array.i
1791 %i.next = add nuw i32 %i, 1
1792 %continue = icmp ult i32 %i.next, %n
1793 br i1 %continue, label %loop, label %exit, !prof !2
1795 exit: ; preds = %guarded, %entry
1796 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1800 define i32 @unsigned_loop_0_to_n_cant_hoist_length(i32* %array, i32 %length, i32 %divider, i32 %n) {
1801 ; CHECK-LABEL: @unsigned_loop_0_to_n_cant_hoist_length(
1802 ; CHECK-NEXT: entry:
1803 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
1804 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1805 ; CHECK: loop.preheader:
1806 ; CHECK-NEXT: br label [[LOOP:%.*]]
1808 ; CHECK-NEXT: [[LOOP_ACC:%.*]] = phi i32 [ [[LOOP_ACC_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1809 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED]] ], [ 0, [[LOOP_PREHEADER]] ]
1810 ; CHECK-NEXT: [[LENGTH_UDIV:%.*]] = udiv i32 [[LENGTH:%.*]], [[DIVIDER:%.*]]
1811 ; CHECK-NEXT: [[WIDENABLE_COND:%.*]] = call i1 @llvm.experimental.widenable.condition()
1812 ; CHECK-NEXT: [[TMP0:%.*]] = icmp ule i32 [[N]], [[LENGTH_UDIV]]
1813 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 0, [[LENGTH_UDIV]]
1814 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[TMP1]], [[TMP0]]
1815 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[TMP2]], [[WIDENABLE_COND]]
1816 ; CHECK-NEXT: br i1 [[TMP3]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1818 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1819 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1821 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1822 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
1823 ; CHECK-NEXT: [[ARRAY_I:%.*]] = load i32, i32* [[ARRAY_I_PTR]], align 4
1824 ; CHECK-NEXT: [[LOOP_ACC_NEXT]] = add i32 [[LOOP_ACC]], [[ARRAY_I]]
1825 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1826 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
1827 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1828 ; CHECK: exit.loopexit:
1829 ; CHECK-NEXT: [[LOOP_ACC_NEXT_LCSSA:%.*]] = phi i32 [ [[LOOP_ACC_NEXT]], [[GUARDED]] ]
1830 ; CHECK-NEXT: br label [[EXIT]]
1832 ; CHECK-NEXT: [[RESULT:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[LOOP_ACC_NEXT_LCSSA]], [[EXIT_LOOPEXIT]] ]
1833 ; CHECK-NEXT: ret i32 [[RESULT]]
1836 %tmp5 = icmp eq i32 %n, 0
1837 br i1 %tmp5, label %exit, label %loop.preheader
1839 loop.preheader: ; preds = %entry
1842 loop: ; preds = %guarded, %loop.preheader
1843 %loop.acc = phi i32 [ %loop.acc.next, %guarded ], [ 0, %loop.preheader ]
1844 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
1845 %length.udiv = udiv i32 %length, %divider
1846 %within.bounds = icmp ult i32 %i, %length.udiv
1847 %widenable_cond = call i1 @llvm.experimental.widenable.condition()
1848 %exiplicit_guard_cond = and i1 %within.bounds, %widenable_cond
1849 br i1 %exiplicit_guard_cond, label %guarded, label %deopt, !prof !0
1851 deopt: ; preds = %loop
1852 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1855 guarded: ; preds = %loop
1856 %i.i64 = zext i32 %i to i64
1857 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1858 %array.i = load i32, i32* %array.i.ptr, align 4
1859 %loop.acc.next = add i32 %loop.acc, %array.i
1860 %i.next = add nuw i32 %i, 1
1861 %continue = icmp ult i32 %i.next, %n
1862 br i1 %continue, label %loop, label %exit, !prof !2
1864 exit: ; preds = %guarded, %entry
1865 %result = phi i32 [ 0, %entry ], [ %loop.acc.next, %guarded ]
1869 ; Make sure that if we're going to consider a branch widenable, that the
1870 ; call to widenable condition is actually present.
1871 define i32 @negative_WC_required(i32* %array, i32 %length, i32 %n, i1 %unrelated) {
1872 ; CHECK-LABEL: @negative_WC_required(
1873 ; CHECK-NEXT: entry:
1874 ; CHECK-NEXT: [[TMP5:%.*]] = icmp eq i32 [[N:%.*]], 0
1875 ; CHECK-NEXT: br i1 [[TMP5]], label [[EXIT:%.*]], label [[LOOP_PREHEADER:%.*]]
1876 ; CHECK: loop.preheader:
1877 ; CHECK-NEXT: br label [[LOOP:%.*]]
1879 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ [[I_NEXT:%.*]], [[GUARDED:%.*]] ], [ 0, [[LOOP_PREHEADER]] ]
1880 ; CHECK-NEXT: [[WITHIN_BOUNDS:%.*]] = icmp ult i32 [[I]], [[LENGTH:%.*]]
1881 ; CHECK-NEXT: [[NOT_WIDENABLE:%.*]] = and i1 [[WITHIN_BOUNDS]], [[UNRELATED:%.*]]
1882 ; CHECK-NEXT: br i1 [[NOT_WIDENABLE]], label [[GUARDED]], label [[DEOPT:%.*]], !prof !0
1884 ; CHECK-NEXT: [[DEOPTCALL:%.*]] = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1885 ; CHECK-NEXT: ret i32 [[DEOPTCALL]]
1887 ; CHECK-NEXT: [[I_I64:%.*]] = zext i32 [[I]] to i64
1888 ; CHECK-NEXT: [[ARRAY_I_PTR:%.*]] = getelementptr inbounds i32, i32* [[ARRAY:%.*]], i64 [[I_I64]]
1889 ; CHECK-NEXT: store i32 0, i32* [[ARRAY_I_PTR]], align 4
1890 ; CHECK-NEXT: [[I_NEXT]] = add nuw i32 [[I]], 1
1891 ; CHECK-NEXT: [[CONTINUE:%.*]] = icmp ult i32 [[I_NEXT]], [[N]]
1892 ; CHECK-NEXT: br i1 [[CONTINUE]], label [[LOOP]], label [[EXIT_LOOPEXIT:%.*]], !prof !1
1893 ; CHECK: exit.loopexit:
1894 ; CHECK-NEXT: br label [[EXIT]]
1896 ; CHECK-NEXT: ret i32 0
1899 %tmp5 = icmp eq i32 %n, 0
1900 br i1 %tmp5, label %exit, label %loop.preheader
1902 loop.preheader: ; preds = %entry
1906 %i = phi i32 [ %i.next, %guarded ], [ 0, %loop.preheader ]
1907 %within.bounds = icmp ult i32 %i, %length
1908 %not_widenable = and i1 %within.bounds, %unrelated
1909 br i1 %not_widenable, label %guarded, label %deopt, !prof !0
1912 %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32(i32 9) [ "deopt"() ]
1915 guarded: ; preds = %loop
1916 %i.i64 = zext i32 %i to i64
1917 %array.i.ptr = getelementptr inbounds i32, i32* %array, i64 %i.i64
1918 store i32 0, i32* %array.i.ptr, align 4
1919 %i.next = add nuw i32 %i, 1
1920 %continue = icmp ult i32 %i.next, %n
1921 br i1 %continue, label %loop, label %exit, !prof !2
1923 exit: ; preds = %guarded, %entry
1928 declare i32 @llvm.experimental.deoptimize.i32(...)
1930 ; Function Attrs: inaccessiblememonly nounwind
1931 declare i1 @llvm.experimental.widenable.condition() #0
1933 attributes #0 = { inaccessiblememonly nounwind }
1935 !0 = !{!"branch_weights", i32 1048576, i32 1}
1936 !1 = !{i32 1, i32 -2147483648}
1937 !2 = !{!"branch_weights", i32 1024, i32 1}