1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=guard-widening < %s | FileCheck %s
4 declare void @llvm.experimental.guard(i1,...)
6 define void @f_0(i32 %x, ptr %length_buf) {
9 ; CHECK-NEXT: [[X_GW_FR:%.*]] = freeze i32 [[X:%.*]]
10 ; CHECK-NEXT: [[LENGTH:%.*]] = load i32, ptr [[LENGTH_BUF:%.*]], align 4, !range [[RNG0:![0-9]+]], !noundef !1
11 ; CHECK-NEXT: [[CHK0:%.*]] = icmp ult i32 [[X_GW_FR]], [[LENGTH]]
12 ; CHECK-NEXT: [[X_INC1:%.*]] = add i32 [[X_GW_FR]], 1
13 ; CHECK-NEXT: [[CHK1:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH]]
14 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[CHK0]], [[CHK1]]
15 ; CHECK-NEXT: [[X_INC2:%.*]] = add i32 [[X_GW_FR]], 2
16 ; CHECK-NEXT: [[CHK2:%.*]] = icmp ult i32 [[X_INC2]], [[LENGTH]]
17 ; CHECK-NEXT: [[WIDE_CHK1:%.*]] = and i1 [[CHK2]], [[CHK0]]
18 ; CHECK-NEXT: [[X_INC3:%.*]] = add i32 [[X_GW_FR]], 3
19 ; CHECK-NEXT: [[CHK3:%.*]] = icmp ult i32 [[X_INC3]], [[LENGTH]]
20 ; CHECK-NEXT: [[WIDE_CHK2:%.*]] = and i1 [[CHK3]], [[CHK0]]
21 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK2]]) [ "deopt"() ]
22 ; CHECK-NEXT: ret void
25 %length = load i32, ptr %length_buf, !range !0, !noundef !{}
26 %chk0 = icmp ult i32 %x, %length
27 call void(i1, ...) @llvm.experimental.guard(i1 %chk0) [ "deopt"() ]
29 %x.inc1 = add i32 %x, 1
30 %chk1 = icmp ult i32 %x.inc1, %length
31 call void(i1, ...) @llvm.experimental.guard(i1 %chk1) [ "deopt"() ]
33 %x.inc2 = add i32 %x, 2
34 %chk2 = icmp ult i32 %x.inc2, %length
35 call void(i1, ...) @llvm.experimental.guard(i1 %chk2) [ "deopt"() ]
37 %x.inc3 = add i32 %x, 3
38 %chk3 = icmp ult i32 %x.inc3, %length
39 call void(i1, ...) @llvm.experimental.guard(i1 %chk3) [ "deopt"() ]
43 define void @f_1(i32 %x, ptr %length_buf) {
46 ; CHECK-NEXT: [[X_GW_FR:%.*]] = freeze i32 [[X:%.*]]
47 ; CHECK-NEXT: [[LENGTH:%.*]] = load i32, ptr [[LENGTH_BUF:%.*]], align 4, !range [[RNG0]], !noundef !1
48 ; CHECK-NEXT: [[CHK0:%.*]] = icmp ult i32 [[X_GW_FR]], [[LENGTH]]
49 ; CHECK-NEXT: [[X_INC1:%.*]] = add i32 [[X_GW_FR]], 1
50 ; CHECK-NEXT: [[CHK1:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH]]
51 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[CHK0]], [[CHK1]]
52 ; CHECK-NEXT: [[X_INC2:%.*]] = add i32 [[X_INC1]], 2
53 ; CHECK-NEXT: [[CHK2:%.*]] = icmp ult i32 [[X_INC2]], [[LENGTH]]
54 ; CHECK-NEXT: [[WIDE_CHK1:%.*]] = and i1 [[CHK2]], [[CHK0]]
55 ; CHECK-NEXT: [[X_INC3:%.*]] = add i32 [[X_INC2]], 3
56 ; CHECK-NEXT: [[CHK3:%.*]] = icmp ult i32 [[X_INC3]], [[LENGTH]]
57 ; CHECK-NEXT: [[WIDE_CHK2:%.*]] = and i1 [[CHK3]], [[CHK0]]
58 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK2]]) [ "deopt"() ]
59 ; CHECK-NEXT: ret void
62 %length = load i32, ptr %length_buf, !range !0, !noundef !{}
63 %chk0 = icmp ult i32 %x, %length
64 call void(i1, ...) @llvm.experimental.guard(i1 %chk0) [ "deopt"() ]
66 %x.inc1 = add i32 %x, 1
67 %chk1 = icmp ult i32 %x.inc1, %length
68 call void(i1, ...) @llvm.experimental.guard(i1 %chk1) [ "deopt"() ]
70 %x.inc2 = add i32 %x.inc1, 2
71 %chk2 = icmp ult i32 %x.inc2, %length
72 call void(i1, ...) @llvm.experimental.guard(i1 %chk2) [ "deopt"() ]
74 %x.inc3 = add i32 %x.inc2, 3
75 %chk3 = icmp ult i32 %x.inc3, %length
76 call void(i1, ...) @llvm.experimental.guard(i1 %chk3) [ "deopt"() ]
80 define void @f_2(i32 %a, ptr %length_buf) {
83 ; CHECK-NEXT: [[A_GW_FR:%.*]] = freeze i32 [[A:%.*]]
84 ; CHECK-NEXT: [[X:%.*]] = and i32 [[A_GW_FR]], -256
85 ; CHECK-NEXT: [[LENGTH:%.*]] = load i32, ptr [[LENGTH_BUF:%.*]], align 4, !range [[RNG0]]
86 ; CHECK-NEXT: [[LENGTH_GW_FR:%.*]] = freeze i32 [[LENGTH]]
87 ; CHECK-NEXT: [[CHK0:%.*]] = icmp ult i32 [[X]], [[LENGTH_GW_FR]]
88 ; CHECK-NEXT: [[X_INC1:%.*]] = or i32 [[X]], 1
89 ; CHECK-NEXT: [[CHK1:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH_GW_FR]]
90 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[CHK0]], [[CHK1]]
91 ; CHECK-NEXT: [[X_INC2:%.*]] = or i32 [[X]], 2
92 ; CHECK-NEXT: [[CHK2:%.*]] = icmp ult i32 [[X_INC2]], [[LENGTH_GW_FR]]
93 ; CHECK-NEXT: [[WIDE_CHK1:%.*]] = and i1 [[WIDE_CHK]], [[CHK2]]
94 ; CHECK-NEXT: [[X_INC3:%.*]] = or i32 [[X]], 3
95 ; CHECK-NEXT: [[CHK3:%.*]] = icmp ult i32 [[X_INC3]], [[LENGTH_GW_FR]]
96 ; CHECK-NEXT: [[WIDE_CHK2:%.*]] = and i1 [[WIDE_CHK1]], [[CHK3]]
97 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK2]]) [ "deopt"() ]
98 ; CHECK-NEXT: ret void
101 %x = and i32 %a, 4294967040 ;; 4294967040 == 0xffffff00
102 %length = load i32, ptr %length_buf, !range !0
103 %chk0 = icmp ult i32 %x, %length
104 call void(i1, ...) @llvm.experimental.guard(i1 %chk0) [ "deopt"() ]
106 %x.inc1 = or i32 %x, 1
107 %chk1 = icmp ult i32 %x.inc1, %length
108 call void(i1, ...) @llvm.experimental.guard(i1 %chk1) [ "deopt"() ]
110 %x.inc2 = or i32 %x, 2
111 %chk2 = icmp ult i32 %x.inc2, %length
112 call void(i1, ...) @llvm.experimental.guard(i1 %chk2) [ "deopt"() ]
114 %x.inc3 = or i32 %x, 3
115 %chk3 = icmp ult i32 %x.inc3, %length
116 call void(i1, ...) @llvm.experimental.guard(i1 %chk3) [ "deopt"() ]
120 define void @f_3(i32 %a, ptr %length_buf) {
123 ; CHECK-NEXT: [[A_GW_FR:%.*]] = freeze i32 [[A:%.*]]
124 ; CHECK-NEXT: [[X:%.*]] = and i32 [[A_GW_FR]], -256
125 ; CHECK-NEXT: [[LENGTH:%.*]] = load i32, ptr [[LENGTH_BUF:%.*]], align 4, !range [[RNG0]], !noundef !1
126 ; CHECK-NEXT: [[CHK0:%.*]] = icmp ult i32 [[X]], [[LENGTH]]
127 ; CHECK-NEXT: [[X_INC1:%.*]] = add i32 [[X]], 1
128 ; CHECK-NEXT: [[CHK1:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH]]
129 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[CHK0]], [[CHK1]]
130 ; CHECK-NEXT: [[X_INC2:%.*]] = or i32 [[X_INC1]], 2
131 ; CHECK-NEXT: [[CHK2:%.*]] = icmp ult i32 [[X_INC2]], [[LENGTH]]
132 ; CHECK-NEXT: [[WIDE_CHK1:%.*]] = and i1 [[CHK2]], [[CHK0]]
133 ; CHECK-NEXT: [[X_INC3:%.*]] = add i32 [[X_INC2]], 3
134 ; CHECK-NEXT: [[CHK3:%.*]] = icmp ult i32 [[X_INC3]], [[LENGTH]]
135 ; CHECK-NEXT: [[WIDE_CHK2:%.*]] = and i1 [[CHK3]], [[CHK0]]
136 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK2]]) [ "deopt"() ]
137 ; CHECK-NEXT: ret void
140 %x = and i32 %a, 4294967040 ;; 4294967040 == 0xffffff00
141 %length = load i32, ptr %length_buf, !range !0, !noundef !{}
142 %chk0 = icmp ult i32 %x, %length
143 call void(i1, ...) @llvm.experimental.guard(i1 %chk0) [ "deopt"() ]
145 %x.inc1 = add i32 %x, 1
146 %chk1 = icmp ult i32 %x.inc1, %length
147 call void(i1, ...) @llvm.experimental.guard(i1 %chk1) [ "deopt"() ]
149 %x.inc2 = or i32 %x.inc1, 2
150 %chk2 = icmp ult i32 %x.inc2, %length
151 call void(i1, ...) @llvm.experimental.guard(i1 %chk2) [ "deopt"() ]
153 %x.inc3 = add i32 %x.inc2, 3
154 %chk3 = icmp ult i32 %x.inc3, %length
155 call void(i1, ...) @llvm.experimental.guard(i1 %chk3) [ "deopt"() ]
159 define void @f_4(i32 %x, ptr %length_buf) {
162 ; CHECK-NEXT: [[X_GW_FR:%.*]] = freeze i32 [[X:%.*]]
163 ; CHECK-NEXT: [[LENGTH:%.*]] = load i32, ptr [[LENGTH_BUF:%.*]], align 4, !range [[RNG0]], !noundef !1
164 ; CHECK-NEXT: [[CHK0:%.*]] = icmp ult i32 [[X_GW_FR]], [[LENGTH]]
165 ; CHECK-NEXT: [[X_INC1:%.*]] = add i32 [[X_GW_FR]], -1024
166 ; CHECK-NEXT: [[CHK1:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH]]
167 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[CHK0]], [[CHK1]]
168 ; CHECK-NEXT: [[X_INC2:%.*]] = add i32 [[X_GW_FR]], 2
169 ; CHECK-NEXT: [[CHK2:%.*]] = icmp ult i32 [[X_INC2]], [[LENGTH]]
170 ; CHECK-NEXT: [[WIDE_CHK1:%.*]] = and i1 [[CHK2]], [[CHK1]]
171 ; CHECK-NEXT: [[X_INC3:%.*]] = add i32 [[X_GW_FR]], 3
172 ; CHECK-NEXT: [[CHK3:%.*]] = icmp ult i32 [[X_INC3]], [[LENGTH]]
173 ; CHECK-NEXT: [[WIDE_CHK2:%.*]] = and i1 [[CHK3]], [[CHK1]]
174 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK2]]) [ "deopt"() ]
175 ; CHECK-NEXT: ret void
178 ; Note: we NOT guarding on "and i1 %chk3, %chk0", that would be incorrect.
180 %length = load i32, ptr %length_buf, !range !0, !noundef !{}
181 %chk0 = icmp ult i32 %x, %length
182 call void(i1, ...) @llvm.experimental.guard(i1 %chk0) [ "deopt"() ]
184 %x.inc1 = add i32 %x, -1024
185 %chk1 = icmp ult i32 %x.inc1, %length
186 call void(i1, ...) @llvm.experimental.guard(i1 %chk1) [ "deopt"() ]
188 %x.inc2 = add i32 %x, 2
189 %chk2 = icmp ult i32 %x.inc2, %length
190 call void(i1, ...) @llvm.experimental.guard(i1 %chk2) [ "deopt"() ]
192 %x.inc3 = add i32 %x, 3
193 %chk3 = icmp ult i32 %x.inc3, %length
194 call void(i1, ...) @llvm.experimental.guard(i1 %chk3) [ "deopt"() ]
198 define void @f_5(i32 %x, ptr %length_buf) {
201 ; CHECK-NEXT: [[X_GW_FR:%.*]] = freeze i32 [[X:%.*]]
202 ; CHECK-NEXT: [[LENGTH:%.*]] = load i32, ptr [[LENGTH_BUF:%.*]], align 4, !range [[RNG0]], !noundef !1
203 ; CHECK-NEXT: [[CHK0:%.*]] = icmp ult i32 [[X_GW_FR]], [[LENGTH]]
204 ; CHECK-NEXT: [[X_INC1:%.*]] = add i32 [[X_GW_FR]], 1
205 ; CHECK-NEXT: [[CHK1:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH]]
206 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[CHK0]], [[CHK1]]
207 ; CHECK-NEXT: [[X_INC2:%.*]] = add i32 [[X_INC1]], -200
208 ; CHECK-NEXT: [[CHK2:%.*]] = icmp ult i32 [[X_INC2]], [[LENGTH]]
209 ; CHECK-NEXT: [[WIDE_CHK1:%.*]] = and i1 [[CHK1]], [[CHK2]]
210 ; CHECK-NEXT: [[WIDE_CHK2:%.*]] = and i1 [[CHK1]], [[CHK2]]
211 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK2]]) [ "deopt"() ]
212 ; CHECK-NEXT: [[X_INC3:%.*]] = add i32 [[X_INC2]], 3
213 ; CHECK-NEXT: [[CHK3:%.*]] = icmp ult i32 [[X_INC3]], [[LENGTH]]
214 ; CHECK-NEXT: ret void
217 %length = load i32, ptr %length_buf, !range !0, !noundef !{}
218 %chk0 = icmp ult i32 %x, %length
219 call void(i1, ...) @llvm.experimental.guard(i1 %chk0) [ "deopt"() ]
221 %x.inc1 = add i32 %x, 1
222 %chk1 = icmp ult i32 %x.inc1, %length
223 call void(i1, ...) @llvm.experimental.guard(i1 %chk1) [ "deopt"() ]
225 %x.inc2 = add i32 %x.inc1, -200
226 %chk2 = icmp ult i32 %x.inc2, %length
227 call void(i1, ...) @llvm.experimental.guard(i1 %chk2) [ "deopt"() ]
229 %x.inc3 = add i32 %x.inc2, 3
230 %chk3 = icmp ult i32 %x.inc3, %length
231 call void(i1, ...) @llvm.experimental.guard(i1 %chk3) [ "deopt"() ]
236 ; Negative test: we can't merge these checks into
238 ; (%x + -2147483647) u< L && (%x + 3) u< L
240 ; because if %length == INT_MAX and %x == -3 then
242 ; (%x + -2147483647) == i32 2147483646 u< L (L is 2147483647)
245 ; But (%x + 2) == -1 is not u< L
247 define void @f_6(i32 %x, ptr %length_buf) {
250 ; CHECK-NEXT: [[X_GW_FR:%.*]] = freeze i32 [[X:%.*]]
251 ; CHECK-NEXT: [[LENGTH:%.*]] = load i32, ptr [[LENGTH_BUF:%.*]], align 4, !range [[RNG0]], !noundef !1
252 ; CHECK-NEXT: [[CHK0:%.*]] = icmp ult i32 [[X_GW_FR]], [[LENGTH]]
253 ; CHECK-NEXT: [[X_INC1:%.*]] = add i32 [[X_GW_FR]], -2147483647
254 ; CHECK-NEXT: [[CHK1:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH]]
255 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[CHK0]], [[CHK1]]
256 ; CHECK-NEXT: [[X_INC2:%.*]] = add i32 [[X_GW_FR]], 2
257 ; CHECK-NEXT: [[CHK2:%.*]] = icmp ult i32 [[X_INC2]], [[LENGTH]]
258 ; CHECK-NEXT: [[WIDE_CHK1:%.*]] = and i1 [[WIDE_CHK]], [[CHK2]]
259 ; CHECK-NEXT: [[X_INC3:%.*]] = add i32 [[X_GW_FR]], 3
260 ; CHECK-NEXT: [[CHK3:%.*]] = icmp ult i32 [[X_INC3]], [[LENGTH]]
261 ; CHECK-NEXT: [[WIDE_CHK2:%.*]] = and i1 [[WIDE_CHK1]], [[CHK3]]
262 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK2]]) [ "deopt"() ]
263 ; CHECK-NEXT: ret void
266 %length = load i32, ptr %length_buf, !range !0, !noundef !{}
267 %chk0 = icmp ult i32 %x, %length
268 call void(i1, ...) @llvm.experimental.guard(i1 %chk0) [ "deopt"() ]
270 %x.inc1 = add i32 %x, -2147483647 ;; -2147483647 == (i32 INT_MIN)+1 == -(i32 INT_MAX)
271 %chk1 = icmp ult i32 %x.inc1, %length
272 call void(i1, ...) @llvm.experimental.guard(i1 %chk1) [ "deopt"() ]
274 %x.inc2 = add i32 %x, 2
275 %chk2 = icmp ult i32 %x.inc2, %length
276 call void(i1, ...) @llvm.experimental.guard(i1 %chk2) [ "deopt"() ]
278 %x.inc3 = add i32 %x, 3
279 %chk3 = icmp ult i32 %x.inc3, %length
280 call void(i1, ...) @llvm.experimental.guard(i1 %chk3) [ "deopt"() ]
285 define void @f_7(i32 %x, ptr %length_buf) {
288 ; CHECK-NEXT: [[X_GW_FR:%.*]] = freeze i32 [[X:%.*]]
289 ; CHECK-NEXT: [[LENGTH_A:%.*]] = load volatile i32, ptr [[LENGTH_BUF:%.*]], align 4, !range [[RNG0]], !noundef !1
290 ; CHECK-NEXT: [[LENGTH_B:%.*]] = load volatile i32, ptr [[LENGTH_BUF]], align 4, !range [[RNG0]], !noundef !1
291 ; CHECK-NEXT: [[CHK0_A:%.*]] = icmp ult i32 [[X_GW_FR]], [[LENGTH_A]]
292 ; CHECK-NEXT: [[CHK0_B:%.*]] = icmp ult i32 [[X_GW_FR]], [[LENGTH_B]]
293 ; CHECK-NEXT: [[CHK0:%.*]] = and i1 [[CHK0_A]], [[CHK0_B]]
294 ; CHECK-NEXT: [[X_INC1:%.*]] = add i32 [[X_GW_FR]], 1
295 ; CHECK-NEXT: [[CHK1_B:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH_B]]
296 ; CHECK-NEXT: [[CHK1_A:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH_A]]
297 ; CHECK-NEXT: [[TMP0:%.*]] = and i1 [[CHK1_B]], [[CHK1_A]]
298 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[CHK0]], [[TMP0]]
299 ; CHECK-NEXT: [[X_INC2:%.*]] = add i32 [[X_GW_FR]], 2
300 ; CHECK-NEXT: [[CHK2_A:%.*]] = icmp ult i32 [[X_INC2]], [[LENGTH_A]]
301 ; CHECK-NEXT: [[TMP1:%.*]] = and i1 [[CHK2_A]], [[CHK0_A]]
302 ; CHECK-NEXT: [[TMP2:%.*]] = and i1 [[CHK0_B]], [[TMP1]]
303 ; CHECK-NEXT: [[CHK2_B:%.*]] = icmp ult i32 [[X_INC2]], [[LENGTH_B]]
304 ; CHECK-NEXT: [[WIDE_CHK1:%.*]] = and i1 [[CHK2_B]], [[TMP2]]
305 ; CHECK-NEXT: [[X_INC3:%.*]] = add i32 [[X_GW_FR]], 3
306 ; CHECK-NEXT: [[CHK3_A:%.*]] = icmp ult i32 [[X_INC3]], [[LENGTH_A]]
307 ; CHECK-NEXT: [[TMP3:%.*]] = and i1 [[CHK3_A]], [[CHK0_A]]
308 ; CHECK-NEXT: [[TMP4:%.*]] = and i1 [[CHK0_B]], [[TMP3]]
309 ; CHECK-NEXT: [[CHK3_B:%.*]] = icmp ult i32 [[X_INC3]], [[LENGTH_B]]
310 ; CHECK-NEXT: [[WIDE_CHK2:%.*]] = and i1 [[CHK3_B]], [[TMP4]]
311 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK2]]) [ "deopt"() ]
312 ; CHECK-NEXT: [[CHK1:%.*]] = and i1 [[CHK1_A]], [[CHK1_B]]
313 ; CHECK-NEXT: [[CHK2:%.*]] = and i1 [[CHK2_A]], [[CHK2_B]]
314 ; CHECK-NEXT: [[CHK3:%.*]] = and i1 [[CHK3_A]], [[CHK3_B]]
315 ; CHECK-NEXT: ret void
320 %length_a = load volatile i32, ptr %length_buf, !range !0, !noundef !{}
321 %length_b = load volatile i32, ptr %length_buf, !range !0, !noundef !{}
322 %chk0.a = icmp ult i32 %x, %length_a
323 %chk0.b = icmp ult i32 %x, %length_b
324 %chk0 = and i1 %chk0.a, %chk0.b
325 call void(i1, ...) @llvm.experimental.guard(i1 %chk0) [ "deopt"() ]
327 %x.inc1 = add i32 %x, 1
328 %chk1.a = icmp ult i32 %x.inc1, %length_a
329 %chk1.b = icmp ult i32 %x.inc1, %length_b
330 %chk1 = and i1 %chk1.a, %chk1.b
331 call void(i1, ...) @llvm.experimental.guard(i1 %chk1) [ "deopt"() ]
333 %x.inc2 = add i32 %x, 2
334 %chk2.a = icmp ult i32 %x.inc2, %length_a
335 %chk2.b = icmp ult i32 %x.inc2, %length_b
336 %chk2 = and i1 %chk2.a, %chk2.b
337 call void(i1, ...) @llvm.experimental.guard(i1 %chk2) [ "deopt"() ]
339 %x.inc3 = add i32 %x, 3
340 %chk3.a = icmp ult i32 %x.inc3, %length_a
341 %chk3.b = icmp ult i32 %x.inc3, %length_b
342 %chk3 = and i1 %chk3.a, %chk3.b
343 call void(i1, ...) @llvm.experimental.guard(i1 %chk3) [ "deopt"() ]
347 define void @f_8(i32 %x, ptr %length_buf) {
348 ; Check that we clean nuw nsw flags
351 ; CHECK-NEXT: [[X_GW_FR:%.*]] = freeze i32 [[X:%.*]]
352 ; CHECK-NEXT: [[LENGTH:%.*]] = load i32, ptr [[LENGTH_BUF:%.*]], align 4, !range [[RNG0]], !noundef !1
353 ; CHECK-NEXT: [[CHK0:%.*]] = icmp ult i32 [[X_GW_FR]], [[LENGTH]]
354 ; CHECK-NEXT: [[X_INC1:%.*]] = add i32 [[X_GW_FR]], 1
355 ; CHECK-NEXT: [[CHK1:%.*]] = icmp ult i32 [[X_INC1]], [[LENGTH]]
356 ; CHECK-NEXT: [[WIDE_CHK:%.*]] = and i1 [[CHK0]], [[CHK1]]
357 ; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[WIDE_CHK]]) [ "deopt"() ]
358 ; CHECK-NEXT: ret void
361 %length = load i32, ptr %length_buf, !range !0, !noundef !{}
362 %chk0 = icmp ult i32 %x, %length
363 call void(i1, ...) @llvm.experimental.guard(i1 %chk0) [ "deopt"() ]
365 %x.inc1 = add nuw nsw i32 %x, 1
366 %chk1 = icmp ult i32 %x.inc1, %length
367 call void(i1, ...) @llvm.experimental.guard(i1 %chk1) [ "deopt"() ]
373 !0 = !{i32 0, i32 2147483648}