1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 define i32 @zero_dividend(i32 %A) {
5 ; CHECK-LABEL: @zero_dividend(
6 ; CHECK-NEXT: ret i32 0
12 define <2 x i32> @zero_dividend_vector(<2 x i32> %A) {
13 ; CHECK-LABEL: @zero_dividend_vector(
14 ; CHECK-NEXT: ret <2 x i32> zeroinitializer
16 %B = udiv <2 x i32> zeroinitializer, %A
20 define <2 x i32> @zero_dividend_vector_poison_elt(<2 x i32> %A) {
21 ; CHECK-LABEL: @zero_dividend_vector_poison_elt(
22 ; CHECK-NEXT: ret <2 x i32> zeroinitializer
24 %B = sdiv <2 x i32> <i32 0, i32 poison>, %A
28 ; Division-by-zero is poison. UB in any vector lane means the whole op is poison.
30 define <2 x i8> @sdiv_zero_elt_vec_constfold(<2 x i8> %x) {
31 ; CHECK-LABEL: @sdiv_zero_elt_vec_constfold(
32 ; CHECK-NEXT: ret <2 x i8> <i8 poison, i8 0>
34 %div = sdiv <2 x i8> <i8 1, i8 2>, <i8 0, i8 -42>
38 define <2 x i8> @udiv_zero_elt_vec_constfold(<2 x i8> %x) {
39 ; CHECK-LABEL: @udiv_zero_elt_vec_constfold(
40 ; CHECK-NEXT: ret <2 x i8> <i8 0, i8 poison>
42 %div = udiv <2 x i8> <i8 1, i8 2>, <i8 42, i8 0>
46 define <2 x i8> @sdiv_zero_elt_vec(<2 x i8> %x) {
47 ; CHECK-LABEL: @sdiv_zero_elt_vec(
48 ; CHECK-NEXT: [[DIV:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 -42, i8 0>
49 ; CHECK-NEXT: ret <2 x i8> [[DIV]]
51 %div = sdiv <2 x i8> %x, <i8 -42, i8 0>
55 define <2 x i8> @udiv_zero_elt_vec(<2 x i8> %x) {
56 ; CHECK-LABEL: @udiv_zero_elt_vec(
57 ; CHECK-NEXT: [[DIV:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 0, i8 42>
58 ; CHECK-NEXT: ret <2 x i8> [[DIV]]
60 %div = udiv <2 x i8> %x, <i8 0, i8 42>
64 define <2 x i8> @sdiv_poison_elt_vec(<2 x i8> %x) {
65 ; CHECK-LABEL: @sdiv_poison_elt_vec(
66 ; CHECK-NEXT: [[DIV:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 -42, i8 poison>
67 ; CHECK-NEXT: ret <2 x i8> [[DIV]]
69 %div = sdiv <2 x i8> %x, <i8 -42, i8 poison>
73 define <2 x i8> @udiv_poison_elt_vec(<2 x i8> %x) {
74 ; CHECK-LABEL: @udiv_poison_elt_vec(
75 ; CHECK-NEXT: [[DIV:%.*]] = udiv <2 x i8> [[X:%.*]], <i8 poison, i8 42>
76 ; CHECK-NEXT: ret <2 x i8> [[DIV]]
78 %div = udiv <2 x i8> %x, <i8 poison, i8 42>
82 ; Division-by-zero is poison. UB in any vector lane means the whole op is poison.
83 ; Thus, we can simplify this: if any element of 'y' is 0, we can do anything.
84 ; Therefore, assume that all elements of 'y' must be 1.
86 define <2 x i1> @sdiv_bool_vec(<2 x i1> %x, <2 x i1> %y) {
87 ; CHECK-LABEL: @sdiv_bool_vec(
88 ; CHECK-NEXT: ret <2 x i1> [[X:%.*]]
90 %div = sdiv <2 x i1> %x, %y
94 define <2 x i1> @udiv_bool_vec(<2 x i1> %x, <2 x i1> %y) {
95 ; CHECK-LABEL: @udiv_bool_vec(
96 ; CHECK-NEXT: ret <2 x i1> [[X:%.*]]
98 %div = udiv <2 x i1> %x, %y
102 define i32 @zext_bool_udiv_divisor(i1 %x, i32 %y) {
103 ; CHECK-LABEL: @zext_bool_udiv_divisor(
104 ; CHECK-NEXT: ret i32 [[Y:%.*]]
106 %ext = zext i1 %x to i32
107 %r = udiv i32 %y, %ext
111 define <2 x i32> @zext_bool_sdiv_divisor_vec(<2 x i1> %x, <2 x i32> %y) {
112 ; CHECK-LABEL: @zext_bool_sdiv_divisor_vec(
113 ; CHECK-NEXT: ret <2 x i32> [[Y:%.*]]
115 %ext = zext <2 x i1> %x to <2 x i32>
116 %r = sdiv <2 x i32> %y, %ext
120 define i32 @udiv_dividend_known_smaller_than_constant_divisor(i32 %x) {
121 ; CHECK-LABEL: @udiv_dividend_known_smaller_than_constant_divisor(
122 ; CHECK-NEXT: ret i32 0
124 %and = and i32 %x, 250
125 %div = udiv i32 %and, 251
129 define i32 @not_udiv_dividend_known_smaller_than_constant_divisor(i32 %x) {
130 ; CHECK-LABEL: @not_udiv_dividend_known_smaller_than_constant_divisor(
131 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 251
132 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[AND]], 251
133 ; CHECK-NEXT: ret i32 [[DIV]]
135 %and = and i32 %x, 251
136 %div = udiv i32 %and, 251
140 define i32 @udiv_constant_dividend_known_smaller_than_divisor(i32 %x) {
141 ; CHECK-LABEL: @udiv_constant_dividend_known_smaller_than_divisor(
142 ; CHECK-NEXT: ret i32 0
145 %div = udiv i32 250, %or
149 define i32 @not_udiv_constant_dividend_known_smaller_than_divisor(i32 %x) {
150 ; CHECK-LABEL: @not_udiv_constant_dividend_known_smaller_than_divisor(
151 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], 251
152 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 251, [[OR]]
153 ; CHECK-NEXT: ret i32 [[DIV]]
156 %div = udiv i32 251, %or
160 define i8 @udiv_dividend_known_smaller_than_constant_divisor2(i1 %b) {
161 ; CHECK-LABEL: @udiv_dividend_known_smaller_than_constant_divisor2(
162 ; CHECK-NEXT: ret i8 0
164 %t0 = zext i1 %b to i8
165 %xor = xor i8 %t0, 12
166 %r = udiv i8 %xor, 14
170 ; negative test - dividend can equal 13
172 define i8 @not_udiv_dividend_known_smaller_than_constant_divisor2(i1 %b) {
173 ; CHECK-LABEL: @not_udiv_dividend_known_smaller_than_constant_divisor2(
174 ; CHECK-NEXT: [[T0:%.*]] = zext i1 [[B:%.*]] to i8
175 ; CHECK-NEXT: [[XOR:%.*]] = xor i8 [[T0]], 12
176 ; CHECK-NEXT: [[R:%.*]] = udiv i8 [[XOR]], 13
177 ; CHECK-NEXT: ret i8 [[R]]
179 %t0 = zext i1 %b to i8
180 %xor = xor i8 %t0, 12
181 %r = udiv i8 %xor, 13
185 ; This would require computing known bits on both x and y. Is it worth doing?
187 define i32 @udiv_dividend_known_smaller_than_divisor(i32 %x, i32 %y) {
188 ; CHECK-LABEL: @udiv_dividend_known_smaller_than_divisor(
189 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 250
190 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[Y:%.*]], 251
191 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[AND]], [[OR]]
192 ; CHECK-NEXT: ret i32 [[DIV]]
194 %and = and i32 %x, 250
196 %div = udiv i32 %and, %or
200 define i32 @not_udiv_dividend_known_smaller_than_divisor(i32 %x, i32 %y) {
201 ; CHECK-LABEL: @not_udiv_dividend_known_smaller_than_divisor(
202 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 251
203 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[Y:%.*]], 251
204 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[AND]], [[OR]]
205 ; CHECK-NEXT: ret i32 [[DIV]]
207 %and = and i32 %x, 251
209 %div = udiv i32 %and, %or
213 declare i32 @external()
216 ; CHECK-LABEL: @div1(
217 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @external(), !range [[RNG0:![0-9]+]]
218 ; CHECK-NEXT: ret i32 0
220 %call = call i32 @external(), !range !0
221 %urem = udiv i32 %call, 3
225 define i8 @sdiv_minusone_divisor() {
226 ; CHECK-LABEL: @sdiv_minusone_divisor(
227 ; CHECK-NEXT: ret i8 poison
229 %v = sdiv i8 -128, -1
233 @g = external global i64
234 @g2 = external global i64
236 define i64 @const_sdiv_one() {
237 ; CHECK-LABEL: @const_sdiv_one(
238 ; CHECK-NEXT: ret i64 ptrtoint (ptr @g to i64)
240 %div = sdiv i64 ptrtoint (ptr @g to i64), 1
244 define i64 @const_srem_one() {
245 ; CHECK-LABEL: @const_srem_one(
246 ; CHECK-NEXT: ret i64 0
248 %rem = srem i64 ptrtoint (ptr @g to i64), 1
252 define i64 @const_udiv_one() {
253 ; CHECK-LABEL: @const_udiv_one(
254 ; CHECK-NEXT: ret i64 ptrtoint (ptr @g to i64)
256 %div = udiv i64 ptrtoint (ptr @g to i64), 1
260 define i64 @const_urem_one() {
261 ; CHECK-LABEL: @const_urem_one(
262 ; CHECK-NEXT: ret i64 0
264 %rem = urem i64 ptrtoint (ptr @g to i64), 1
268 define i64 @const_sdiv_zero() {
269 ; CHECK-LABEL: @const_sdiv_zero(
270 ; CHECK-NEXT: ret i64 0
272 %div = sdiv i64 0, ptrtoint (ptr @g to i64)
276 define i64 @const_srem_zero() {
277 ; CHECK-LABEL: @const_srem_zero(
278 ; CHECK-NEXT: ret i64 0
280 %rem = srem i64 0, ptrtoint (ptr @g to i64)
284 define i64 @const_udiv_zero() {
285 ; CHECK-LABEL: @const_udiv_zero(
286 ; CHECK-NEXT: ret i64 0
288 %div = udiv i64 0, ptrtoint (ptr @g to i64)
292 define i64 @const_urem_zero() {
293 ; CHECK-LABEL: @const_urem_zero(
294 ; CHECK-NEXT: ret i64 0
296 %rem = urem i64 0, ptrtoint (ptr @g to i64)
300 define i64 @const_sdiv_zero_negone() {
301 ; CHECK-LABEL: @const_sdiv_zero_negone(
302 ; CHECK-NEXT: ret i64 0
304 %div = sdiv i64 0, -1
308 define i1 @const_sdiv_i1() {
309 ; CHECK-LABEL: @const_sdiv_i1(
310 ; CHECK-NEXT: ret i1 ptrtoint (ptr @g to i1)
312 %div = sdiv i1 ptrtoint (ptr @g to i1), ptrtoint (ptr @g2 to i1)
316 define i1 @const_srem_1() {
317 ; CHECK-LABEL: @const_srem_1(
318 ; CHECK-NEXT: ret i1 false
320 %rem = srem i1 ptrtoint (ptr @g to i1), ptrtoint (ptr @g2 to i1)
324 define i1 @const_udiv_i1() {
325 ; CHECK-LABEL: @const_udiv_i1(
326 ; CHECK-NEXT: ret i1 ptrtoint (ptr @g to i1)
328 %div = udiv i1 ptrtoint (ptr @g to i1), ptrtoint (ptr @g2 to i1)
332 define i1 @const_urem_1() {
333 ; CHECK-LABEL: @const_urem_1(
334 ; CHECK-NEXT: ret i1 false
336 %rem = urem i1 ptrtoint (ptr @g to i1), ptrtoint (ptr @g2 to i1)
340 ; Can't divide evenly, so create poison.
342 define i8 @sdiv_exact_trailing_zeros(i8 %x) {
343 ; CHECK-LABEL: @sdiv_exact_trailing_zeros(
344 ; CHECK-NEXT: ret i8 poison
346 %o = or i8 %x, 1 ; odd number
347 %r = sdiv exact i8 %o, -42 ; can't divide exactly
351 ; Negative test - could divide evenly.
353 define i8 @sdiv_exact_trailing_zeros_eq(i8 %x) {
354 ; CHECK-LABEL: @sdiv_exact_trailing_zeros_eq(
355 ; CHECK-NEXT: [[O:%.*]] = or i8 [[X:%.*]], 2
356 ; CHECK-NEXT: [[R:%.*]] = sdiv exact i8 [[O]], -42
357 ; CHECK-NEXT: ret i8 [[R]]
360 %r = sdiv exact i8 %o, -42
364 ; Negative test - must be exact div.
366 define i8 @sdiv_trailing_zeros(i8 %x) {
367 ; CHECK-LABEL: @sdiv_trailing_zeros(
368 ; CHECK-NEXT: [[O:%.*]] = or i8 [[X:%.*]], 1
369 ; CHECK-NEXT: [[R:%.*]] = sdiv i8 [[O]], -12
370 ; CHECK-NEXT: ret i8 [[R]]
377 ; TODO: Match non-splat vector constants.
379 define <2 x i8> @sdiv_exact_trailing_zeros_nonuniform_vector(<2 x i8> %x) {
380 ; CHECK-LABEL: @sdiv_exact_trailing_zeros_nonuniform_vector(
381 ; CHECK-NEXT: [[O:%.*]] = or <2 x i8> [[X:%.*]], <i8 3, i8 1>
382 ; CHECK-NEXT: [[R:%.*]] = sdiv exact <2 x i8> [[O]], <i8 12, i8 2>
383 ; CHECK-NEXT: ret <2 x i8> [[R]]
385 %o = or <2 x i8> %x, <i8 3, i8 1>
386 %r = sdiv exact <2 x i8> %o, <i8 12, i8 2>
390 ; Can't divide evenly, so create poison.
392 define <2 x i8> @udiv_exact_trailing_zeros(<2 x i8> %x) {
393 ; CHECK-LABEL: @udiv_exact_trailing_zeros(
394 ; CHECK-NEXT: ret <2 x i8> poison
396 %o = or <2 x i8> %x, <i8 3, i8 3>
397 %r = udiv exact <2 x i8> %o, <i8 12, i8 12> ; can't divide exactly
401 ; Negative test - could divide evenly.
403 define <2 x i8> @udiv_exact_trailing_zeros_eq(<2 x i8> %x) {
404 ; CHECK-LABEL: @udiv_exact_trailing_zeros_eq(
405 ; CHECK-NEXT: [[O:%.*]] = or <2 x i8> [[X:%.*]], splat (i8 28)
406 ; CHECK-NEXT: [[R:%.*]] = udiv exact <2 x i8> [[O]], splat (i8 12)
407 ; CHECK-NEXT: ret <2 x i8> [[R]]
409 %o = or <2 x i8> %x, <i8 28, i8 28>
410 %r = udiv exact <2 x i8> %o, <i8 12, i8 12>
414 ; Negative test - must be exact div.
416 define i8 @udiv_trailing_zeros(i8 %x) {
417 ; CHECK-LABEL: @udiv_trailing_zeros(
418 ; CHECK-NEXT: [[O:%.*]] = or i8 [[X:%.*]], 1
419 ; CHECK-NEXT: [[R:%.*]] = udiv i8 [[O]], 12
420 ; CHECK-NEXT: ret i8 [[R]]
427 ; Negative test - only the first element is poison
429 define <2 x i8> @udiv_exact_trailing_zeros_nonuniform_vector(<2 x i8> %x) {
430 ; CHECK-LABEL: @udiv_exact_trailing_zeros_nonuniform_vector(
431 ; CHECK-NEXT: [[O:%.*]] = or <2 x i8> [[X:%.*]], splat (i8 3)
432 ; CHECK-NEXT: [[R:%.*]] = udiv exact <2 x i8> [[O]], <i8 12, i8 1>
433 ; CHECK-NEXT: ret <2 x i8> [[R]]
435 %o = or <2 x i8> %x, <i8 3, i8 3>
436 %r = udiv exact <2 x i8> %o, <i8 12, i8 1>
442 define i32 @sdiv_one_srem_divisor(i32 %a, i32 %b) {
443 ; CHECK-LABEL: @sdiv_one_srem_divisor(
444 ; CHECK-NEXT: ret i32 [[A:%.*]]
446 %srem = srem i32 1, %b
447 %sdiv = sdiv i32 %a, %srem
451 define i32 @sdiv_one_urem_divisor(i32 %a, i32 %b) {
452 ; CHECK-LABEL: @sdiv_one_urem_divisor(
453 ; CHECK-NEXT: ret i32 [[A:%.*]]
455 %urem = urem i32 1, %b
456 %sdiv = sdiv i32 %a, %urem
460 define i32 @udiv_one_srem_divisor(i32 %a, i32 %b) {
461 ; CHECK-LABEL: @udiv_one_srem_divisor(
462 ; CHECK-NEXT: ret i32 [[A:%.*]]
464 %srem = srem i32 1, %b
465 %udiv = udiv i32 %a, %srem
469 define i32 @udiv_one_urem_divisor(i32 %a, i32 %b) {
470 ; CHECK-LABEL: @udiv_one_urem_divisor(
471 ; CHECK-NEXT: ret i32 [[A:%.*]]
473 %urem = urem i32 1, %b
474 %udiv = udiv i32 %a, %urem
478 define i32 @srem_one_srem_divisor(i32 %a, i32 %b) {
479 ; CHECK-LABEL: @srem_one_srem_divisor(
480 ; CHECK-NEXT: ret i32 0
482 %srem = srem i32 1, %b
483 %srem1 = srem i32 %a, %srem
487 define i32 @urem_one_srem_divisor(i32 %a, i32 %b) {
488 ; CHECK-LABEL: @urem_one_srem_divisor(
489 ; CHECK-NEXT: ret i32 0
491 %srem = srem i32 1, %b
492 %urem = urem i32 %a, %srem
496 define i32 @srem_one_urem_divisor(i32 %a, i32 %b) {
497 ; CHECK-LABEL: @srem_one_urem_divisor(
498 ; CHECK-NEXT: ret i32 0
500 %urem = urem i32 1, %b
501 %srem = srem i32 %a, %urem
505 define i32 @urem_one_urem_divisor(i32 %a, i32 %b) {
506 ; CHECK-LABEL: @urem_one_urem_divisor(
507 ; CHECK-NEXT: ret i32 0
509 %urem = urem i32 1, %b
510 %urem1 = urem i32 %a, %urem
514 define <2 x i8> @sdiv_one_vec_srem_divisor(<2 x i8> %a, <2 x i8> %b) {
515 ; CHECK-LABEL: @sdiv_one_vec_srem_divisor(
516 ; CHECK-NEXT: ret <2 x i8> [[A:%.*]]
518 %srem = srem <2 x i8> <i8 1, i8 1>, %b
519 %sdiv = sdiv <2 x i8> %a, %srem
523 define i32 @sdiv_and_one_divisor(i32 %x, i32 %y) {
524 ; CHECK-LABEL: @sdiv_and_one_divisor(
525 ; CHECK-NEXT: ret i32 [[Y:%.*]]
528 %res = sdiv i32 %y, %and
532 define <2 x i8> @sdiv_and_one_vec_divisor(<2 x i8> %x, <2 x i8> %y) {
533 ; CHECK-LABEL: @sdiv_and_one_vec_divisor(
534 ; CHECK-NEXT: ret <2 x i8> [[Y:%.*]]
536 %and = and <2 x i8> %x, <i8 1, i8 1>
537 %res = sdiv <2 x i8> %y, %and
541 define i32 @sdiv_neg_or_divisor(i32 %x, i32 %y) {
542 ; CHECK-LABEL: @sdiv_neg_or_divisor(
543 ; CHECK-NEXT: ret i32 [[Y:%.*]]
546 %neg = xor i32 %or, -1
547 %res = sdiv i32 %y, %neg
551 define i32 @sdiv_neg_or_multi_one_bit_divisor(i32 %x, i32 %y) {
552 ; CHECK-LABEL: @sdiv_neg_or_multi_one_bit_divisor(
553 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[X:%.*]], -3
554 ; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[OR]], -1
555 ; CHECK-NEXT: [[RES:%.*]] = sdiv i32 [[Y:%.*]], [[NEG]]
556 ; CHECK-NEXT: ret i32 [[RES]]
559 %neg = xor i32 %or, -1
560 %res = sdiv i32 %y, %neg
564 define <2 x i8> @sdiv_vec_multi_one_bit_divisor(<2 x i8> %x, <2 x i8> %y) {
565 ; CHECK-LABEL: @sdiv_vec_multi_one_bit_divisor(
566 ; CHECK-NEXT: [[AND:%.*]] = and <2 x i8> [[X:%.*]], <i8 1, i8 3>
567 ; CHECK-NEXT: [[RES:%.*]] = sdiv <2 x i8> [[Y:%.*]], [[AND]]
568 ; CHECK-NEXT: ret <2 x i8> [[RES]]
570 %and = and <2 x i8> %x, <i8 1, i8 3>
571 %res = sdiv <2 x i8> %y, %and
575 define i8 @udiv_exact_mul_nsw(i8 %x) {
576 ; CHECK-LABEL: @udiv_exact_mul_nsw(
577 ; CHECK-NEXT: ret i8 [[X:%.*]]
579 %a = mul nsw i8 %x, 24
580 %b = udiv exact i8 %a, 24
584 define i8 @sdiv_exact_mul_nuw(i8 %x) {
585 ; CHECK-LABEL: @sdiv_exact_mul_nuw(
586 ; CHECK-NEXT: ret i8 [[X:%.*]]
588 %a = mul nuw i8 %x, 24
589 %b = sdiv exact i8 %a, 24
595 define i8 @udiv_exact_mul_nsw_mismatch(i8 %x) {
596 ; CHECK-LABEL: @udiv_exact_mul_nsw_mismatch(
597 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], 24
598 ; CHECK-NEXT: [[B:%.*]] = udiv exact i8 [[A]], 12
599 ; CHECK-NEXT: ret i8 [[B]]
601 %a = mul nsw i8 %x, 24
602 %b = udiv exact i8 %a, 12
606 define i8 @udiv_exact_mul_nsw_power_of_2(i8 %x) {
607 ; CHECK-LABEL: @udiv_exact_mul_nsw_power_of_2(
608 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], 8
609 ; CHECK-NEXT: [[B:%.*]] = udiv exact i8 [[A]], 8
610 ; CHECK-NEXT: ret i8 [[B]]
612 %a = mul nsw i8 %x, 8
613 %b = udiv exact i8 %a, 8
617 define i8 @sdiv_exact_mul_nuw_power_of_2(i8 %x) {
618 ; CHECK-LABEL: @sdiv_exact_mul_nuw_power_of_2(
619 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 8
620 ; CHECK-NEXT: [[B:%.*]] = sdiv exact i8 [[A]], 8
621 ; CHECK-NEXT: ret i8 [[B]]
623 %a = mul nuw i8 %x, 8
624 %b = sdiv exact i8 %a, 8
628 define i8 @udiv_exact_mul(i8 %x) {
629 ; CHECK-LABEL: @udiv_exact_mul(
630 ; CHECK-NEXT: [[A:%.*]] = mul i8 [[X:%.*]], 24
631 ; CHECK-NEXT: [[B:%.*]] = udiv exact i8 [[A]], 24
632 ; CHECK-NEXT: ret i8 [[B]]
635 %b = udiv exact i8 %a, 24
639 define i8 @sdiv_exact_mul(i8 %x) {
640 ; CHECK-LABEL: @sdiv_exact_mul(
641 ; CHECK-NEXT: [[A:%.*]] = mul i8 [[X:%.*]], 24
642 ; CHECK-NEXT: [[B:%.*]] = sdiv exact i8 [[A]], 24
643 ; CHECK-NEXT: ret i8 [[B]]
646 %b = sdiv exact i8 %a, 24
650 define i8 @udiv_mul_nsw(i8 %x) {
651 ; CHECK-LABEL: @udiv_mul_nsw(
652 ; CHECK-NEXT: [[A:%.*]] = mul nsw i8 [[X:%.*]], 24
653 ; CHECK-NEXT: [[B:%.*]] = udiv i8 [[A]], 24
654 ; CHECK-NEXT: ret i8 [[B]]
656 %a = mul nsw i8 %x, 24
661 define i8 @sdiv_mul_nuw(i8 %x) {
662 ; CHECK-LABEL: @sdiv_mul_nuw(
663 ; CHECK-NEXT: [[A:%.*]] = mul nuw i8 [[X:%.*]], 24
664 ; CHECK-NEXT: [[B:%.*]] = sdiv i8 [[A]], 24
665 ; CHECK-NEXT: ret i8 [[B]]
667 %a = mul nuw i8 %x, 24