1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=constraint-elimination -S %s | FileCheck %s
4 declare void @llvm.assume(i1)
6 define i1 @test_shl_const_nuw_unsigned_1(i8 %start, i8 %high) {
7 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_1(
9 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[START:%.*]], 4
10 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
11 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
12 ; CHECK-NEXT: ret i1 true
15 %start.shl.4 = shl nuw i8 %start, 4
16 %c.1 = icmp ult i8 %start.shl.4, %high
17 call void @llvm.assume(i1 %c.1)
19 %t.1 = icmp ult i8 %start, %high
23 define i1 @test_shl_const_nuw_unsigned_2(i8 %start, i8 %high) {
24 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_2(
26 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[START:%.*]], 4
27 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
28 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
29 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nuw i8 [[START]], 2
30 ; CHECK-NEXT: ret i1 true
33 %start.shl.4 = shl nuw i8 %start, 4
34 %c.1 = icmp ult i8 %start.shl.4, %high
35 call void @llvm.assume(i1 %c.1)
37 %start.shl.2 = shl nuw i8 %start, 2
38 %t = icmp ult i8 %start.shl.2, %high
42 define i1 @test_shl_const_nuw_unsigned_3(i8 %start, i8 %high) {
43 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_3(
45 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[START:%.*]], 4
46 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
47 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
48 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nuw i8 [[START]], 2
49 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
50 ; CHECK-NEXT: ret i1 true
53 %start.shl.4 = shl nuw i8 %start, 4
54 %c.1 = icmp ult i8 %start.shl.4, %high
55 call void @llvm.assume(i1 %c.1)
57 %start.shl.2 = shl nuw i8 %start, 2
58 %start.add.1 = add nuw i8 %start, %start
59 %t = icmp ule i8 %start.add.1, %start.shl.2
63 define i1 @test_shl_const_nuw_unsigned_4(i8 %start, i8 %high) {
64 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_4(
66 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[START:%.*]], 4
67 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
68 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
69 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nuw i8 [[START]], 2
70 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
71 ; CHECK-NEXT: [[F:%.*]] = icmp ult i8 [[START_ADD_1]], [[START_SHL_2]]
72 ; CHECK-NEXT: ret i1 [[F]]
75 %start.shl.4 = shl nuw i8 %start, 4
76 %c.1 = icmp ult i8 %start.shl.4, %high
77 call void @llvm.assume(i1 %c.1)
79 %start.shl.2 = shl nuw i8 %start, 2
80 %start.add.1 = add nuw i8 %start, %start
81 %f = icmp ult i8 %start.add.1, %start.shl.2
86 define i1 @test_shl_const_nuw_unsigned_5(i8 %start, i8 %high) {
87 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_5(
89 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[START:%.*]], 4
90 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
91 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
92 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
93 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nuw i8 [[START_ADD_1]], [[START_ADD_1]]
94 ; CHECK-NEXT: ret i1 true
97 %start.shl.4 = shl nuw i8 %start, 4
98 %c.1 = icmp ult i8 %start.shl.4, %high
99 call void @llvm.assume(i1 %c.1)
101 %start.add.1 = add nuw i8 %start, %start
102 %start.add.2 = add nuw i8 %start.add.1, %start.add.1
103 %t.4 = icmp ule i8 %start.add.2, %start.shl.4
107 define i1 @test_shl_const_nuw_unsigned_6(i8 %start, i8 %high) {
108 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_6(
110 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[START:%.*]], 4
111 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
112 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
113 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
114 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nuw i8 [[START_ADD_1]], [[START_ADD_1]]
115 ; CHECK-NEXT: [[F_2:%.*]] = icmp ult i8 [[START_ADD_2]], [[START_SHL_4]]
116 ; CHECK-NEXT: ret i1 [[F_2]]
119 %start.shl.4 = shl nuw i8 %start, 4
120 %c.1 = icmp ult i8 %start.shl.4, %high
121 call void @llvm.assume(i1 %c.1)
123 %start.add.1 = add nuw i8 %start, %start
124 %start.add.2 = add nuw i8 %start.add.1, %start.add.1
125 %f.2 = icmp ult i8 %start.add.2, %start.shl.4
129 define i1 @test_shl_const_nuw_unsigned_7(i8 %start, i8 %high) {
130 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_7(
132 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[START:%.*]], 4
133 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
134 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
135 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nuw i8 [[START]], 2
136 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
137 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nuw i8 [[START_ADD_1]], [[START_ADD_1]]
138 ; CHECK-NEXT: [[START_ADD_2_1:%.*]] = add nuw i8 [[START_ADD_2]], 1
139 ; CHECK-NEXT: [[F_3:%.*]] = icmp ule i8 [[START_ADD_2_1]], [[START_SHL_4]]
140 ; CHECK-NEXT: ret i1 [[F_3]]
143 %start.shl.4 = shl nuw i8 %start, 4
144 %c.1 = icmp ult i8 %start.shl.4, %high
145 call void @llvm.assume(i1 %c.1)
147 %start.shl.2 = shl nuw i8 %start, 2
148 %start.add.1 = add nuw i8 %start, %start
149 %start.add.2 = add nuw i8 %start.add.1, %start.add.1
150 %start.add.2.1 = add nuw i8 %start.add.2, 1
151 %f.3 = icmp ule i8 %start.add.2.1, %start.shl.4
155 define i1 @test_shl_const_nuw_unsigned_8(i8 %start, i8 %high) {
156 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_8(
158 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[START:%.*]], 4
159 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
160 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
161 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nuw i8 [[START]], 2
162 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
163 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nuw i8 [[START_ADD_1]], [[START_ADD_1]]
164 ; CHECK-NEXT: [[START_ADD_2_1:%.*]] = add nuw i8 [[START_ADD_2]], 1
165 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nuw i8 [[START]], 3
166 ; CHECK-NEXT: ret i1 true
169 %start.shl.4 = shl nuw i8 %start, 4
170 %c.1 = icmp ult i8 %start.shl.4, %high
171 call void @llvm.assume(i1 %c.1)
173 %start.shl.2 = shl nuw i8 %start, 2
174 %start.add.1 = add nuw i8 %start, %start
175 %start.add.2 = add nuw i8 %start.add.1, %start.add.1
176 %start.add.2.1 = add nuw i8 %start.add.2, 1
177 %start.shl.3 = shl nuw i8 %start, 3
178 %t.5 = icmp ule i8 %start.add.1, %start.shl.3
182 define i1 @test_shl_const_nuw_unsigned_9(i8 %start, i8 %high) {
183 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_9(
185 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[START:%.*]], 4
186 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
187 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
188 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nuw i8 [[START]], 2
189 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
190 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nuw i8 [[START_ADD_1]], [[START_ADD_1]]
191 ; CHECK-NEXT: [[START_ADD_2_1:%.*]] = add nuw i8 [[START_ADD_2]], 1
192 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nuw i8 [[START]], 3
193 ; CHECK-NEXT: [[F_5:%.*]] = icmp ult i8 [[START_ADD_2]], [[START_SHL_3]]
194 ; CHECK-NEXT: ret i1 [[F_5]]
197 %start.shl.4 = shl nuw i8 %start, 4
198 %c.1 = icmp ult i8 %start.shl.4, %high
199 call void @llvm.assume(i1 %c.1)
201 %start.shl.2 = shl nuw i8 %start, 2
202 %start.add.1 = add nuw i8 %start, %start
203 %start.add.2 = add nuw i8 %start.add.1, %start.add.1
204 %start.add.2.1 = add nuw i8 %start.add.2, 1
205 %start.shl.3 = shl nuw i8 %start, 3
206 %f.5 = icmp ult i8 %start.add.2, %start.shl.3
210 define i1 @test_shl_const_nuw_unsigned_10(i8 %start, i8 %high) {
211 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_10(
213 ; CHECK-NEXT: [[START_SHL_5:%.*]] = shl nuw i8 [[START:%.*]], 5
214 ; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8 [[START]], [[START_SHL_5]]
215 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_0]])
216 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nuw i8 [[START]], 3
217 ; CHECK-NEXT: ret i1 true
220 %start.shl.5 = shl nuw i8 %start, 5
221 %c.0 = icmp ult i8 %start, %start.shl.5
222 call void @llvm.assume(i1 %c.0)
224 %start.shl.3 = shl nuw i8 %start, 3
225 %t.1 = icmp ule i8 %start.shl.3, %start.shl.5
229 define i1 @test_shl_const_nuw_unsigned_11(i8 %start, i8 %high) {
230 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_11(
232 ; CHECK-NEXT: [[START_SHL_5:%.*]] = shl nuw i8 [[START:%.*]], 5
233 ; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8 [[START]], [[START_SHL_5]]
234 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_0]])
235 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nuw i8 [[START]], 3
236 ; CHECK-NEXT: ret i1 false
239 %start.shl.5 = shl nuw i8 %start, 5
240 %c.0 = icmp ult i8 %start, %start.shl.5
241 call void @llvm.assume(i1 %c.0)
243 %start.shl.3 = shl nuw i8 %start, 3
244 %c.1 = icmp ule i8 %start.shl.5, %start.shl.3
248 define i1 @test_shl_const_nuw_unsigned_12(i8 %start) {
249 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_12(
251 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nuw i8 [[START:%.*]], 3
252 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START]], [[START_SHL_3]]
253 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
254 ; CHECK-NEXT: [[START_SHL_5:%.*]] = shl nuw i8 [[START]], 5
255 ; CHECK-NEXT: ret i1 true
258 %start.shl.3 = shl nuw i8 %start, 3
259 %c.1 = icmp ult i8 %start, %start.shl.3
260 call void @llvm.assume(i1 %c.1)
262 %start.shl.5 = shl nuw i8 %start, 5
263 %t.1 = icmp ule i8 %start.shl.3, %start.shl.5
267 define i1 @test_shl_const_nuw_unsigned_13(i8 %start) {
268 ; CHECK-LABEL: @test_shl_const_nuw_unsigned_13(
270 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl i8 [[START:%.*]], 3
271 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START]], [[START_SHL_3]]
272 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
273 ; CHECK-NEXT: [[START_SHL_5:%.*]] = shl i8 [[START]], 5
274 ; CHECK-NEXT: [[F_1:%.*]] = icmp ule i8 [[START_SHL_5]], [[START_SHL_3]]
275 ; CHECK-NEXT: ret i1 [[F_1]]
278 %start.shl.3 = shl i8 %start, 3
279 %c.1 = icmp ult i8 %start, %start.shl.3
280 call void @llvm.assume(i1 %c.1)
282 %start.shl.5 = shl i8 %start, 5
283 %f.1 = icmp ule i8 %start.shl.5, %start.shl.3
287 define i1 @test_shl_add_const_nuw_unsigned_1(i8 %start, i8 %high) {
288 ; CHECK-LABEL: @test_shl_add_const_nuw_unsigned_1(
290 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[START:%.*]], 3
291 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[ADD]], 4
292 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
293 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
294 ; CHECK-NEXT: ret i1 true
297 %add = add nuw i8 %start, 3
298 %start.shl.4 = shl nuw i8 %add, 4
299 %c.1 = icmp ult i8 %start.shl.4, %high
300 call void @llvm.assume(i1 %c.1)
302 %t.1 = icmp ult i8 %start, %high
306 define i1 @test_shl_add_const_nuw_unsigned_2(i8 %start, i8 %high) {
307 ; CHECK-LABEL: @test_shl_add_const_nuw_unsigned_2(
309 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[START:%.*]], 3
310 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[ADD]], 4
311 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
312 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
313 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nuw i8 [[START]], 2
314 ; CHECK-NEXT: ret i1 true
317 %add = add nuw i8 %start, 3
318 %start.shl.4 = shl nuw i8 %add, 4
319 %c.1 = icmp ult i8 %start.shl.4, %high
320 call void @llvm.assume(i1 %c.1)
322 %start.shl.2 = shl nuw i8 %start, 2
323 %t.2 = icmp ult i8 %start.shl.2, %high
327 define i1 @test_shl_add_const_nuw_unsigned_3(i8 %start, i8 %high) {
328 ; CHECK-LABEL: @test_shl_add_const_nuw_unsigned_3(
330 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[START:%.*]], 3
331 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[ADD]], 4
332 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
333 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
334 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
335 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nuw i8 [[START_ADD_1]], [[START_ADD_1]]
336 ; CHECK-NEXT: ret i1 true
339 %add = add nuw i8 %start, 3
340 %start.shl.4 = shl nuw i8 %add, 4
341 %c.1 = icmp ult i8 %start.shl.4, %high
342 call void @llvm.assume(i1 %c.1)
344 %start.add.1 = add nuw i8 %start, %start
345 %start.add.2 = add nuw i8 %start.add.1, %start.add.1
346 %t.3 = icmp ule i8 %start.add.2, %start.shl.4
350 define i1 @test_shl_add_const_nuw_unsigned_4(i8 %start, i8 %high) {
351 ; CHECK-LABEL: @test_shl_add_const_nuw_unsigned_4(
353 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[START:%.*]], 3
354 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[ADD]], 4
355 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
356 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
357 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nuw i8 [[START]], 2
358 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
359 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nuw i8 [[START_ADD_1]], [[START_ADD_1]]
360 ; CHECK-NEXT: ret i1 true
363 %add = add nuw i8 %start, 3
364 %start.shl.4 = shl nuw i8 %add, 4
365 %c.1 = icmp ult i8 %start.shl.4, %high
366 call void @llvm.assume(i1 %c.1)
368 %start.shl.2 = shl nuw i8 %start, 2
369 %start.add.1 = add nuw i8 %start, %start
370 %start.add.2 = add nuw i8 %start.add.1, %start.add.1
371 %t.4 = icmp ult i8 %start.add.2, %start.shl.4
375 define i1 @test_shl_add_const_nuw_unsigned_5(i8 %start, i8 %high) {
376 ; CHECK-LABEL: @test_shl_add_const_nuw_unsigned_5(
378 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[START:%.*]], 3
379 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[ADD]], 4
380 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
381 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
382 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
383 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nuw i8 [[START_ADD_1]], [[START_ADD_1]]
384 ; CHECK-NEXT: [[START_ADD_2_12:%.*]] = add nuw i8 [[START_ADD_2]], 12
385 ; CHECK-NEXT: ret i1 true
388 %add = add nuw i8 %start, 3
389 %start.shl.4 = shl nuw i8 %add, 4
390 %c.1 = icmp ult i8 %start.shl.4, %high
391 call void @llvm.assume(i1 %c.1)
393 %start.add.1 = add nuw i8 %start, %start
394 %start.add.2 = add nuw i8 %start.add.1, %start.add.1
395 %start.add.2.12 = add nuw i8 %start.add.2, 12
396 %t.5 = icmp ule i8 %start.add.2.12, %start.shl.4
400 define i1 @test_shl_add_const_nuw_unsigned_6(i8 %start, i8 %high) {
401 ; CHECK-LABEL: @test_shl_add_const_nuw_unsigned_6(
403 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i8 [[START:%.*]], 3
404 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nuw i8 [[ADD]], 4
405 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
406 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
407 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nuw i8 [[START]], [[START]]
408 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nuw i8 [[START_ADD_1]], [[START_ADD_1]]
409 ; CHECK-NEXT: [[START_ADD_2_13:%.*]] = add nuw i8 [[START_ADD_2]], 13
410 ; CHECK-NEXT: ret i1 true
413 %add = add nuw i8 %start, 3
414 %start.shl.4 = shl nuw i8 %add, 4
415 %c.1 = icmp ult i8 %start.shl.4, %high
416 call void @llvm.assume(i1 %c.1)
418 %start.add.1 = add nuw i8 %start, %start
419 %start.add.2 = add nuw i8 %start.add.1, %start.add.1
420 %start.add.2.13 = add nuw i8 %start.add.2, 13
421 %f.1 = icmp ule i8 %start.add.2.13, %start.shl.4
425 define i1 @test_shl_const_nsw_unsigned_1(i8 %start, i8 %high) {
426 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_1(
428 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[START:%.*]], 4
429 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
430 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
431 ; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[START]], [[HIGH]]
432 ; CHECK-NEXT: ret i1 [[T_1]]
435 %start.shl.4 = shl nsw i8 %start, 4
436 %c.1 = icmp ult i8 %start.shl.4, %high
437 call void @llvm.assume(i1 %c.1)
439 %t.1 = icmp ult i8 %start, %high
443 define i1 @test_shl_const_nsw_unsigned_2(i8 %start, i8 %high) {
444 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_2(
446 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[START:%.*]], 4
447 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
448 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
449 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nsw i8 [[START]], 2
450 ; CHECK-NEXT: [[T:%.*]] = icmp ult i8 [[START_SHL_2]], [[HIGH]]
451 ; CHECK-NEXT: ret i1 [[T]]
454 %start.shl.4 = shl nsw i8 %start, 4
455 %c.1 = icmp ult i8 %start.shl.4, %high
456 call void @llvm.assume(i1 %c.1)
458 %start.shl.2 = shl nsw i8 %start, 2
459 %t = icmp ult i8 %start.shl.2, %high
463 define i1 @test_shl_const_nsw_unsigned_3(i8 %start, i8 %high) {
464 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_3(
466 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[START:%.*]], 4
467 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
468 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
469 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nsw i8 [[START]], 2
470 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
471 ; CHECK-NEXT: [[T:%.*]] = icmp ule i8 [[START_ADD_1]], [[START_SHL_2]]
472 ; CHECK-NEXT: ret i1 [[T]]
475 %start.shl.4 = shl nsw i8 %start, 4
476 %c.1 = icmp ult i8 %start.shl.4, %high
477 call void @llvm.assume(i1 %c.1)
479 %start.shl.2 = shl nsw i8 %start, 2
480 %start.add.1 = add nsw i8 %start, %start
481 %t = icmp ule i8 %start.add.1, %start.shl.2
486 define i1 @test_shl_const_nsw_unsigned_4(i8 %start, i8 %high) {
487 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_4(
489 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[START:%.*]], 4
490 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
491 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
492 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nsw i8 [[START]], 2
493 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
494 ; CHECK-NEXT: [[F:%.*]] = icmp ult i8 [[START_ADD_1]], [[START_SHL_2]]
495 ; CHECK-NEXT: ret i1 [[F]]
498 %start.shl.4 = shl nsw i8 %start, 4
499 %c.1 = icmp ult i8 %start.shl.4, %high
500 call void @llvm.assume(i1 %c.1)
502 %start.shl.2 = shl nsw i8 %start, 2
503 %start.add.1 = add nsw i8 %start, %start
504 %f = icmp ult i8 %start.add.1, %start.shl.2
509 define i1 @test_shl_const_nsw_unsigned_5(i8 %start, i8 %high) {
510 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_5(
512 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[START:%.*]], 4
513 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
514 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
515 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
516 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nsw i8 [[START_ADD_1]], [[START_ADD_1]]
517 ; CHECK-NEXT: [[T_4:%.*]] = icmp ule i8 [[START_ADD_2]], [[START_SHL_4]]
518 ; CHECK-NEXT: ret i1 [[T_4]]
521 %start.shl.4 = shl nsw i8 %start, 4
522 %c.1 = icmp ult i8 %start.shl.4, %high
523 call void @llvm.assume(i1 %c.1)
525 %start.add.1 = add nsw i8 %start, %start
526 %start.add.2 = add nsw i8 %start.add.1, %start.add.1
527 %t.4 = icmp ule i8 %start.add.2, %start.shl.4
531 define i1 @test_shl_const_nsw_unsigned_6(i8 %start, i8 %high) {
532 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_6(
534 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[START:%.*]], 4
535 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
536 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
537 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
538 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nsw i8 [[START_ADD_1]], [[START_ADD_1]]
539 ; CHECK-NEXT: [[F_2:%.*]] = icmp ult i8 [[START_ADD_2]], [[START_SHL_4]]
540 ; CHECK-NEXT: ret i1 [[F_2]]
543 %start.shl.4 = shl nsw i8 %start, 4
544 %c.1 = icmp ult i8 %start.shl.4, %high
545 call void @llvm.assume(i1 %c.1)
547 %start.add.1 = add nsw i8 %start, %start
548 %start.add.2 = add nsw i8 %start.add.1, %start.add.1
549 %f.2 = icmp ult i8 %start.add.2, %start.shl.4
553 define i1 @test_shl_const_nsw_unsigned_7(i8 %start, i8 %high) {
554 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_7(
556 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[START:%.*]], 4
557 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
558 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
559 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nsw i8 [[START]], 2
560 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
561 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nsw i8 [[START_ADD_1]], [[START_ADD_1]]
562 ; CHECK-NEXT: [[START_ADD_2_1:%.*]] = add nsw i8 [[START_ADD_2]], 1
563 ; CHECK-NEXT: [[F_3:%.*]] = icmp ule i8 [[START_ADD_2_1]], [[START_SHL_4]]
564 ; CHECK-NEXT: ret i1 [[F_3]]
567 %start.shl.4 = shl nsw i8 %start, 4
568 %c.1 = icmp ult i8 %start.shl.4, %high
569 call void @llvm.assume(i1 %c.1)
571 %start.shl.2 = shl nsw i8 %start, 2
572 %start.add.1 = add nsw i8 %start, %start
573 %start.add.2 = add nsw i8 %start.add.1, %start.add.1
574 %start.add.2.1 = add nsw i8 %start.add.2, 1
575 %f.3 = icmp ule i8 %start.add.2.1, %start.shl.4
579 define i1 @test_shl_const_nsw_unsigned_8(i8 %start, i8 %high) {
580 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_8(
582 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[START:%.*]], 4
583 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
584 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
585 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nsw i8 [[START]], 2
586 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
587 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nsw i8 [[START_ADD_1]], [[START_ADD_1]]
588 ; CHECK-NEXT: [[START_ADD_2_1:%.*]] = add nsw i8 [[START_ADD_2]], 1
589 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nsw i8 [[START]], 3
590 ; CHECK-NEXT: [[T_5:%.*]] = icmp ule i8 [[START_ADD_1]], [[START_SHL_3]]
591 ; CHECK-NEXT: ret i1 [[T_5]]
594 %start.shl.4 = shl nsw i8 %start, 4
595 %c.1 = icmp ult i8 %start.shl.4, %high
596 call void @llvm.assume(i1 %c.1)
598 %start.shl.2 = shl nsw i8 %start, 2
599 %start.add.1 = add nsw i8 %start, %start
600 %start.add.2 = add nsw i8 %start.add.1, %start.add.1
601 %start.add.2.1 = add nsw i8 %start.add.2, 1
602 %start.shl.3 = shl nsw i8 %start, 3
603 %t.5 = icmp ule i8 %start.add.1, %start.shl.3
607 define i1 @test_shl_const_nsw_unsigned_9(i8 %start, i8 %high) {
608 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_9(
610 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[START:%.*]], 4
611 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
612 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
613 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nsw i8 [[START]], 2
614 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
615 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nsw i8 [[START_ADD_1]], [[START_ADD_1]]
616 ; CHECK-NEXT: [[START_ADD_2_1:%.*]] = add nsw i8 [[START_ADD_2]], 1
617 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nsw i8 [[START]], 3
618 ; CHECK-NEXT: [[F_5:%.*]] = icmp ult i8 [[START_ADD_2]], [[START_SHL_3]]
619 ; CHECK-NEXT: ret i1 [[F_5]]
622 %start.shl.4 = shl nsw i8 %start, 4
623 %c.1 = icmp ult i8 %start.shl.4, %high
624 call void @llvm.assume(i1 %c.1)
626 %start.shl.2 = shl nsw i8 %start, 2
627 %start.add.1 = add nsw i8 %start, %start
628 %start.add.2 = add nsw i8 %start.add.1, %start.add.1
629 %start.add.2.1 = add nsw i8 %start.add.2, 1
630 %start.shl.3 = shl nsw i8 %start, 3
631 %f.5 = icmp ult i8 %start.add.2, %start.shl.3
635 define i1 @test_shl_const_nsw_unsigned_10(i8 %start, i8 %high) {
636 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_10(
638 ; CHECK-NEXT: [[START_SHL_5:%.*]] = shl nsw i8 [[START:%.*]], 5
639 ; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8 [[START]], [[START_SHL_5]]
640 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_0]])
641 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nsw i8 [[START]], 3
642 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i8 [[START_SHL_3]], [[START_SHL_5]]
643 ; CHECK-NEXT: ret i1 [[T_1]]
646 %start.shl.5 = shl nsw i8 %start, 5
647 %c.0 = icmp ult i8 %start, %start.shl.5
648 call void @llvm.assume(i1 %c.0)
650 %start.shl.3 = shl nsw i8 %start, 3
651 %t.1 = icmp ule i8 %start.shl.3, %start.shl.5
655 define i1 @test_shl_const_nsw_unsigned_11(i8 %start, i8 %high) {
656 ; CHECK-LABEL: @test_shl_const_nsw_unsigned_11(
658 ; CHECK-NEXT: [[START_SHL_5:%.*]] = shl nsw i8 [[START:%.*]], 5
659 ; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8 [[START]], [[START_SHL_5]]
660 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_0]])
661 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nsw i8 [[START]], 3
662 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8 [[START_SHL_5]], [[START_SHL_3]]
663 ; CHECK-NEXT: ret i1 [[C_1]]
666 %start.shl.5 = shl nsw i8 %start, 5
667 %c.0 = icmp ult i8 %start, %start.shl.5
668 call void @llvm.assume(i1 %c.0)
670 %start.shl.3 = shl nsw i8 %start, 3
671 %c.1 = icmp ule i8 %start.shl.5, %start.shl.3
675 define i1 @test_shl_add_const_nsw_unsigned_1(i8 %start, i8 %high) {
676 ; CHECK-LABEL: @test_shl_add_const_nsw_unsigned_1(
678 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[START:%.*]], 3
679 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[ADD]], 4
680 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
681 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
682 ; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[START]], [[HIGH]]
683 ; CHECK-NEXT: ret i1 [[T_1]]
686 %add = add nsw i8 %start, 3
687 %start.shl.4 = shl nsw i8 %add, 4
688 %c.1 = icmp ult i8 %start.shl.4, %high
689 call void @llvm.assume(i1 %c.1)
691 %t.1 = icmp ult i8 %start, %high
695 define i1 @test_shl_add_const_nsw_unsigned_2(i8 %start, i8 %high) {
696 ; CHECK-LABEL: @test_shl_add_const_nsw_unsigned_2(
698 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[START:%.*]], 3
699 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[ADD]], 4
700 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
701 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
702 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nsw i8 [[START]], 2
703 ; CHECK-NEXT: [[T_2:%.*]] = icmp ult i8 [[START_SHL_2]], [[HIGH]]
704 ; CHECK-NEXT: ret i1 [[T_2]]
707 %add = add nsw i8 %start, 3
708 %start.shl.4 = shl nsw i8 %add, 4
709 %c.1 = icmp ult i8 %start.shl.4, %high
710 call void @llvm.assume(i1 %c.1)
712 %start.shl.2 = shl nsw i8 %start, 2
713 %t.2 = icmp ult i8 %start.shl.2, %high
717 define i1 @test_shl_add_const_nsw_unsigned_3(i8 %start, i8 %high) {
718 ; CHECK-LABEL: @test_shl_add_const_nsw_unsigned_3(
720 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[START:%.*]], 3
721 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[ADD]], 4
722 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
723 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
724 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
725 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nsw i8 [[START_ADD_1]], [[START_ADD_1]]
726 ; CHECK-NEXT: [[T_3:%.*]] = icmp ule i8 [[START_ADD_2]], [[START_SHL_4]]
727 ; CHECK-NEXT: ret i1 [[T_3]]
730 %add = add nsw i8 %start, 3
731 %start.shl.4 = shl nsw i8 %add, 4
732 %c.1 = icmp ult i8 %start.shl.4, %high
733 call void @llvm.assume(i1 %c.1)
735 %start.add.1 = add nsw i8 %start, %start
736 %start.add.2 = add nsw i8 %start.add.1, %start.add.1
737 %t.3 = icmp ule i8 %start.add.2, %start.shl.4
741 define i1 @test_shl_add_const_nsw_unsigned_4(i8 %start, i8 %high) {
742 ; CHECK-LABEL: @test_shl_add_const_nsw_unsigned_4(
744 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[START:%.*]], 3
745 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[ADD]], 4
746 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
747 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
748 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl nsw i8 [[START]], 2
749 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
750 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nsw i8 [[START_ADD_1]], [[START_ADD_1]]
751 ; CHECK-NEXT: [[T_4:%.*]] = icmp ult i8 [[START_ADD_2]], [[START_SHL_4]]
752 ; CHECK-NEXT: ret i1 [[T_4]]
755 %add = add nsw i8 %start, 3
756 %start.shl.4 = shl nsw i8 %add, 4
757 %c.1 = icmp ult i8 %start.shl.4, %high
758 call void @llvm.assume(i1 %c.1)
760 %start.shl.2 = shl nsw i8 %start, 2
761 %start.add.1 = add nsw i8 %start, %start
762 %start.add.2 = add nsw i8 %start.add.1, %start.add.1
763 %t.4 = icmp ult i8 %start.add.2, %start.shl.4
767 define i1 @test_shl_add_const_nsw_unsigned_5(i8 %start, i8 %high) {
768 ; CHECK-LABEL: @test_shl_add_const_nsw_unsigned_5(
770 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[START:%.*]], 3
771 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[ADD]], 4
772 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
773 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
774 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
775 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nsw i8 [[START_ADD_1]], [[START_ADD_1]]
776 ; CHECK-NEXT: [[START_ADD_2_12:%.*]] = add nsw i8 [[START_ADD_2]], 12
777 ; CHECK-NEXT: [[T_5:%.*]] = icmp ule i8 [[START_ADD_2_12]], [[START_SHL_4]]
778 ; CHECK-NEXT: ret i1 [[T_5]]
781 %add = add nsw i8 %start, 3
782 %start.shl.4 = shl nsw i8 %add, 4
783 %c.1 = icmp ult i8 %start.shl.4, %high
784 call void @llvm.assume(i1 %c.1)
786 %start.add.1 = add nsw i8 %start, %start
787 %start.add.2 = add nsw i8 %start.add.1, %start.add.1
788 %start.add.2.12 = add nsw i8 %start.add.2, 12
789 %t.5 = icmp ule i8 %start.add.2.12, %start.shl.4
793 define i1 @test_shl_add_const_nsw_unsigned_6(i8 %start, i8 %high) {
794 ; CHECK-LABEL: @test_shl_add_const_nsw_unsigned_6(
796 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i8 [[START:%.*]], 3
797 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl nsw i8 [[ADD]], 4
798 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
799 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
800 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add nsw i8 [[START]], [[START]]
801 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add nsw i8 [[START_ADD_1]], [[START_ADD_1]]
802 ; CHECK-NEXT: [[START_ADD_2_13:%.*]] = add nsw i8 [[START_ADD_2]], 13
803 ; CHECK-NEXT: [[F_1:%.*]] = icmp ule i8 [[START_ADD_2_13]], [[START_SHL_4]]
804 ; CHECK-NEXT: ret i1 [[F_1]]
807 %add = add nsw i8 %start, 3
808 %start.shl.4 = shl nsw i8 %add, 4
809 %c.1 = icmp ult i8 %start.shl.4, %high
810 call void @llvm.assume(i1 %c.1)
812 %start.add.1 = add nsw i8 %start, %start
813 %start.add.2 = add nsw i8 %start.add.1, %start.add.1
814 %start.add.2.13 = add nsw i8 %start.add.2, 13
815 %f.1 = icmp ule i8 %start.add.2.13, %start.shl.4
819 define i1 @test_shl_const_no_nuw_unsigned_1(i8 %start, i8 %high) {
820 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_1(
822 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[START:%.*]], 4
823 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
824 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
825 ; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[START]], [[HIGH]]
826 ; CHECK-NEXT: ret i1 [[T_1]]
829 %start.shl.4 = shl i8 %start, 4
830 %c.1 = icmp ult i8 %start.shl.4, %high
831 call void @llvm.assume(i1 %c.1)
833 %t.1 = icmp ult i8 %start, %high
837 define i1 @test_shl_const_no_nuw_unsigned_2(i8 %start, i8 %high) {
838 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_2(
840 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[START:%.*]], 4
841 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
842 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
843 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl i8 [[START]], 2
844 ; CHECK-NEXT: [[T:%.*]] = icmp ult i8 [[START_SHL_2]], [[HIGH]]
845 ; CHECK-NEXT: ret i1 [[T]]
848 %start.shl.4 = shl i8 %start, 4
849 %c.1 = icmp ult i8 %start.shl.4, %high
850 call void @llvm.assume(i1 %c.1)
852 %start.shl.2 = shl i8 %start, 2
853 %t = icmp ult i8 %start.shl.2, %high
857 define i1 @test_shl_const_no_nuw_unsigned_3(i8 %start, i8 %high) {
858 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_3(
860 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[START:%.*]], 4
861 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
862 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
863 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl i8 [[START]], 2
864 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
865 ; CHECK-NEXT: [[T:%.*]] = icmp ule i8 [[START_ADD_1]], [[START_SHL_2]]
866 ; CHECK-NEXT: ret i1 [[T]]
869 %start.shl.4 = shl i8 %start, 4
870 %c.1 = icmp ult i8 %start.shl.4, %high
871 call void @llvm.assume(i1 %c.1)
873 %start.shl.2 = shl i8 %start, 2
874 %start.add.1 = add i8 %start, %start
875 %t = icmp ule i8 %start.add.1, %start.shl.2
880 define i1 @test_shl_const_no_nuw_unsigned_4(i8 %start, i8 %high) {
881 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_4(
883 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[START:%.*]], 4
884 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
885 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
886 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl i8 [[START]], 2
887 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
888 ; CHECK-NEXT: [[F:%.*]] = icmp ult i8 [[START_ADD_1]], [[START_SHL_2]]
889 ; CHECK-NEXT: ret i1 [[F]]
892 %start.shl.4 = shl i8 %start, 4
893 %c.1 = icmp ult i8 %start.shl.4, %high
894 call void @llvm.assume(i1 %c.1)
896 %start.shl.2 = shl i8 %start, 2
897 %start.add.1 = add i8 %start, %start
898 %f = icmp ult i8 %start.add.1, %start.shl.2
903 define i1 @test_shl_const_no_nuw_unsigned_5(i8 %start, i8 %high) {
904 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_5(
906 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[START:%.*]], 4
907 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
908 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
909 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
910 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add i8 [[START_ADD_1]], [[START_ADD_1]]
911 ; CHECK-NEXT: [[T_4:%.*]] = icmp ule i8 [[START_ADD_2]], [[START_SHL_4]]
912 ; CHECK-NEXT: ret i1 [[T_4]]
915 %start.shl.4 = shl i8 %start, 4
916 %c.1 = icmp ult i8 %start.shl.4, %high
917 call void @llvm.assume(i1 %c.1)
919 %start.add.1 = add i8 %start, %start
920 %start.add.2 = add i8 %start.add.1, %start.add.1
921 %t.4 = icmp ule i8 %start.add.2, %start.shl.4
925 define i1 @test_shl_const_no_nuw_unsigned_6(i8 %start, i8 %high) {
926 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_6(
928 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[START:%.*]], 4
929 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
930 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
931 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
932 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add i8 [[START_ADD_1]], [[START_ADD_1]]
933 ; CHECK-NEXT: [[F_2:%.*]] = icmp ult i8 [[START_ADD_2]], [[START_SHL_4]]
934 ; CHECK-NEXT: ret i1 [[F_2]]
937 %start.shl.4 = shl i8 %start, 4
938 %c.1 = icmp ult i8 %start.shl.4, %high
939 call void @llvm.assume(i1 %c.1)
941 %start.add.1 = add i8 %start, %start
942 %start.add.2 = add i8 %start.add.1, %start.add.1
943 %f.2 = icmp ult i8 %start.add.2, %start.shl.4
947 define i1 @test_shl_const_no_nuw_unsigned_7(i8 %start, i8 %high) {
948 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_7(
950 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[START:%.*]], 4
951 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
952 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
953 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl i8 [[START]], 2
954 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
955 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add i8 [[START_ADD_1]], [[START_ADD_1]]
956 ; CHECK-NEXT: [[START_ADD_2_1:%.*]] = add i8 [[START_ADD_2]], 1
957 ; CHECK-NEXT: [[F_3:%.*]] = icmp ule i8 [[START_ADD_2_1]], [[START_SHL_4]]
958 ; CHECK-NEXT: ret i1 [[F_3]]
961 %start.shl.4 = shl i8 %start, 4
962 %c.1 = icmp ult i8 %start.shl.4, %high
963 call void @llvm.assume(i1 %c.1)
965 %start.shl.2 = shl i8 %start, 2
966 %start.add.1 = add i8 %start, %start
967 %start.add.2 = add i8 %start.add.1, %start.add.1
968 %start.add.2.1 = add i8 %start.add.2, 1
969 %f.3 = icmp ule i8 %start.add.2.1, %start.shl.4
973 define i1 @test_shl_const_no_nuw_unsigned_8(i8 %start, i8 %high) {
974 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_8(
976 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[START:%.*]], 4
977 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
978 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
979 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl i8 [[START]], 2
980 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
981 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add i8 [[START_ADD_1]], [[START_ADD_1]]
982 ; CHECK-NEXT: [[START_ADD_2_1:%.*]] = add i8 [[START_ADD_2]], 1
983 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl i8 [[START]], 3
984 ; CHECK-NEXT: [[T_5:%.*]] = icmp ule i8 [[START_ADD_1]], [[START_SHL_3]]
985 ; CHECK-NEXT: ret i1 [[T_5]]
988 %start.shl.4 = shl i8 %start, 4
989 %c.1 = icmp ult i8 %start.shl.4, %high
990 call void @llvm.assume(i1 %c.1)
992 %start.shl.2 = shl i8 %start, 2
993 %start.add.1 = add i8 %start, %start
994 %start.add.2 = add i8 %start.add.1, %start.add.1
995 %start.add.2.1 = add i8 %start.add.2, 1
996 %start.shl.3 = shl i8 %start, 3
997 %t.5 = icmp ule i8 %start.add.1, %start.shl.3
1001 define i1 @test_shl_const_no_nuw_unsigned_9(i8 %start, i8 %high) {
1002 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_9(
1003 ; CHECK-NEXT: entry:
1004 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[START:%.*]], 4
1005 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
1006 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1007 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl i8 [[START]], 2
1008 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
1009 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add i8 [[START_ADD_1]], [[START_ADD_1]]
1010 ; CHECK-NEXT: [[START_ADD_2_1:%.*]] = add i8 [[START_ADD_2]], 1
1011 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl i8 [[START]], 3
1012 ; CHECK-NEXT: [[F_5:%.*]] = icmp ult i8 [[START_ADD_2]], [[START_SHL_3]]
1013 ; CHECK-NEXT: ret i1 [[F_5]]
1016 %start.shl.4 = shl i8 %start, 4
1017 %c.1 = icmp ult i8 %start.shl.4, %high
1018 call void @llvm.assume(i1 %c.1)
1020 %start.shl.2 = shl i8 %start, 2
1021 %start.add.1 = add i8 %start, %start
1022 %start.add.2 = add i8 %start.add.1, %start.add.1
1023 %start.add.2.1 = add i8 %start.add.2, 1
1024 %start.shl.3 = shl i8 %start, 3
1025 %f.5 = icmp ult i8 %start.add.2, %start.shl.3
1029 define i1 @test_shl_const_no_nuw_unsigned_10(i8 %start, i8 %high) {
1030 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_10(
1031 ; CHECK-NEXT: entry:
1032 ; CHECK-NEXT: [[START_SHL_5:%.*]] = shl i8 [[START:%.*]], 5
1033 ; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8 [[START]], [[START_SHL_5]]
1034 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_0]])
1035 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl i8 [[START]], 3
1036 ; CHECK-NEXT: [[T_1:%.*]] = icmp ule i8 [[START_SHL_3]], [[START_SHL_5]]
1037 ; CHECK-NEXT: ret i1 [[T_1]]
1040 %start.shl.5 = shl i8 %start, 5
1041 %c.0 = icmp ult i8 %start, %start.shl.5
1042 call void @llvm.assume(i1 %c.0)
1044 %start.shl.3 = shl i8 %start, 3
1045 %t.1 = icmp ule i8 %start.shl.3, %start.shl.5
1049 define i1 @test_shl_const_no_nuw_unsigned_11(i8 %start, i8 %high) {
1050 ; CHECK-LABEL: @test_shl_const_no_nuw_unsigned_11(
1051 ; CHECK-NEXT: entry:
1052 ; CHECK-NEXT: [[START_SHL_5:%.*]] = shl i8 [[START:%.*]], 5
1053 ; CHECK-NEXT: [[C_0:%.*]] = icmp ult i8 [[START]], [[START_SHL_5]]
1054 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_0]])
1055 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl i8 [[START]], 3
1056 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8 [[START_SHL_5]], [[START_SHL_3]]
1057 ; CHECK-NEXT: ret i1 [[C_1]]
1060 %start.shl.5 = shl i8 %start, 5
1061 %c.0 = icmp ult i8 %start, %start.shl.5
1062 call void @llvm.assume(i1 %c.0)
1064 %start.shl.3 = shl i8 %start, 3
1065 %c.1 = icmp ule i8 %start.shl.5, %start.shl.3
1069 define i1 @test_shl_add_const_no_nuw_unsigned_1(i8 %start, i8 %high) {
1070 ; CHECK-LABEL: @test_shl_add_const_no_nuw_unsigned_1(
1071 ; CHECK-NEXT: entry:
1072 ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[START:%.*]], 3
1073 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[ADD]], 4
1074 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
1075 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1076 ; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8 [[START]], [[HIGH]]
1077 ; CHECK-NEXT: ret i1 [[T_1]]
1080 %add = add i8 %start, 3
1081 %start.shl.4 = shl i8 %add, 4
1082 %c.1 = icmp ult i8 %start.shl.4, %high
1083 call void @llvm.assume(i1 %c.1)
1085 %t.1 = icmp ult i8 %start, %high
1089 define i1 @test_shl_add_const_no_nuw_unsigned_2(i8 %start, i8 %high) {
1090 ; CHECK-LABEL: @test_shl_add_const_no_nuw_unsigned_2(
1091 ; CHECK-NEXT: entry:
1092 ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[START:%.*]], 3
1093 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[ADD]], 4
1094 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
1095 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1096 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl i8 [[START]], 2
1097 ; CHECK-NEXT: [[T_2:%.*]] = icmp ult i8 [[START_SHL_2]], [[HIGH]]
1098 ; CHECK-NEXT: ret i1 [[T_2]]
1101 %add = add i8 %start, 3
1102 %start.shl.4 = shl i8 %add, 4
1103 %c.1 = icmp ult i8 %start.shl.4, %high
1104 call void @llvm.assume(i1 %c.1)
1106 %start.shl.2 = shl i8 %start, 2
1107 %t.2 = icmp ult i8 %start.shl.2, %high
1111 define i1 @test_shl_add_const_no_nuw_unsigned_3(i8 %start, i8 %high) {
1112 ; CHECK-LABEL: @test_shl_add_const_no_nuw_unsigned_3(
1113 ; CHECK-NEXT: entry:
1114 ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[START:%.*]], 3
1115 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[ADD]], 4
1116 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
1117 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1118 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
1119 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add i8 [[START_ADD_1]], [[START_ADD_1]]
1120 ; CHECK-NEXT: [[T_3:%.*]] = icmp ule i8 [[START_ADD_2]], [[START_SHL_4]]
1121 ; CHECK-NEXT: ret i1 [[T_3]]
1124 %add = add i8 %start, 3
1125 %start.shl.4 = shl i8 %add, 4
1126 %c.1 = icmp ult i8 %start.shl.4, %high
1127 call void @llvm.assume(i1 %c.1)
1129 %start.add.1 = add i8 %start, %start
1130 %start.add.2 = add i8 %start.add.1, %start.add.1
1131 %t.3 = icmp ule i8 %start.add.2, %start.shl.4
1135 define i1 @test_shl_add_const_no_nuw_unsigned_4(i8 %start, i8 %high) {
1136 ; CHECK-LABEL: @test_shl_add_const_no_nuw_unsigned_4(
1137 ; CHECK-NEXT: entry:
1138 ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[START:%.*]], 3
1139 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[ADD]], 4
1140 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
1141 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1142 ; CHECK-NEXT: [[START_SHL_2:%.*]] = shl i8 [[START]], 2
1143 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
1144 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add i8 [[START_ADD_1]], [[START_ADD_1]]
1145 ; CHECK-NEXT: [[T_4:%.*]] = icmp ult i8 [[START_ADD_2]], [[START_SHL_4]]
1146 ; CHECK-NEXT: ret i1 [[T_4]]
1149 %add = add i8 %start, 3
1150 %start.shl.4 = shl i8 %add, 4
1151 %c.1 = icmp ult i8 %start.shl.4, %high
1152 call void @llvm.assume(i1 %c.1)
1154 %start.shl.2 = shl i8 %start, 2
1155 %start.add.1 = add i8 %start, %start
1156 %start.add.2 = add i8 %start.add.1, %start.add.1
1157 %t.4 = icmp ult i8 %start.add.2, %start.shl.4
1161 define i1 @test_shl_add_const_no_nuw_unsigned_5(i8 %start, i8 %high) {
1162 ; CHECK-LABEL: @test_shl_add_const_no_nuw_unsigned_5(
1163 ; CHECK-NEXT: entry:
1164 ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[START:%.*]], 3
1165 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[ADD]], 4
1166 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
1167 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1168 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
1169 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add i8 [[START_ADD_1]], [[START_ADD_1]]
1170 ; CHECK-NEXT: [[START_ADD_2_12:%.*]] = add i8 [[START_ADD_2]], 12
1171 ; CHECK-NEXT: [[T_5:%.*]] = icmp ule i8 [[START_ADD_2_12]], [[START_SHL_4]]
1172 ; CHECK-NEXT: ret i1 [[T_5]]
1175 %add = add i8 %start, 3
1176 %start.shl.4 = shl i8 %add, 4
1177 %c.1 = icmp ult i8 %start.shl.4, %high
1178 call void @llvm.assume(i1 %c.1)
1180 %start.add.1 = add i8 %start, %start
1181 %start.add.2 = add i8 %start.add.1, %start.add.1
1182 %start.add.2.12 = add i8 %start.add.2, 12
1183 %t.5 = icmp ule i8 %start.add.2.12, %start.shl.4
1187 define i1 @test_shl_add_const_no_nuw_unsigned_6(i8 %start, i8 %high) {
1188 ; CHECK-LABEL: @test_shl_add_const_no_nuw_unsigned_6(
1189 ; CHECK-NEXT: entry:
1190 ; CHECK-NEXT: [[ADD:%.*]] = add i8 [[START:%.*]], 3
1191 ; CHECK-NEXT: [[START_SHL_4:%.*]] = shl i8 [[ADD]], 4
1192 ; CHECK-NEXT: [[C_1:%.*]] = icmp ult i8 [[START_SHL_4]], [[HIGH:%.*]]
1193 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1194 ; CHECK-NEXT: [[START_ADD_1:%.*]] = add i8 [[START]], [[START]]
1195 ; CHECK-NEXT: [[START_ADD_2:%.*]] = add i8 [[START_ADD_1]], [[START_ADD_1]]
1196 ; CHECK-NEXT: [[START_ADD_2_13:%.*]] = add i8 [[START_ADD_2]], 13
1197 ; CHECK-NEXT: [[F_1:%.*]] = icmp ule i8 [[START_ADD_2_13]], [[START_SHL_4]]
1198 ; CHECK-NEXT: ret i1 [[F_1]]
1201 %add = add i8 %start, 3
1202 %start.shl.4 = shl i8 %add, 4
1203 %c.1 = icmp ult i8 %start.shl.4, %high
1204 call void @llvm.assume(i1 %c.1)
1206 %start.add.1 = add i8 %start, %start
1207 %start.add.2 = add i8 %start.add.1, %start.add.1
1208 %start.add.2.13 = add i8 %start.add.2, 13
1209 %f.1 = icmp ule i8 %start.add.2.13, %start.shl.4
1213 define i1 @shl_overflow(i64 %start) {
1214 ; CHECK-LABEL: @shl_overflow(
1215 ; CHECK-NEXT: entry:
1216 ; CHECK-NEXT: [[PRE_COND:%.*]] = icmp ugt i64 [[START:%.*]], 0
1217 ; CHECK-NEXT: br i1 [[PRE_COND]], label [[MAIN:%.*]], label [[EXIT:%.*]]
1219 ; CHECK-NEXT: [[TMP0:%.*]] = shl nuw nsw i64 [[START]], -1
1220 ; CHECK-NEXT: [[TMP1:%.*]] = icmp uge i64 [[TMP0]], [[START]]
1221 ; CHECK-NEXT: ret i1 [[TMP1]]
1223 ; CHECK-NEXT: ret i1 false
1226 %pre.cond = icmp ugt i64 %start, 0
1227 br i1 %pre.cond, label %main, label %exit
1230 %0 = shl nuw nsw i64 %start, -1
1231 %1 = icmp uge i64 %0, %start
1239 define i1 @shl_overflow_2() {
1240 ; CHECK-LABEL: @shl_overflow_2(
1241 ; CHECK-NEXT: entry:
1242 ; CHECK-NEXT: [[SHL_UB:%.*]] = shl nuw nsw i256 0, 64
1243 ; CHECK-NEXT: [[SHL_CMP:%.*]] = icmp uge i256 [[SHL_UB]], 0
1244 ; CHECK-NEXT: ret i1 [[SHL_CMP]]
1247 %shl.ub = shl nuw nsw i256 0, 64
1248 %shl.cmp = icmp uge i256 %shl.ub, 0
1252 define i1 @shl_overflow_3() {
1253 ; CHECK-LABEL: @shl_overflow_3(
1254 ; CHECK-NEXT: entry:
1255 ; CHECK-NEXT: [[SHL_UB:%.*]] = shl nuw nsw i256 0, 65
1256 ; CHECK-NEXT: [[SHL_CMP:%.*]] = icmp uge i256 [[SHL_UB]], 0
1257 ; CHECK-NEXT: ret i1 [[SHL_CMP]]
1260 %shl.ub = shl nuw nsw i256 0, 65
1261 %shl.cmp = icmp uge i256 %shl.ub, 0
1265 define i1 @shl_55() {
1266 ; CHECK-LABEL: @shl_55(
1267 ; CHECK-NEXT: entry:
1268 ; CHECK-NEXT: [[SHL_UB:%.*]] = shl nuw nsw i256 1, 55
1269 ; CHECK-NEXT: [[SHL_CMP:%.*]] = icmp uge i256 [[SHL_UB]], 1
1270 ; CHECK-NEXT: ret i1 [[SHL_CMP]]
1273 %shl.ub = shl nuw nsw i256 1, 55
1274 %shl.cmp = icmp uge i256 %shl.ub, 1
1278 define i1 @shl_nsw_x8_slt_x7(i8 %start, i8 %high) {
1279 ; CHECK-LABEL: @shl_nsw_x8_slt_x7(
1280 ; CHECK-NEXT: [[C_0:%.*]] = icmp sge i8 [[HIGH:%.*]], 0
1281 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_0]])
1282 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nsw i8 [[START:%.*]], 3
1283 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt i8 [[START_SHL_3]], [[HIGH]]
1284 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1285 ; CHECK-NEXT: [[START_MUL_7:%.*]] = mul nsw i8 [[START]], 7
1286 ; CHECK-NEXT: ret i1 true
1288 %c.0 = icmp sge i8 %high, 0
1289 call void @llvm.assume(i1 %c.0)
1291 %start.shl.3 = shl nsw i8 %start, 3
1292 %c.1 = icmp slt i8 %start.shl.3, %high
1293 call void @llvm.assume(i1 %c.1)
1295 %start.mul.7 = mul nsw i8 %start, 7
1296 %t.1 = icmp slt i8 %start.mul.7, %high
1300 define i1 @shl_nsw_x8_not_slt_x9(i8 %start, i8 %high) {
1301 ; CHECK-LABEL: @shl_nsw_x8_not_slt_x9(
1302 ; CHECK-NEXT: [[C_0:%.*]] = icmp sge i8 [[HIGH:%.*]], 0
1303 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_0]])
1304 ; CHECK-NEXT: [[START_SHL_3:%.*]] = shl nsw i8 [[START:%.*]], 3
1305 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt i8 [[START_SHL_3]], [[HIGH]]
1306 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1307 ; CHECK-NEXT: [[START_MUL_9:%.*]] = mul nsw i8 [[START]], 9
1308 ; CHECK-NEXT: [[T_1:%.*]] = icmp slt i8 [[START_MUL_9]], [[HIGH]]
1309 ; CHECK-NEXT: ret i1 [[T_1]]
1311 %c.0 = icmp sge i8 %high, 0
1312 call void @llvm.assume(i1 %c.0)
1314 %start.shl.3 = shl nsw i8 %start, 3
1315 %c.1 = icmp slt i8 %start.shl.3, %high
1316 call void @llvm.assume(i1 %c.1)
1318 %start.mul.9 = mul nsw i8 %start, 9
1319 %t.1 = icmp slt i8 %start.mul.9, %high
1323 define i1 @shl_nsw_sign_implication(i8 %x) {
1324 ; CHECK-LABEL: @shl_nsw_sign_implication(
1325 ; CHECK-NEXT: [[SHL:%.*]] = shl nsw i8 [[X:%.*]], 2
1326 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i8 [[X]], 0
1327 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF:%.*]], label [[ELSE:%.*]]
1329 ; CHECK-NEXT: ret i1 true
1331 ; CHECK-NEXT: ret i1 true
1333 %shl = shl nsw i8 %x, 2
1334 %cmp1 = icmp slt i8 %x, 0
1335 br i1 %cmp1, label %if, label %else
1338 %cmp2 = icmp slt i8 %shl, 0
1342 %cmp3 = icmp sge i8 %shl, 0
1346 define i1 @shl_nsw_by_bw_minus_1(i64 %x) {
1347 ; CHECK-LABEL: @shl_nsw_by_bw_minus_1(
1348 ; CHECK-NEXT: [[X_SHL:%.*]] = shl nsw i64 [[X:%.*]], 63
1349 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt i64 [[X_SHL]], 0
1350 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1351 ; CHECK-NEXT: [[T_1:%.*]] = icmp slt i64 [[X]], 0
1352 ; CHECK-NEXT: ret i1 [[T_1]]
1354 %x.shl = shl nsw i64 %x, 63
1355 %c.1 = icmp slt i64 %x.shl, 0
1356 call void @llvm.assume(i1 %c.1)
1358 %t.1 = icmp slt i64 %x, 0
1362 ; Shift returns poison in this case, just make sure we don't crash.
1363 define i1 @shl_nsw_by_bw(i64 %x) {
1364 ; CHECK-LABEL: @shl_nsw_by_bw(
1365 ; CHECK-NEXT: [[X_SHL:%.*]] = shl nsw i64 [[X:%.*]], 64
1366 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt i64 [[X_SHL]], 0
1367 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1368 ; CHECK-NEXT: [[T_1:%.*]] = icmp slt i64 [[X]], 0
1369 ; CHECK-NEXT: ret i1 [[T_1]]
1371 %x.shl = shl nsw i64 %x, 64
1372 %c.1 = icmp slt i64 %x.shl, 0
1373 call void @llvm.assume(i1 %c.1)
1375 %t.1 = icmp slt i64 %x, 0
1379 ; Shift returns poison in this case, just make sure we don't crash.
1380 define i1 @shl_nsw_by_bw_plus_1(i64 %x) {
1381 ; CHECK-LABEL: @shl_nsw_by_bw_plus_1(
1382 ; CHECK-NEXT: [[X_SHL:%.*]] = shl nsw i64 [[X:%.*]], 65
1383 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt i64 [[X_SHL]], 0
1384 ; CHECK-NEXT: call void @llvm.assume(i1 [[C_1]])
1385 ; CHECK-NEXT: [[T_1:%.*]] = icmp slt i64 [[X]], 0
1386 ; CHECK-NEXT: ret i1 [[T_1]]
1388 %x.shl = shl nsw i64 %x, 65
1389 %c.1 = icmp slt i64 %x.shl, 0
1390 call void @llvm.assume(i1 %c.1)
1392 %t.1 = icmp slt i64 %x, 0