1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=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 nneg 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 nneg 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 nneg 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 nneg 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 nneg 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 nneg 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 nneg 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 nneg 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: ret i32 0
144 %1 = or i32 %x, -83886080
145 %2 = icmp eq i32 %1, -83886079
146 %3 = shl nuw nsw i32 %1, 2
147 %4 = select i1 %2, i32 -335544316, i32 %3
153 define i32 @test_shl_nuw__nsw_is_safe(i32 %x) {
154 ; CHECK-LABEL: @test_shl_nuw__nsw_is_safe(
155 ; CHECK-NEXT: ret i32 0
157 %1 = or i32 %x, -83886080
158 %2 = icmp eq i32 %1, -83886079
159 %3 = shl nuw i32 %1, 2
160 %4 = select i1 %2, i32 -335544316, i32 %3
166 define i32 @test_shl_nsw__nsw_is_safe(i32 %x) {
167 ; CHECK-LABEL: @test_shl_nsw__nsw_is_safe(
168 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[X:%.*]], -83886080
169 ; CHECK-NEXT: [[TMP2:%.*]] = shl nsw i32 [[TMP1]], 2
170 ; CHECK-NEXT: [[TMP3:%.*]] = mul i32 [[TMP2]], [[TMP1]]
171 ; CHECK-NEXT: [[TMP4:%.*]] = mul i32 [[TMP3]], [[TMP2]]
172 ; CHECK-NEXT: ret i32 [[TMP4]]
174 %1 = or i32 %x, -83886080
175 %2 = icmp eq i32 %1, -83886079
176 %3 = shl nsw i32 %1, 2
177 %4 = select i1 %2, i32 -335544316, i32 %3
183 define i32 @test_shl__nsw_is_safe(i32 %x) {
184 ; CHECK-LABEL: @test_shl__nsw_is_safe(
185 ; CHECK-NEXT: [[TMP1:%.*]] = or i32 [[X:%.*]], -83886080
186 ; CHECK-NEXT: [[TMP2:%.*]] = shl nsw i32 [[TMP1]], 2
187 ; CHECK-NEXT: [[TMP3:%.*]] = mul i32 [[TMP2]], [[TMP1]]
188 ; CHECK-NEXT: [[TMP4:%.*]] = mul i32 [[TMP3]], [[TMP2]]
189 ; CHECK-NEXT: ret i32 [[TMP4]]
191 %1 = or i32 %x, -83886080
192 %2 = icmp eq i32 %1, -83886079
194 %4 = select i1 %2, i32 -335544316, i32 %3
201 define i64 @test_shl_nuw_nsw__none_are_safe(i32 %x, i64 %y) {
202 ; CHECK-LABEL: @test_shl_nuw_nsw__none_are_safe(
203 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
204 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
205 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
206 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
207 ; CHECK-NEXT: ret i64 [[TMP4]]
209 %1 = and i32 %x, 4294967294
210 %2 = shl nuw nsw i32 %1, 2
211 %3 = zext i32 %2 to i64
212 %4 = icmp eq i32 %1, 0
214 %6 = select i1 %4, i64 %y, i64 %5
218 define i64 @test_shl_nuw__none_are_safe(i32 %x, i64 %y) {
219 ; CHECK-LABEL: @test_shl_nuw__none_are_safe(
220 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
221 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
222 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
223 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
224 ; CHECK-NEXT: ret i64 [[TMP4]]
226 %1 = and i32 %x, 4294967294
227 %2 = shl nuw i32 %1, 2
228 %3 = zext i32 %2 to i64
229 %4 = icmp eq i32 %1, 0
231 %6 = select i1 %4, i64 %y, i64 %5
235 define i64 @test_shl_nsw__none_are_safe(i32 %x, i64 %y) {
236 ; CHECK-LABEL: @test_shl_nsw__none_are_safe(
237 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
238 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
239 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
240 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
241 ; CHECK-NEXT: ret i64 [[TMP4]]
243 %1 = and i32 %x, 4294967294
244 %2 = shl nsw i32 %1, 2
245 %3 = zext i32 %2 to i64
246 %4 = icmp eq i32 %1, 0
248 %6 = select i1 %4, i64 %y, i64 %5
252 define i64 @test_shl__none_are_safe(i32 %x, i64 %y) {
253 ; CHECK-LABEL: @test_shl__none_are_safe(
254 ; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[X:%.*]], 2
255 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -8
256 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
257 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
258 ; CHECK-NEXT: ret i64 [[TMP4]]
260 %1 = and i32 %x, 4294967294
262 %3 = zext i32 %2 to i64
263 %4 = icmp eq i32 %1, 0
265 %6 = select i1 %4, i64 %y, i64 %5
269 define i64 @test_lshr_exact__exact_is_safe(i32 %x, i64 %y) {
270 ; CHECK-LABEL: @test_lshr_exact__exact_is_safe(
271 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 2
272 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 15
273 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
274 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
275 ; CHECK-NEXT: ret i64 [[TMP4]]
278 %2 = lshr exact i32 %1, 2
279 %3 = zext i32 %2 to i64
280 %4 = icmp eq i32 %1, 0
282 %6 = select i1 %4, i64 %y, i64 %5
286 define i64 @test_lshr__exact_is_safe(i32 %x, i64 %y) {
287 ; CHECK-LABEL: @test_lshr__exact_is_safe(
288 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 2
289 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 15
290 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
291 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
292 ; CHECK-NEXT: ret i64 [[TMP4]]
296 %3 = zext i32 %2 to i64
297 %4 = icmp eq i32 %1, 0
299 %6 = select i1 %4, i64 %y, i64 %5
303 define i64 @test_lshr_exact__exact_is_unsafe(i32 %x, i64 %y) {
304 ; CHECK-LABEL: @test_lshr_exact__exact_is_unsafe(
305 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 2
306 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 15
307 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
308 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
309 ; CHECK-NEXT: ret i64 [[TMP4]]
312 %2 = lshr exact i32 %1, 2
313 %3 = zext i32 %2 to i64
314 %4 = icmp eq i32 %1, 0
316 %6 = select i1 %4, i64 %y, i64 %5
320 define i64 @test_lshr__exact_is_unsafe(i32 %x, i64 %y) {
321 ; CHECK-LABEL: @test_lshr__exact_is_unsafe(
322 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X:%.*]], 2
323 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 15
324 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
325 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
326 ; CHECK-NEXT: ret i64 [[TMP4]]
330 %3 = zext i32 %2 to i64
331 %4 = icmp eq i32 %1, 0
333 %6 = select i1 %4, i64 %y, i64 %5
337 define i64 @test_ashr_exact__exact_is_safe(i32 %x, i64 %y) {
338 ; CHECK-LABEL: @test_ashr_exact__exact_is_safe(
339 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 2
340 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -536870897
341 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
342 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
343 ; CHECK-NEXT: ret i64 [[TMP4]]
345 %1 = and i32 %x, -2147483588
346 %2 = ashr exact i32 %1, 2
347 %3 = zext i32 %2 to i64
348 %4 = icmp eq i32 %1, 0
350 %6 = select i1 %4, i64 %y, i64 %5
354 define i64 @test_ashr__exact_is_safe(i32 %x, i64 %y) {
355 ; CHECK-LABEL: @test_ashr__exact_is_safe(
356 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 2
357 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -536870897
358 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
359 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
360 ; CHECK-NEXT: ret i64 [[TMP4]]
362 %1 = and i32 %x, -2147483588
364 %3 = zext i32 %2 to i64
365 %4 = icmp eq i32 %1, 0
367 %6 = select i1 %4, i64 %y, i64 %5
371 define i64 @test_ashr_exact__exact_is_unsafe(i32 %x, i64 %y) {
372 ; CHECK-LABEL: @test_ashr_exact__exact_is_unsafe(
373 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 2
374 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -536870897
375 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
376 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
377 ; CHECK-NEXT: ret i64 [[TMP4]]
379 %1 = and i32 %x, -2147483585
380 %2 = ashr exact i32 %1, 2
381 %3 = zext i32 %2 to i64
382 %4 = icmp eq i32 %1, 0
384 %6 = select i1 %4, i64 %y, i64 %5
388 define i64 @test_ashr__exact_is_unsafe(i32 %x, i64 %y) {
389 ; CHECK-LABEL: @test_ashr__exact_is_unsafe(
390 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i32 [[X:%.*]], 2
391 ; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], -536870897
392 ; CHECK-NEXT: [[TMP3:%.*]] = zext nneg i32 [[TMP2]] to i64
393 ; CHECK-NEXT: [[TMP4:%.*]] = ashr i64 [[Y:%.*]], [[TMP3]]
394 ; CHECK-NEXT: ret i64 [[TMP4]]
396 %1 = and i32 %x, -2147483585
398 %3 = zext i32 %2 to i64
399 %4 = icmp eq i32 %1, 0
401 %6 = select i1 %4, i64 %y, i64 %5
405 define i32 @test_add_nuw_nsw__all_are_safe(i32 %x) {
406 ; CHECK-LABEL: @test_add_nuw_nsw__all_are_safe(
407 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 1073741823
408 ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[AND]], 1
409 ; CHECK-NEXT: ret i32 [[ADD]]
411 %and = and i32 %x, 1073741823
412 %cmp = icmp eq i32 %and, 3
413 %add = add nuw nsw i32 %and, 1
414 %sel = select i1 %cmp, i32 4, i32 %add
418 define i32 @test_add_nuw__all_are_safe(i32 %x) {
419 ; CHECK-LABEL: @test_add_nuw__all_are_safe(
420 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 1073741823
421 ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[AND]], 1
422 ; CHECK-NEXT: ret i32 [[ADD]]
424 %and = and i32 %x, 1073741823
425 %cmp = icmp eq i32 %and, 3
426 %add = add nuw i32 %and, 1
427 %sel = select i1 %cmp, i32 4, i32 %add
431 define i32 @test_add_nsw__all_are_safe(i32 %x) {
432 ; CHECK-LABEL: @test_add_nsw__all_are_safe(
433 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 1073741823
434 ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[AND]], 1
435 ; CHECK-NEXT: ret i32 [[ADD]]
437 %and = and i32 %x, 1073741823
438 %cmp = icmp eq i32 %and, 3
439 %add = add nsw i32 %and, 1
440 %sel = select i1 %cmp, i32 4, i32 %add
444 define i32 @test_add__all_are_safe(i32 %x) {
445 ; CHECK-LABEL: @test_add__all_are_safe(
446 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 1073741823
447 ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[AND]], 1
448 ; CHECK-NEXT: ret i32 [[ADD]]
450 %and = and i32 %x, 1073741823
451 %cmp = icmp eq i32 %and, 3
452 %add = add i32 %and, 1
453 %sel = select i1 %cmp, i32 4, i32 %add
457 define i32 @test_add_nuw_nsw__nuw_is_safe(i32 %x) {
458 ; CHECK-LABEL: @test_add_nuw_nsw__nuw_is_safe(
459 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
460 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[AND]], 1
461 ; CHECK-NEXT: ret i32 [[ADD]]
463 %and = and i32 %x, 2147483647
464 %cmp = icmp eq i32 %and, 2147483647
465 %add = add nuw nsw i32 %and, 1
466 %sel = select i1 %cmp, i32 -2147483648, i32 %add
470 define i32 @test_add_nuw__nuw_is_safe(i32 %x) {
471 ; CHECK-LABEL: @test_add_nuw__nuw_is_safe(
472 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
473 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[AND]], 1
474 ; CHECK-NEXT: ret i32 [[ADD]]
476 %and = and i32 %x, 2147483647
477 %cmp = icmp eq i32 %and, 2147483647
478 %add = add nuw i32 %and, 1
479 %sel = select i1 %cmp, i32 -2147483648, i32 %add
483 define i32 @test_add_nsw__nuw_is_safe(i32 %x) {
484 ; CHECK-LABEL: @test_add_nsw__nuw_is_safe(
485 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
486 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[AND]], 1
487 ; CHECK-NEXT: ret i32 [[ADD]]
489 %and = and i32 %x, 2147483647
490 %cmp = icmp eq i32 %and, 2147483647
491 %add = add nsw i32 %and, 1
492 %sel = select i1 %cmp, i32 -2147483648, i32 %add
496 define i32 @test_add__nuw_is_safe(i32 %x) {
497 ; CHECK-LABEL: @test_add__nuw_is_safe(
498 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
499 ; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[AND]], 1
500 ; CHECK-NEXT: ret i32 [[ADD]]
502 %and = and i32 %x, 2147483647
503 %cmp = icmp eq i32 %and, 2147483647
504 %add = add i32 %and, 1
505 %sel = select i1 %cmp, i32 -2147483648, i32 %add
509 define i32 @test_add_nuw_nsw__nsw_is_safe(i32 %x) {
510 ; CHECK-LABEL: @test_add_nuw_nsw__nsw_is_safe(
511 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
512 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[OR]], 1
513 ; CHECK-NEXT: ret i32 [[ADD]]
515 %or = or i32 %x, -2147483648
516 %cmp = icmp eq i32 %or, -1
517 %add = add nuw nsw i32 %or, 1
518 %sel = select i1 %cmp, i32 0, i32 %add
522 define i32 @test_add_nuw__nsw_is_safe(i32 %x) {
523 ; CHECK-LABEL: @test_add_nuw__nsw_is_safe(
524 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
525 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[OR]], 1
526 ; CHECK-NEXT: ret i32 [[ADD]]
528 %or = or i32 %x, -2147483648
529 %cmp = icmp eq i32 %or, -1
530 %add = add nuw i32 %or, 1
531 %sel = select i1 %cmp, i32 0, i32 %add
535 define i32 @test_add_nsw__nsw_is_safe(i32 %x) {
536 ; CHECK-LABEL: @test_add_nsw__nsw_is_safe(
537 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
538 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[OR]], 1
539 ; CHECK-NEXT: ret i32 [[ADD]]
541 %or = or i32 %x, -2147483648
542 %cmp = icmp eq i32 %or, -1
543 %add = add nsw i32 %or, 1
544 %sel = select i1 %cmp, i32 0, i32 %add
548 define i32 @test_add__nsw_is_safe(i32 %x) {
549 ; CHECK-LABEL: @test_add__nsw_is_safe(
550 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
551 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[OR]], 1
552 ; CHECK-NEXT: ret i32 [[ADD]]
554 %or = or i32 %x, -2147483648
555 %cmp = icmp eq i32 %or, -1
556 %add = add i32 %or, 1
557 %sel = select i1 %cmp, i32 0, i32 %add
561 define i32 @test_add_nuw_nsw__none_are_safe(i32 %x) {
562 ; CHECK-LABEL: @test_add_nuw_nsw__none_are_safe(
563 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], 1
564 ; CHECK-NEXT: ret i32 [[ADD]]
566 %cmp = icmp eq i32 %x, 3
567 %add = add nuw nsw i32 %x, 1
568 %sel = select i1 %cmp, i32 4, i32 %add
572 define i32 @test_add_nuw__none_are_safe(i32 %x) {
573 ; CHECK-LABEL: @test_add_nuw__none_are_safe(
574 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], 1
575 ; CHECK-NEXT: ret i32 [[ADD]]
577 %cmp = icmp eq i32 %x, 3
578 %add = add nuw i32 %x, 1
579 %sel = select i1 %cmp, i32 4, i32 %add
583 define i32 @test_add_nsw__none_are_safe(i32 %x) {
584 ; CHECK-LABEL: @test_add_nsw__none_are_safe(
585 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], 1
586 ; CHECK-NEXT: ret i32 [[ADD]]
588 %cmp = icmp eq i32 %x, 3
589 %add = add nsw i32 %x, 1
590 %sel = select i1 %cmp, i32 4, i32 %add
594 define i32 @test_add__none_are_safe(i32 %x) {
595 ; CHECK-LABEL: @test_add__none_are_safe(
596 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], 1
597 ; CHECK-NEXT: ret i32 [[ADD]]
599 %cmp = icmp eq i32 %x, 3
601 %sel = select i1 %cmp, i32 4, i32 %add
605 define i32 @test_sub_nuw_nsw__all_are_safe(i32 %x) {
606 ; CHECK-LABEL: @test_sub_nuw_nsw__all_are_safe(
607 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
608 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 -254, [[AND]]
609 ; CHECK-NEXT: ret i32 [[SUB]]
611 %and = and i32 %x, 255
612 %cmp = icmp eq i32 %and, 6
613 %sub = sub nuw nsw i32 -254, %and
614 %sel = select i1 %cmp, i32 -260, i32 %sub
618 define i32 @test_sub_nuw__all_are_safe(i32 %x) {
619 ; CHECK-LABEL: @test_sub_nuw__all_are_safe(
620 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
621 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 -254, [[AND]]
622 ; CHECK-NEXT: ret i32 [[SUB]]
624 %and = and i32 %x, 255
625 %cmp = icmp eq i32 %and, 6
626 %sub = sub nuw i32 -254, %and
627 %sel = select i1 %cmp, i32 -260, i32 %sub
631 define i32 @test_sub_nsw__all_are_safe(i32 %x) {
632 ; CHECK-LABEL: @test_sub_nsw__all_are_safe(
633 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
634 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 -254, [[AND]]
635 ; CHECK-NEXT: ret i32 [[SUB]]
637 %and = and i32 %x, 255
638 %cmp = icmp eq i32 %and, 6
639 %sub = sub nsw i32 -254, %and
640 %sel = select i1 %cmp, i32 -260, i32 %sub
644 define i32 @test_sub__all_are_safe(i32 %x) {
645 ; CHECK-LABEL: @test_sub__all_are_safe(
646 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
647 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw nsw i32 -254, [[AND]]
648 ; CHECK-NEXT: ret i32 [[SUB]]
650 %and = and i32 %x, 255
651 %cmp = icmp eq i32 %and, 6
652 %sub = sub i32 -254, %and
653 %sel = select i1 %cmp, i32 -260, i32 %sub
657 define i32 @test_sub_nuw_nsw__nuw_is_safe(i32 %x) {
658 ; CHECK-LABEL: @test_sub_nuw_nsw__nuw_is_safe(
659 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
660 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw i32 -2147483648, [[AND]]
661 ; CHECK-NEXT: ret i32 [[SUB]]
663 %and = and i32 %x, 2147483647
664 %cmp = icmp eq i32 %and, 1073741824
665 %sub = sub nuw nsw i32 -2147483648, %and
666 %sel = select i1 %cmp, i32 1073741824, i32 %sub
670 define i32 @test_sub_nuw__nuw_is_safe(i32 %x) {
671 ; CHECK-LABEL: @test_sub_nuw__nuw_is_safe(
672 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
673 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw i32 -2147483648, [[AND]]
674 ; CHECK-NEXT: ret i32 [[SUB]]
676 %and = and i32 %x, 2147483647
677 %cmp = icmp eq i32 %and, 1073741824
678 %sub = sub nuw i32 -2147483648, %and
679 %sel = select i1 %cmp, i32 1073741824, i32 %sub
683 define i32 @test_sub_nsw__nuw_is_safe(i32 %x) {
684 ; CHECK-LABEL: @test_sub_nsw__nuw_is_safe(
685 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
686 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw i32 -2147483648, [[AND]]
687 ; CHECK-NEXT: ret i32 [[SUB]]
689 %and = and i32 %x, 2147483647
690 %cmp = icmp eq i32 %and, 1073741824
691 %sub = sub nsw i32 -2147483648, %and
692 %sel = select i1 %cmp, i32 1073741824, i32 %sub
696 define i32 @test_sub__nuw_is_safe(i32 %x) {
697 ; CHECK-LABEL: @test_sub__nuw_is_safe(
698 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 2147483647
699 ; CHECK-NEXT: [[SUB:%.*]] = sub nuw i32 -2147483648, [[AND]]
700 ; CHECK-NEXT: ret i32 [[SUB]]
702 %and = and i32 %x, 2147483647
703 %cmp = icmp eq i32 %and, 1073741824
704 %sub = sub i32 -2147483648, %and
705 %sel = select i1 %cmp, i32 1073741824, i32 %sub
709 define i32 @test_sub_nuw_nsw__nsw_is_safe(i32 %x) {
710 ; CHECK-LABEL: @test_sub_nuw_nsw__nsw_is_safe(
711 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
712 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 -2147483648, [[OR]]
713 ; CHECK-NEXT: ret i32 [[SUB]]
715 %or = or i32 %x, -2147483648
716 %cmp = icmp eq i32 %or, -2147483647
717 %sub = sub nuw nsw i32 -2147483648, %or
718 %sel = select i1 %cmp, i32 -1, i32 %sub
722 define i32 @test_sub_nuw__nsw_is_safe(i32 %x) {
723 ; CHECK-LABEL: @test_sub_nuw__nsw_is_safe(
724 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
725 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 -2147483648, [[OR]]
726 ; CHECK-NEXT: ret i32 [[SUB]]
728 %or = or i32 %x, -2147483648
729 %cmp = icmp eq i32 %or, -2147483647
730 %sub = sub nuw i32 -2147483648, %or
731 %sel = select i1 %cmp, i32 -1, i32 %sub
735 define i32 @test_sub_nsw__nsw_is_safe(i32 %x) {
736 ; CHECK-LABEL: @test_sub_nsw__nsw_is_safe(
737 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
738 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 -2147483648, [[OR]]
739 ; CHECK-NEXT: ret i32 [[SUB]]
741 %or = or i32 %x, -2147483648
742 %cmp = icmp eq i32 %or, -2147483647
743 %sub = sub nsw i32 -2147483648, %or
744 %sel = select i1 %cmp, i32 -1, i32 %sub
748 define i32 @test_sub__nsw_is_safe(i32 %x) {
749 ; CHECK-LABEL: @test_sub__nsw_is_safe(
750 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -2147483648
751 ; CHECK-NEXT: [[SUB:%.*]] = sub nsw i32 -2147483648, [[OR]]
752 ; CHECK-NEXT: ret i32 [[SUB]]
754 %or = or i32 %x, -2147483648
755 %cmp = icmp eq i32 %or, -2147483647
756 %sub = sub i32 -2147483648, %or
757 %sel = select i1 %cmp, i32 -1, i32 %sub
761 define i32 @test_sub_nuw_nsw__none_are_safe(i32 %x) {
762 ; CHECK-LABEL: @test_sub_nuw_nsw__none_are_safe(
763 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 -2147483648, [[X:%.*]]
764 ; CHECK-NEXT: ret i32 [[SUB]]
766 %cmp = icmp eq i32 %x, 1
767 %sub = sub nuw nsw i32 -2147483648, %x
768 %sel = select i1 %cmp, i32 2147483647, i32 %sub
772 define i32 @test_sub_nuw__none_are_safe(i32 %x) {
773 ; CHECK-LABEL: @test_sub_nuw__none_are_safe(
774 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 -2147483648, [[X:%.*]]
775 ; CHECK-NEXT: ret i32 [[SUB]]
777 %cmp = icmp eq i32 %x, 1
778 %sub = sub nuw i32 -2147483648, %x
779 %sel = select i1 %cmp, i32 2147483647, i32 %sub
783 define i32 @test_sub_nsw__none_are_safe(i32 %x) {
784 ; CHECK-LABEL: @test_sub_nsw__none_are_safe(
785 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 -2147483648, [[X:%.*]]
786 ; CHECK-NEXT: ret i32 [[SUB]]
788 %cmp = icmp eq i32 %x, 1
789 %sub = sub nsw i32 -2147483648, %x
790 %sel = select i1 %cmp, i32 2147483647, i32 %sub
794 define i32 @test_sub__none_are_safe(i32 %x) {
795 ; CHECK-LABEL: @test_sub__none_are_safe(
796 ; CHECK-NEXT: [[SUB:%.*]] = sub i32 -2147483648, [[X:%.*]]
797 ; CHECK-NEXT: ret i32 [[SUB]]
799 %cmp = icmp eq i32 %x, 1
800 %sub = sub i32 -2147483648, %x
801 %sel = select i1 %cmp, i32 2147483647, i32 %sub
805 define i32 @test_mul_nuw_nsw__all_are_safe(i32 %x) {
806 ; CHECK-LABEL: @test_mul_nuw_nsw__all_are_safe(
807 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
808 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[AND]], 9
809 ; CHECK-NEXT: ret i32 [[MUL]]
811 %and = and i32 %x, 255
812 %cmp = icmp eq i32 %and, 17
813 %mul = mul nuw nsw i32 %and, 9
814 %sel = select i1 %cmp, i32 153, i32 %mul
818 define i32 @test_mul_nuw__all_are_safe(i32 %x) {
819 ; CHECK-LABEL: @test_mul_nuw__all_are_safe(
820 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
821 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[AND]], 9
822 ; CHECK-NEXT: ret i32 [[MUL]]
824 %and = and i32 %x, 255
825 %cmp = icmp eq i32 %and, 17
826 %mul = mul nuw i32 %and, 9
827 %sel = select i1 %cmp, i32 153, i32 %mul
831 define i32 @test_mul_nsw__all_are_safe(i32 %x) {
832 ; CHECK-LABEL: @test_mul_nsw__all_are_safe(
833 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
834 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[AND]], 9
835 ; CHECK-NEXT: ret i32 [[MUL]]
837 %and = and i32 %x, 255
838 %cmp = icmp eq i32 %and, 17
839 %mul = mul nsw i32 %and, 9
840 %sel = select i1 %cmp, i32 153, i32 %mul
844 define i32 @test_mul__all_are_safe(i32 %x) {
845 ; CHECK-LABEL: @test_mul__all_are_safe(
846 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 255
847 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[AND]], 9
848 ; CHECK-NEXT: ret i32 [[MUL]]
850 %and = and i32 %x, 255
851 %cmp = icmp eq i32 %and, 17
852 %mul = mul i32 %and, 9
853 %sel = select i1 %cmp, i32 153, i32 %mul
857 define i32 @test_mul_nuw_nsw__nuw_is_safe(i32 %x) {
858 ; CHECK-LABEL: @test_mul_nuw_nsw__nuw_is_safe(
859 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 268435457
860 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[AND]], 9
861 ; CHECK-NEXT: ret i32 [[MUL]]
863 %and = and i32 %x, 268435457
864 %cmp = icmp eq i32 %and, 268435456
865 %mul = mul nuw nsw i32 %and, 9
866 %sel = select i1 %cmp, i32 -1879048192, i32 %mul
870 define i32 @test_mul_nuw__nuw_is_safe(i32 %x) {
871 ; CHECK-LABEL: @test_mul_nuw__nuw_is_safe(
872 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 268435457
873 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[AND]], 9
874 ; CHECK-NEXT: ret i32 [[MUL]]
876 %and = and i32 %x, 268435457
877 %cmp = icmp eq i32 %and, 268435456
878 %mul = mul nuw i32 %and, 9
879 %sel = select i1 %cmp, i32 -1879048192, i32 %mul
883 define i32 @test_mul_nsw__nuw_is_safe(i32 %x) {
884 ; CHECK-LABEL: @test_mul_nsw__nuw_is_safe(
885 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 268435457
886 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[AND]], 9
887 ; CHECK-NEXT: ret i32 [[MUL]]
889 %and = and i32 %x, 268435457
890 %cmp = icmp eq i32 %and, 268435456
891 %mul = mul nsw i32 %and, 9
892 %sel = select i1 %cmp, i32 -1879048192, i32 %mul
896 define i32 @test_mul__nuw_is_safe(i32 %x) {
897 ; CHECK-LABEL: @test_mul__nuw_is_safe(
898 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 268435457
899 ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[AND]], 9
900 ; CHECK-NEXT: ret i32 [[MUL]]
902 %and = and i32 %x, 268435457
903 %cmp = icmp eq i32 %and, 268435456
904 %mul = mul i32 %and, 9
905 %sel = select i1 %cmp, i32 -1879048192, i32 %mul
909 define i32 @test_mul_nuw_nsw__nsw_is_safe(i32 %x) {
910 ; CHECK-LABEL: @test_mul_nuw_nsw__nsw_is_safe(
911 ; CHECK-NEXT: [[AND:%.*]] = or i32 [[X:%.*]], -83886080
912 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[AND]], 9
913 ; CHECK-NEXT: ret i32 [[MUL]]
915 %and = or i32 %x, -83886080
916 %cmp = icmp eq i32 %and, -83886079
917 %mul = mul nuw nsw i32 %and, 9
918 %sel = select i1 %cmp, i32 -754974711, i32 %mul
922 define i32 @test_mul_nuw__nsw_is_safe(i32 %x) {
923 ; CHECK-LABEL: @test_mul_nuw__nsw_is_safe(
924 ; CHECK-NEXT: [[AND:%.*]] = or i32 [[X:%.*]], -83886080
925 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[AND]], 9
926 ; CHECK-NEXT: ret i32 [[MUL]]
928 %and = or i32 %x, -83886080
929 %cmp = icmp eq i32 %and, -83886079
930 %mul = mul nuw i32 %and, 9
931 %sel = select i1 %cmp, i32 -754974711, i32 %mul
935 define i32 @test_mul_nsw__nsw_is_safe(i32 %x) {
936 ; CHECK-LABEL: @test_mul_nsw__nsw_is_safe(
937 ; CHECK-NEXT: [[AND:%.*]] = or i32 [[X:%.*]], -83886080
938 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[AND]], 9
939 ; CHECK-NEXT: ret i32 [[MUL]]
941 %and = or i32 %x, -83886080
942 %cmp = icmp eq i32 %and, -83886079
943 %mul = mul nsw i32 %and, 9
944 %sel = select i1 %cmp, i32 -754974711, i32 %mul
948 define i32 @test_mul__nsw_is_safe(i32 %x) {
949 ; CHECK-LABEL: @test_mul__nsw_is_safe(
950 ; CHECK-NEXT: [[AND:%.*]] = or i32 [[X:%.*]], -83886080
951 ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[AND]], 9
952 ; CHECK-NEXT: ret i32 [[MUL]]
954 %and = or i32 %x, -83886080
955 %cmp = icmp eq i32 %and, -83886079
956 %mul = mul i32 %and, 9
957 %sel = select i1 %cmp, i32 -754974711, i32 %mul
961 define i32 @test_mul_nuw_nsw__none_are_safe(i32 %x) {
962 ; CHECK-LABEL: @test_mul_nuw_nsw__none_are_safe(
963 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], 9
964 ; CHECK-NEXT: ret i32 [[MUL]]
966 %cmp = icmp eq i32 %x, 805306368
967 %mul = mul nuw nsw i32 %x, 9
968 %sel = select i1 %cmp, i32 -1342177280, i32 %mul
972 define i32 @test_mul_nuw__none_are_safe(i32 %x) {
973 ; CHECK-LABEL: @test_mul_nuw__none_are_safe(
974 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], 9
975 ; CHECK-NEXT: ret i32 [[MUL]]
977 %cmp = icmp eq i32 %x, 805306368
978 %mul = mul nuw i32 %x, 9
979 %sel = select i1 %cmp, i32 -1342177280, i32 %mul
983 define i32 @test_mul_nsw__none_are_safe(i32 %x) {
984 ; CHECK-LABEL: @test_mul_nsw__none_are_safe(
985 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], 9
986 ; CHECK-NEXT: ret i32 [[MUL]]
988 %cmp = icmp eq i32 %x, 805306368
989 %mul = mul nsw i32 %x, 9
990 %sel = select i1 %cmp, i32 -1342177280, i32 %mul
994 define i32 @test_mul__none_are_safe(i32 %x) {
995 ; CHECK-LABEL: @test_mul__none_are_safe(
996 ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], 9
997 ; CHECK-NEXT: ret i32 [[MUL]]
999 %cmp = icmp eq i32 %x, 805306368
1000 %mul = mul i32 %x, 9
1001 %sel = select i1 %cmp, i32 -1342177280, i32 %mul