1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -instcombine < %s | FileCheck %s
4 define i64 @test_shl_nuw_nsw__all_are_safe(i32 %x, i64 %y) {
5 ; CHECK-LABEL: @test_shl_nuw_nsw__all_are_safe(
6 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
7 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 60
8 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
9 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
10 ; CHECK-NEXT: ret i64 [[TMP4]]
13 %2 = shl nuw nsw i32 %1, 2
14 %3 = zext i32 %2 to i64
15 %4 = icmp eq i32 %1, 0
17 %6 = select i1 %4, i64 %y, i64 %5
21 define i64 @test_shl_nuw__all_are_safe(i32 %x, i64 %y) {
22 ; CHECK-LABEL: @test_shl_nuw__all_are_safe(
23 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
24 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 60
25 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
26 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
27 ; CHECK-NEXT: ret i64 [[TMP4]]
30 %2 = shl nuw i32 %1, 2
31 %3 = zext i32 %2 to i64
32 %4 = icmp eq i32 %1, 0
34 %6 = select i1 %4, i64 %y, i64 %5
38 define i64 @test_shl_nsw__all_are_safe(i32 %x, i64 %y) {
39 ; CHECK-LABEL: @test_shl_nsw__all_are_safe(
40 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
41 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 60
42 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
43 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
44 ; CHECK-NEXT: ret i64 [[TMP4]]
47 %2 = shl nsw i32 %1, 2
48 %3 = zext i32 %2 to i64
49 %4 = icmp eq i32 %1, 0
51 %6 = select i1 %4, i64 %y, i64 %5
55 define i64 @test_shl__all_are_safe(i32 %x, i64 %y) {
56 ; CHECK-LABEL: @test_shl__all_are_safe(
57 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
58 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 60
59 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
60 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
61 ; CHECK-NEXT: ret i64 [[TMP4]]
65 %3 = zext i32 %2 to i64
66 %4 = icmp eq i32 %1, 0
68 %6 = select i1 %4, i64 %y, i64 %5
72 define i64 @test_shl_nuw_nsw__nuw_is_safe(i32 %x, i64 %y) {
73 ; CHECK-LABEL: @test_shl_nuw_nsw__nuw_is_safe(
74 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
75 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
76 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
77 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
78 ; CHECK-NEXT: ret i64 [[TMP4]]
80 %1 = and i32 %x, 1073741822
81 %2 = shl nuw nsw i32 %1, 2
82 %3 = zext i32 %2 to i64
83 %4 = icmp eq i32 %1, 0
85 %6 = select i1 %4, i64 %y, i64 %5
89 define i64 @test_shl_nuw__nuw_is_safe(i32 %x, i64 %y) {
90 ; CHECK-LABEL: @test_shl_nuw__nuw_is_safe(
91 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
92 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
93 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
94 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
95 ; CHECK-NEXT: ret i64 [[TMP4]]
97 %1 = and i32 %x, 1073741822
98 %2 = shl nuw i32 %1, 2
99 %3 = zext i32 %2 to i64
100 %4 = icmp eq i32 %1, 0
102 %6 = select i1 %4, i64 %y, i64 %5
106 define i64 @test_shl_nsw__nuw_is_safe(i32 %x, i64 %y) {
107 ; CHECK-LABEL: @test_shl_nsw__nuw_is_safe(
108 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
109 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
110 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
111 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
112 ; CHECK-NEXT: ret i64 [[TMP4]]
114 %1 = and i32 %x, 1073741822
115 %2 = shl nsw i32 %1, 2
116 %3 = zext i32 %2 to i64
117 %4 = icmp eq i32 %1, 0
119 %6 = select i1 %4, i64 %y, i64 %5
123 define i64 @test_shl__nuw_is_safe(i32 %x, i64 %y) {
124 ; CHECK-LABEL: @test_shl__nuw_is_safe(
125 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
126 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
127 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
128 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
129 ; CHECK-NEXT: ret i64 [[TMP4]]
131 %1 = and i32 %x, 1073741822
133 %3 = zext i32 %2 to i64
134 %4 = icmp eq i32 %1, 0
136 %6 = select i1 %4, i64 %y, i64 %5
140 define i32 @test_shl_nuw_nsw__nsw_is_safe(i32 %x) {
141 ; CHECK-LABEL: @test_shl_nuw_nsw__nsw_is_safe(
142 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[X:%.*]], -83886080
143 ; CHECK-NEXT: [[TMP2:%.*]] = shl nsw i32 [[TMP1]], 2
144 ; CHECK-NEXT: [[TMP3:%.*]] = mul i32 [[TMP2]], [[TMP1]]
145 ; CHECK-NEXT: [[TMP4:%.*]] = mul i32 [[TMP3]], [[TMP2]]
146 ; CHECK-NEXT: ret i32 [[TMP4]]
148 %1 = or i32 %x, -83886080
149 %2 = icmp eq i32 %1, -83886079
150 %3 = shl nuw nsw i32 %1, 2
151 %4 = select i1 %2, i32 -335544316, i32 %3
157 define i32 @test_shl_nuw__nsw_is_safe(i32 %x) {
158 ; CHECK-LABEL: @test_shl_nuw__nsw_is_safe(
159 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[X:%.*]], -83886080
160 ; CHECK-NEXT: [[TMP2:%.*]] = shl nsw i32 [[TMP1]], 2
161 ; CHECK-NEXT: [[TMP3:%.*]] = mul i32 [[TMP2]], [[TMP1]]
162 ; CHECK-NEXT: [[TMP4:%.*]] = mul i32 [[TMP3]], [[TMP2]]
163 ; CHECK-NEXT: ret i32 [[TMP4]]
165 %1 = or i32 %x, -83886080
166 %2 = icmp eq i32 %1, -83886079
167 %3 = shl nuw i32 %1, 2
168 %4 = select i1 %2, i32 -335544316, i32 %3
174 define i32 @test_shl_nsw__nsw_is_safe(i32 %x) {
175 ; CHECK-LABEL: @test_shl_nsw__nsw_is_safe(
176 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[X:%.*]], -83886080
177 ; CHECK-NEXT: [[TMP2:%.*]] = shl nsw i32 [[TMP1]], 2
178 ; CHECK-NEXT: [[TMP3:%.*]] = mul i32 [[TMP2]], [[TMP1]]
179 ; CHECK-NEXT: [[TMP4:%.*]] = mul i32 [[TMP3]], [[TMP2]]
180 ; CHECK-NEXT: ret i32 [[TMP4]]
182 %1 = or i32 %x, -83886080
183 %2 = icmp eq i32 %1, -83886079
184 %3 = shl nsw i32 %1, 2
185 %4 = select i1 %2, i32 -335544316, i32 %3
191 define i32 @test_shl__nsw_is_safe(i32 %x) {
192 ; CHECK-LABEL: @test_shl__nsw_is_safe(
193 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[X:%.*]], -83886080
194 ; CHECK-NEXT: [[TMP2:%.*]] = shl nsw i32 [[TMP1]], 2
195 ; CHECK-NEXT: [[TMP3:%.*]] = mul i32 [[TMP2]], [[TMP1]]
196 ; CHECK-NEXT: [[TMP4:%.*]] = mul i32 [[TMP3]], [[TMP2]]
197 ; CHECK-NEXT: ret i32 [[TMP4]]
199 %1 = or i32 %x, -83886080
200 %2 = icmp eq i32 %1, -83886079
202 %4 = select i1 %2, i32 -335544316, i32 %3
209 define i64 @test_shl_nuw_nsw__none_are_safe(i32 %x, i64 %y) {
210 ; CHECK-LABEL: @test_shl_nuw_nsw__none_are_safe(
211 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
212 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
213 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
214 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
215 ; CHECK-NEXT: ret i64 [[TMP4]]
217 %1 = and i32 %x, 4294967294
218 %2 = shl nuw nsw i32 %1, 2
219 %3 = zext i32 %2 to i64
220 %4 = icmp eq i32 %1, 0
222 %6 = select i1 %4, i64 %y, i64 %5
226 define i64 @test_shl_nuw__none_are_safe(i32 %x, i64 %y) {
227 ; CHECK-LABEL: @test_shl_nuw__none_are_safe(
228 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
229 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
230 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
231 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
232 ; CHECK-NEXT: ret i64 [[TMP4]]
234 %1 = and i32 %x, 4294967294
235 %2 = shl nuw i32 %1, 2
236 %3 = zext i32 %2 to i64
237 %4 = icmp eq i32 %1, 0
239 %6 = select i1 %4, i64 %y, i64 %5
243 define i64 @test_shl_nsw__none_are_safe(i32 %x, i64 %y) {
244 ; CHECK-LABEL: @test_shl_nsw__none_are_safe(
245 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
246 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
247 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
248 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
249 ; CHECK-NEXT: ret i64 [[TMP4]]
251 %1 = and i32 %x, 4294967294
252 %2 = shl nsw i32 %1, 2
253 %3 = zext i32 %2 to i64
254 %4 = icmp eq i32 %1, 0
256 %6 = select i1 %4, i64 %y, i64 %5
260 define i64 @test_shl__none_are_safe(i32 %x, i64 %y) {
261 ; CHECK-LABEL: @test_shl__none_are_safe(
262 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
263 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
264 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
265 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
266 ; CHECK-NEXT: ret i64 [[TMP4]]
268 %1 = and i32 %x, 4294967294
270 %3 = zext i32 %2 to i64
271 %4 = icmp eq i32 %1, 0
273 %6 = select i1 %4, i64 %y, i64 %5
277 define i64 @test_lshr_exact__exact_is_safe(i32 %x, i64 %y) {
278 ; CHECK-LABEL: @test_lshr_exact__exact_is_safe(
279 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 2
280 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 15
281 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
282 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
283 ; CHECK-NEXT: ret i64 [[TMP4]]
286 %2 = lshr exact i32 %1, 2
287 %3 = zext i32 %2 to i64
288 %4 = icmp eq i32 %1, 0
290 %6 = select i1 %4, i64 %y, i64 %5
294 define i64 @test_lshr__exact_is_safe(i32 %x, i64 %y) {
295 ; CHECK-LABEL: @test_lshr__exact_is_safe(
296 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 2
297 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 15
298 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
299 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
300 ; CHECK-NEXT: ret i64 [[TMP4]]
304 %3 = zext i32 %2 to i64
305 %4 = icmp eq i32 %1, 0
307 %6 = select i1 %4, i64 %y, i64 %5
311 define i64 @test_lshr_exact__exact_is_unsafe(i32 %x, i64 %y) {
312 ; CHECK-LABEL: @test_lshr_exact__exact_is_unsafe(
313 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 2
314 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 15
315 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
316 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
317 ; CHECK-NEXT: ret i64 [[TMP4]]
320 %2 = lshr exact i32 %1, 2
321 %3 = zext i32 %2 to i64
322 %4 = icmp eq i32 %1, 0
324 %6 = select i1 %4, i64 %y, i64 %5
328 define i64 @test_lshr__exact_is_unsafe(i32 %x, i64 %y) {
329 ; CHECK-LABEL: @test_lshr__exact_is_unsafe(
330 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 2
331 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 15
332 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
333 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
334 ; CHECK-NEXT: ret i64 [[TMP4]]
338 %3 = zext i32 %2 to i64
339 %4 = icmp eq i32 %1, 0
341 %6 = select i1 %4, i64 %y, i64 %5
345 define i64 @test_ashr_exact__exact_is_safe(i32 %x, i64 %y) {
346 ; CHECK-LABEL: @test_ashr_exact__exact_is_safe(
347 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 2
348 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -536870897
349 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
350 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
351 ; CHECK-NEXT: ret i64 [[TMP4]]
353 %1 = and i32 %x, -2147483588
354 %2 = ashr exact i32 %1, 2
355 %3 = zext i32 %2 to i64
356 %4 = icmp eq i32 %1, 0
358 %6 = select i1 %4, i64 %y, i64 %5
362 define i64 @test_ashr__exact_is_safe(i32 %x, i64 %y) {
363 ; CHECK-LABEL: @test_ashr__exact_is_safe(
364 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 2
365 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -536870897
366 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
367 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
368 ; CHECK-NEXT: ret i64 [[TMP4]]
370 %1 = and i32 %x, -2147483588
372 %3 = zext i32 %2 to i64
373 %4 = icmp eq i32 %1, 0
375 %6 = select i1 %4, i64 %y, i64 %5
379 define i64 @test_ashr_exact__exact_is_unsafe(i32 %x, i64 %y) {
380 ; CHECK-LABEL: @test_ashr_exact__exact_is_unsafe(
381 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 2
382 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -536870897
383 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
384 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
385 ; CHECK-NEXT: ret i64 [[TMP4]]
387 %1 = and i32 %x, -2147483585
388 %2 = ashr exact i32 %1, 2
389 %3 = zext i32 %2 to i64
390 %4 = icmp eq i32 %1, 0
392 %6 = select i1 %4, i64 %y, i64 %5
396 define i64 @test_ashr__exact_is_unsafe(i32 %x, i64 %y) {
397 ; CHECK-LABEL: @test_ashr__exact_is_unsafe(
398 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 2
399 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -536870897
400 ; CHECK-NEXT: [[TMP3:%.*]] = zext i32 [[TMP2]] to i64
401 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
402 ; CHECK-NEXT: ret i64 [[TMP4]]
404 %1 = and i32 %x, -2147483585
406 %3 = zext i32 %2 to i64
407 %4 = icmp eq i32 %1, 0
409 %6 = select i1 %4, i64 %y, i64 %5
413 define i32 @test_add_nuw_nsw__all_are_safe(i32 %x) {
414 ; CHECK-LABEL: @test_add_nuw_nsw__all_are_safe(
415 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 1073741823
416 ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[AND]], 1
417 ; CHECK-NEXT: ret i32 [[ADD]]
419 %and = and i32 %x, 1073741823
420 %cmp = icmp eq i32 %and, 3
421 %add = add nuw nsw i32 %and, 1
422 %sel = select i1 %cmp, i32 4, i32 %add
426 define i32 @test_add_nuw__all_are_safe(i32 %x) {
427 ; CHECK-LABEL: @test_add_nuw__all_are_safe(
428 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 1073741823
429 ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[AND]], 1
430 ; CHECK-NEXT: ret i32 [[ADD]]
432 %and = and i32 %x, 1073741823
433 %cmp = icmp eq i32 %and, 3
434 %add = add nuw i32 %and, 1
435 %sel = select i1 %cmp, i32 4, i32 %add
439 define i32 @test_add_nsw__all_are_safe(i32 %x) {
440 ; CHECK-LABEL: @test_add_nsw__all_are_safe(
441 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 1073741823
442 ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[AND]], 1
443 ; CHECK-NEXT: ret i32 [[ADD]]
445 %and = and i32 %x, 1073741823
446 %cmp = icmp eq i32 %and, 3
447 %add = add nsw i32 %and, 1
448 %sel = select i1 %cmp, i32 4, i32 %add
452 define i32 @test_add__all_are_safe(i32 %x) {
453 ; CHECK-LABEL: @test_add__all_are_safe(
454 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 1073741823
455 ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[AND]], 1
456 ; CHECK-NEXT: ret i32 [[ADD]]
458 %and = and i32 %x, 1073741823
459 %cmp = icmp eq i32 %and, 3
460 %add = add i32 %and, 1
461 %sel = select i1 %cmp, i32 4, i32 %add
465 define i32 @test_add_nuw_nsw__nuw_is_safe(i32 %x) {
466 ; CHECK-LABEL: @test_add_nuw_nsw__nuw_is_safe(
467 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
468 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[AND]], 1
469 ; CHECK-NEXT: ret i32 [[ADD]]
471 %and = and i32 %x, 2147483647
472 %cmp = icmp eq i32 %and, 2147483647
473 %add = add nuw nsw i32 %and, 1
474 %sel = select i1 %cmp, i32 -2147483648, i32 %add
478 define i32 @test_add_nuw__nuw_is_safe(i32 %x) {
479 ; CHECK-LABEL: @test_add_nuw__nuw_is_safe(
480 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
481 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[AND]], 1
482 ; CHECK-NEXT: ret i32 [[ADD]]
484 %and = and i32 %x, 2147483647
485 %cmp = icmp eq i32 %and, 2147483647
486 %add = add nuw i32 %and, 1
487 %sel = select i1 %cmp, i32 -2147483648, i32 %add
491 define i32 @test_add_nsw__nuw_is_safe(i32 %x) {
492 ; CHECK-LABEL: @test_add_nsw__nuw_is_safe(
493 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
494 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[AND]], 1
495 ; CHECK-NEXT: ret i32 [[ADD]]
497 %and = and i32 %x, 2147483647
498 %cmp = icmp eq i32 %and, 2147483647
499 %add = add nsw i32 %and, 1
500 %sel = select i1 %cmp, i32 -2147483648, i32 %add
504 define i32 @test_add__nuw_is_safe(i32 %x) {
505 ; CHECK-LABEL: @test_add__nuw_is_safe(
506 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
507 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[AND]], 1
508 ; CHECK-NEXT: ret i32 [[ADD]]
510 %and = and i32 %x, 2147483647
511 %cmp = icmp eq i32 %and, 2147483647
512 %add = add i32 %and, 1
513 %sel = select i1 %cmp, i32 -2147483648, i32 %add
517 define i32 @test_add_nuw_nsw__nsw_is_safe(i32 %x) {
518 ; CHECK-LABEL: @test_add_nuw_nsw__nsw_is_safe(
519 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
520 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[OR]], 1
521 ; CHECK-NEXT: ret i32 [[ADD]]
523 %or = or i32 %x, -2147483648
524 %cmp = icmp eq i32 %or, -1
525 %add = add nuw nsw i32 %or, 1
526 %sel = select i1 %cmp, i32 0, i32 %add
530 define i32 @test_add_nuw__nsw_is_safe(i32 %x) {
531 ; CHECK-LABEL: @test_add_nuw__nsw_is_safe(
532 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
533 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[OR]], 1
534 ; CHECK-NEXT: ret i32 [[ADD]]
536 %or = or i32 %x, -2147483648
537 %cmp = icmp eq i32 %or, -1
538 %add = add nuw i32 %or, 1
539 %sel = select i1 %cmp, i32 0, i32 %add
543 define i32 @test_add_nsw__nsw_is_safe(i32 %x) {
544 ; CHECK-LABEL: @test_add_nsw__nsw_is_safe(
545 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
546 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[OR]], 1
547 ; CHECK-NEXT: ret i32 [[ADD]]
549 %or = or i32 %x, -2147483648
550 %cmp = icmp eq i32 %or, -1
551 %add = add nsw i32 %or, 1
552 %sel = select i1 %cmp, i32 0, i32 %add
556 define i32 @test_add__nsw_is_safe(i32 %x) {
557 ; CHECK-LABEL: @test_add__nsw_is_safe(
558 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
559 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[OR]], 1
560 ; CHECK-NEXT: ret i32 [[ADD]]
562 %or = or i32 %x, -2147483648
563 %cmp = icmp eq i32 %or, -1
564 %add = add i32 %or, 1
565 %sel = select i1 %cmp, i32 0, i32 %add
569 define i32 @test_add_nuw_nsw__none_are_safe(i32 %x) {
570 ; CHECK-LABEL: @test_add_nuw_nsw__none_are_safe(
571 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], 1
572 ; CHECK-NEXT: ret i32 [[ADD]]
574 %cmp = icmp eq i32 %x, 3
575 %add = add nuw nsw i32 %x, 1
576 %sel = select i1 %cmp, i32 4, i32 %add
580 define i32 @test_add_nuw__none_are_safe(i32 %x) {
581 ; CHECK-LABEL: @test_add_nuw__none_are_safe(
582 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], 1
583 ; CHECK-NEXT: ret i32 [[ADD]]
585 %cmp = icmp eq i32 %x, 3
586 %add = add nuw i32 %x, 1
587 %sel = select i1 %cmp, i32 4, i32 %add
591 define i32 @test_add_nsw__none_are_safe(i32 %x) {
592 ; CHECK-LABEL: @test_add_nsw__none_are_safe(
593 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], 1
594 ; CHECK-NEXT: ret i32 [[ADD]]
596 %cmp = icmp eq i32 %x, 3
597 %add = add nsw i32 %x, 1
598 %sel = select i1 %cmp, i32 4, i32 %add
602 define i32 @test_add__none_are_safe(i32 %x) {
603 ; CHECK-LABEL: @test_add__none_are_safe(
604 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], 1
605 ; CHECK-NEXT: ret i32 [[ADD]]
607 %cmp = icmp eq i32 %x, 3
609 %sel = select i1 %cmp, i32 4, i32 %add
613 define i32 @test_sub_nuw_nsw__all_are_safe(i32 %x) {
614 ; CHECK-LABEL: @test_sub_nuw_nsw__all_are_safe(
615 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
616 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 -254, [[AND]]
617 ; CHECK-NEXT: ret i32 [[SUB]]
619 %and = and i32 %x, 255
620 %cmp = icmp eq i32 %and, 6
621 %sub = sub nuw nsw i32 -254, %and
622 %sel = select i1 %cmp, i32 -260, i32 %sub
626 define i32 @test_sub_nuw__all_are_safe(i32 %x) {
627 ; CHECK-LABEL: @test_sub_nuw__all_are_safe(
628 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
629 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 -254, [[AND]]
630 ; CHECK-NEXT: ret i32 [[SUB]]
632 %and = and i32 %x, 255
633 %cmp = icmp eq i32 %and, 6
634 %sub = sub nuw i32 -254, %and
635 %sel = select i1 %cmp, i32 -260, i32 %sub
639 define i32 @test_sub_nsw__all_are_safe(i32 %x) {
640 ; CHECK-LABEL: @test_sub_nsw__all_are_safe(
641 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
642 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 -254, [[AND]]
643 ; CHECK-NEXT: ret i32 [[SUB]]
645 %and = and i32 %x, 255
646 %cmp = icmp eq i32 %and, 6
647 %sub = sub nsw i32 -254, %and
648 %sel = select i1 %cmp, i32 -260, i32 %sub
652 define i32 @test_sub__all_are_safe(i32 %x) {
653 ; CHECK-LABEL: @test_sub__all_are_safe(
654 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
655 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 -254, [[AND]]
656 ; CHECK-NEXT: ret i32 [[SUB]]
658 %and = and i32 %x, 255
659 %cmp = icmp eq i32 %and, 6
660 %sub = sub i32 -254, %and
661 %sel = select i1 %cmp, i32 -260, i32 %sub
665 define i32 @test_sub_nuw_nsw__nuw_is_safe(i32 %x) {
666 ; CHECK-LABEL: @test_sub_nuw_nsw__nuw_is_safe(
667 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
668 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw i32 -2147483648, [[AND]]
669 ; CHECK-NEXT: ret i32 [[SUB]]
671 %and = and i32 %x, 2147483647
672 %cmp = icmp eq i32 %and, 1073741824
673 %sub = sub nuw nsw i32 -2147483648, %and
674 %sel = select i1 %cmp, i32 1073741824, i32 %sub
678 define i32 @test_sub_nuw__nuw_is_safe(i32 %x) {
679 ; CHECK-LABEL: @test_sub_nuw__nuw_is_safe(
680 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
681 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw i32 -2147483648, [[AND]]
682 ; CHECK-NEXT: ret i32 [[SUB]]
684 %and = and i32 %x, 2147483647
685 %cmp = icmp eq i32 %and, 1073741824
686 %sub = sub nuw i32 -2147483648, %and
687 %sel = select i1 %cmp, i32 1073741824, i32 %sub
691 define i32 @test_sub_nsw__nuw_is_safe(i32 %x) {
692 ; CHECK-LABEL: @test_sub_nsw__nuw_is_safe(
693 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
694 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw i32 -2147483648, [[AND]]
695 ; CHECK-NEXT: ret i32 [[SUB]]
697 %and = and i32 %x, 2147483647
698 %cmp = icmp eq i32 %and, 1073741824
699 %sub = sub nsw i32 -2147483648, %and
700 %sel = select i1 %cmp, i32 1073741824, i32 %sub
704 define i32 @test_sub__nuw_is_safe(i32 %x) {
705 ; CHECK-LABEL: @test_sub__nuw_is_safe(
706 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
707 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw i32 -2147483648, [[AND]]
708 ; CHECK-NEXT: ret i32 [[SUB]]
710 %and = and i32 %x, 2147483647
711 %cmp = icmp eq i32 %and, 1073741824
712 %sub = sub i32 -2147483648, %and
713 %sel = select i1 %cmp, i32 1073741824, i32 %sub
717 define i32 @test_sub_nuw_nsw__nsw_is_safe(i32 %x) {
718 ; CHECK-LABEL: @test_sub_nuw_nsw__nsw_is_safe(
719 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
720 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 -2147483648, [[OR]]
721 ; CHECK-NEXT: ret i32 [[SUB]]
723 %or = or i32 %x, -2147483648
724 %cmp = icmp eq i32 %or, -2147483647
725 %sub = sub nuw nsw i32 -2147483648, %or
726 %sel = select i1 %cmp, i32 -1, i32 %sub
730 define i32 @test_sub_nuw__nsw_is_safe(i32 %x) {
731 ; CHECK-LABEL: @test_sub_nuw__nsw_is_safe(
732 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
733 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 -2147483648, [[OR]]
734 ; CHECK-NEXT: ret i32 [[SUB]]
736 %or = or i32 %x, -2147483648
737 %cmp = icmp eq i32 %or, -2147483647
738 %sub = sub nuw i32 -2147483648, %or
739 %sel = select i1 %cmp, i32 -1, i32 %sub
743 define i32 @test_sub_nsw__nsw_is_safe(i32 %x) {
744 ; CHECK-LABEL: @test_sub_nsw__nsw_is_safe(
745 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
746 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 -2147483648, [[OR]]
747 ; CHECK-NEXT: ret i32 [[SUB]]
749 %or = or i32 %x, -2147483648
750 %cmp = icmp eq i32 %or, -2147483647
751 %sub = sub nsw i32 -2147483648, %or
752 %sel = select i1 %cmp, i32 -1, i32 %sub
756 define i32 @test_sub__nsw_is_safe(i32 %x) {
757 ; CHECK-LABEL: @test_sub__nsw_is_safe(
758 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
759 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 -2147483648, [[OR]]
760 ; CHECK-NEXT: ret i32 [[SUB]]
762 %or = or i32 %x, -2147483648
763 %cmp = icmp eq i32 %or, -2147483647
764 %sub = sub i32 -2147483648, %or
765 %sel = select i1 %cmp, i32 -1, i32 %sub
769 define i32 @test_sub_nuw_nsw__none_are_safe(i32 %x) {
770 ; CHECK-LABEL: @test_sub_nuw_nsw__none_are_safe(
771 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 -2147483648, [[X:%.*]]
772 ; CHECK-NEXT: ret i32 [[SUB]]
774 %cmp = icmp eq i32 %x, 1
775 %sub = sub nuw nsw i32 -2147483648, %x
776 %sel = select i1 %cmp, i32 2147483647, i32 %sub
780 define i32 @test_sub_nuw__none_are_safe(i32 %x) {
781 ; CHECK-LABEL: @test_sub_nuw__none_are_safe(
782 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 -2147483648, [[X:%.*]]
783 ; CHECK-NEXT: ret i32 [[SUB]]
785 %cmp = icmp eq i32 %x, 1
786 %sub = sub nuw i32 -2147483648, %x
787 %sel = select i1 %cmp, i32 2147483647, i32 %sub
791 define i32 @test_sub_nsw__none_are_safe(i32 %x) {
792 ; CHECK-LABEL: @test_sub_nsw__none_are_safe(
793 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 -2147483648, [[X:%.*]]
794 ; CHECK-NEXT: ret i32 [[SUB]]
796 %cmp = icmp eq i32 %x, 1
797 %sub = sub nsw i32 -2147483648, %x
798 %sel = select i1 %cmp, i32 2147483647, i32 %sub
802 define i32 @test_sub__none_are_safe(i32 %x) {
803 ; CHECK-LABEL: @test_sub__none_are_safe(
804 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 -2147483648, [[X:%.*]]
805 ; CHECK-NEXT: ret i32 [[SUB]]
807 %cmp = icmp eq i32 %x, 1
808 %sub = sub i32 -2147483648, %x
809 %sel = select i1 %cmp, i32 2147483647, i32 %sub
813 define i32 @test_mul_nuw_nsw__all_are_safe(i32 %x) {
814 ; CHECK-LABEL: @test_mul_nuw_nsw__all_are_safe(
815 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
816 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[AND]], 9
817 ; CHECK-NEXT: ret i32 [[MUL]]
819 %and = and i32 %x, 255
820 %cmp = icmp eq i32 %and, 17
821 %mul = mul nuw nsw i32 %and, 9
822 %sel = select i1 %cmp, i32 153, i32 %mul
826 define i32 @test_mul_nuw__all_are_safe(i32 %x) {
827 ; CHECK-LABEL: @test_mul_nuw__all_are_safe(
828 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
829 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[AND]], 9
830 ; CHECK-NEXT: ret i32 [[MUL]]
832 %and = and i32 %x, 255
833 %cmp = icmp eq i32 %and, 17
834 %mul = mul nuw i32 %and, 9
835 %sel = select i1 %cmp, i32 153, i32 %mul
839 define i32 @test_mul_nsw__all_are_safe(i32 %x) {
840 ; CHECK-LABEL: @test_mul_nsw__all_are_safe(
841 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
842 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[AND]], 9
843 ; CHECK-NEXT: ret i32 [[MUL]]
845 %and = and i32 %x, 255
846 %cmp = icmp eq i32 %and, 17
847 %mul = mul nsw i32 %and, 9
848 %sel = select i1 %cmp, i32 153, i32 %mul
852 define i32 @test_mul__all_are_safe(i32 %x) {
853 ; CHECK-LABEL: @test_mul__all_are_safe(
854 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
855 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[AND]], 9
856 ; CHECK-NEXT: ret i32 [[MUL]]
858 %and = and i32 %x, 255
859 %cmp = icmp eq i32 %and, 17
860 %mul = mul i32 %and, 9
861 %sel = select i1 %cmp, i32 153, i32 %mul
865 define i32 @test_mul_nuw_nsw__nuw_is_safe(i32 %x) {
866 ; CHECK-LABEL: @test_mul_nuw_nsw__nuw_is_safe(
867 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 268435457
868 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[AND]], 9
869 ; CHECK-NEXT: ret i32 [[MUL]]
871 %and = and i32 %x, 268435457
872 %cmp = icmp eq i32 %and, 268435456
873 %mul = mul nuw nsw i32 %and, 9
874 %sel = select i1 %cmp, i32 -1879048192, i32 %mul
878 define i32 @test_mul_nuw__nuw_is_safe(i32 %x) {
879 ; CHECK-LABEL: @test_mul_nuw__nuw_is_safe(
880 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 268435457
881 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[AND]], 9
882 ; CHECK-NEXT: ret i32 [[MUL]]
884 %and = and i32 %x, 268435457
885 %cmp = icmp eq i32 %and, 268435456
886 %mul = mul nuw i32 %and, 9
887 %sel = select i1 %cmp, i32 -1879048192, i32 %mul
891 define i32 @test_mul_nsw__nuw_is_safe(i32 %x) {
892 ; CHECK-LABEL: @test_mul_nsw__nuw_is_safe(
893 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 268435457
894 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[AND]], 9
895 ; CHECK-NEXT: ret i32 [[MUL]]
897 %and = and i32 %x, 268435457
898 %cmp = icmp eq i32 %and, 268435456
899 %mul = mul nsw i32 %and, 9
900 %sel = select i1 %cmp, i32 -1879048192, i32 %mul
904 define i32 @test_mul__nuw_is_safe(i32 %x) {
905 ; CHECK-LABEL: @test_mul__nuw_is_safe(
906 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 268435457
907 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[AND]], 9
908 ; CHECK-NEXT: ret i32 [[MUL]]
910 %and = and i32 %x, 268435457
911 %cmp = icmp eq i32 %and, 268435456
912 %mul = mul i32 %and, 9
913 %sel = select i1 %cmp, i32 -1879048192, i32 %mul
917 define i32 @test_mul_nuw_nsw__nsw_is_safe(i32 %x) {
918 ; CHECK-LABEL: @test_mul_nuw_nsw__nsw_is_safe(
919 ; CHECK-NEXT: [[AND:%.*]] = or i32 [[X:%.*]], -83886080
920 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[AND]], 9
921 ; CHECK-NEXT: ret i32 [[MUL]]
923 %and = or i32 %x, -83886080
924 %cmp = icmp eq i32 %and, -83886079
925 %mul = mul nuw nsw i32 %and, 9
926 %sel = select i1 %cmp, i32 -754974711, i32 %mul
930 define i32 @test_mul_nuw__nsw_is_safe(i32 %x) {
931 ; CHECK-LABEL: @test_mul_nuw__nsw_is_safe(
932 ; CHECK-NEXT: [[AND:%.*]] = or i32 [[X:%.*]], -83886080
933 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[AND]], 9
934 ; CHECK-NEXT: ret i32 [[MUL]]
936 %and = or i32 %x, -83886080
937 %cmp = icmp eq i32 %and, -83886079
938 %mul = mul nuw i32 %and, 9
939 %sel = select i1 %cmp, i32 -754974711, i32 %mul
943 define i32 @test_mul_nsw__nsw_is_safe(i32 %x) {
944 ; CHECK-LABEL: @test_mul_nsw__nsw_is_safe(
945 ; CHECK-NEXT: [[AND:%.*]] = or i32 [[X:%.*]], -83886080
946 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[AND]], 9
947 ; CHECK-NEXT: ret i32 [[MUL]]
949 %and = or i32 %x, -83886080
950 %cmp = icmp eq i32 %and, -83886079
951 %mul = mul nsw i32 %and, 9
952 %sel = select i1 %cmp, i32 -754974711, i32 %mul
956 define i32 @test_mul__nsw_is_safe(i32 %x) {
957 ; CHECK-LABEL: @test_mul__nsw_is_safe(
958 ; CHECK-NEXT: [[AND:%.*]] = or i32 [[X:%.*]], -83886080
959 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[AND]], 9
960 ; CHECK-NEXT: ret i32 [[MUL]]
962 %and = or i32 %x, -83886080
963 %cmp = icmp eq i32 %and, -83886079
964 %mul = mul i32 %and, 9
965 %sel = select i1 %cmp, i32 -754974711, i32 %mul
969 define i32 @test_mul_nuw_nsw__none_are_safe(i32 %x) {
970 ; CHECK-LABEL: @test_mul_nuw_nsw__none_are_safe(
971 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], 9
972 ; CHECK-NEXT: ret i32 [[MUL]]
974 %cmp = icmp eq i32 %x, 805306368
975 %mul = mul nuw nsw i32 %x, 9
976 %sel = select i1 %cmp, i32 -1342177280, i32 %mul
980 define i32 @test_mul_nuw__none_are_safe(i32 %x) {
981 ; CHECK-LABEL: @test_mul_nuw__none_are_safe(
982 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], 9
983 ; CHECK-NEXT: ret i32 [[MUL]]
985 %cmp = icmp eq i32 %x, 805306368
986 %mul = mul nuw i32 %x, 9
987 %sel = select i1 %cmp, i32 -1342177280, i32 %mul
991 define i32 @test_mul_nsw__none_are_safe(i32 %x) {
992 ; CHECK-LABEL: @test_mul_nsw__none_are_safe(
993 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], 9
994 ; CHECK-NEXT: ret i32 [[MUL]]
996 %cmp = icmp eq i32 %x, 805306368
997 %mul = mul nsw i32 %x, 9
998 %sel = select i1 %cmp, i32 -1342177280, i32 %mul
1002 define i32 @test_mul__none_are_safe(i32 %x) {
1003 ; CHECK-LABEL: @test_mul__none_are_safe(
1004 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], 9
1005 ; CHECK-NEXT: ret i32 [[MUL]]
1007 %cmp = icmp eq i32 %x, 805306368
1008 %mul = mul i32 %x, 9
1009 %sel = select i1 %cmp, i32 -1342177280, i32 %mul