1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; This test makes sure that div instructions are properly eliminated.
4 ; RUN: opt < %s -instcombine -S | FileCheck %s
6 define i32 @test1(i32 %A) {
8 ; CHECK-NEXT: ret i32 [[A:%.*]]
14 define i32 @test2(i32 %A) {
15 ; CHECK-LABEL: @test2(
16 ; CHECK-NEXT: [[B:%.*]] = lshr i32 [[A:%.*]], 3
17 ; CHECK-NEXT: ret i32 [[B]]
23 define i32 @sdiv_by_minus1(i32 %A) {
24 ; CHECK-LABEL: @sdiv_by_minus1(
25 ; CHECK-NEXT: [[B:%.*]] = sub i32 0, [[A:%.*]]
26 ; CHECK-NEXT: ret i32 [[B]]
32 define <2 x i64> @sdiv_by_minus1_vec(<2 x i64> %x) {
33 ; CHECK-LABEL: @sdiv_by_minus1_vec(
34 ; CHECK-NEXT: [[DIV:%.*]] = sub <2 x i64> zeroinitializer, [[X:%.*]]
35 ; CHECK-NEXT: ret <2 x i64> [[DIV]]
37 %div = sdiv <2 x i64> %x, <i64 -1, i64 -1>
41 define <2 x i64> @sdiv_by_minus1_vec_undef_elt(<2 x i64> %x) {
42 ; CHECK-LABEL: @sdiv_by_minus1_vec_undef_elt(
43 ; CHECK-NEXT: ret <2 x i64> poison
45 %div = sdiv <2 x i64> %x, <i64 -1, i64 undef>
49 define i32 @sdiv_by_sext_minus1(i1 %x, i32 %y) {
50 ; CHECK-LABEL: @sdiv_by_sext_minus1(
51 ; CHECK-NEXT: [[DIV:%.*]] = sub i32 0, [[Y:%.*]]
52 ; CHECK-NEXT: ret i32 [[DIV]]
54 %sext = sext i1 %x to i32
55 %div = sdiv i32 %y, %sext
59 define <2 x i32> @sdiv_by_sext_minus1_vec(<2 x i1> %x, <2 x i32> %y) {
60 ; CHECK-LABEL: @sdiv_by_sext_minus1_vec(
61 ; CHECK-NEXT: [[DIV:%.*]] = sub <2 x i32> zeroinitializer, [[Y:%.*]]
62 ; CHECK-NEXT: ret <2 x i32> [[DIV]]
64 %sext = sext <2 x i1> %x to <2 x i32>
65 %div = sdiv <2 x i32> %y, %sext
69 define i8 @udiv_by_negative(i8 %x) {
70 ; CHECK-LABEL: @udiv_by_negative(
71 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X:%.*]], -7
72 ; CHECK-NEXT: [[A:%.*]] = zext i1 [[TMP1]] to i8
73 ; CHECK-NEXT: ret i8 [[A]]
79 define i32 @udiv_by_minus1(i32 %A) {
80 ; CHECK-LABEL: @udiv_by_minus1(
81 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[A:%.*]], -1
82 ; CHECK-NEXT: [[B:%.*]] = zext i1 [[TMP1]] to i32
83 ; CHECK-NEXT: ret i32 [[B]]
89 define <2 x i64> @udiv_by_minus1_vec(<2 x i64> %x) {
90 ; CHECK-LABEL: @udiv_by_minus1_vec(
91 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i64> [[X:%.*]], <i64 -1, i64 -1>
92 ; CHECK-NEXT: [[DIV:%.*]] = zext <2 x i1> [[TMP1]] to <2 x i64>
93 ; CHECK-NEXT: ret <2 x i64> [[DIV]]
95 %div = udiv <2 x i64> %x, <i64 -1, i64 -1>
99 define i32 @udiv_by_sext_all_ones(i1 %x, i32 %y) {
100 ; CHECK-LABEL: @udiv_by_sext_all_ones(
101 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[Y:%.*]], -1
102 ; CHECK-NEXT: [[DIV:%.*]] = zext i1 [[TMP1]] to i32
103 ; CHECK-NEXT: ret i32 [[DIV]]
105 %sext = sext i1 %x to i32
106 %div = udiv i32 %y, %sext
110 define <2 x i32> @udiv_by_sext_all_ones_vec(<2 x i1> %x, <2 x i32> %y) {
111 ; CHECK-LABEL: @udiv_by_sext_all_ones_vec(
112 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i32> [[Y:%.*]], <i32 -1, i32 -1>
113 ; CHECK-NEXT: [[DIV:%.*]] = zext <2 x i1> [[TMP1]] to <2 x i32>
114 ; CHECK-NEXT: ret <2 x i32> [[DIV]]
116 %sext = sext <2 x i1> %x to <2 x i32>
117 %div = udiv <2 x i32> %y, %sext
121 define i32 @test5(i32 %A) {
122 ; CHECK-LABEL: @test5(
123 ; CHECK-NEXT: ret i32 0
125 %B = udiv i32 %A, -16
130 define i1 @test6(i32 %A) {
131 ; CHECK-LABEL: @test6(
132 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[A:%.*]], 123
133 ; CHECK-NEXT: ret i1 [[TMP1]]
135 %B = udiv i32 %A, 123
137 %C = icmp eq i32 %B, 0
141 define i1 @test7(i32 %A) {
142 ; CHECK-LABEL: @test7(
143 ; CHECK-NEXT: [[A_OFF:%.*]] = add i32 [[A:%.*]], -20
144 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 [[A_OFF]], 10
145 ; CHECK-NEXT: ret i1 [[TMP1]]
149 %C = icmp eq i32 %B, 2
153 define <2 x i1> @test7vec(<2 x i32> %A) {
154 ; CHECK-LABEL: @test7vec(
155 ; CHECK-NEXT: [[A_OFF:%.*]] = add <2 x i32> [[A:%.*]], <i32 -20, i32 -20>
156 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ult <2 x i32> [[A_OFF]], <i32 10, i32 10>
157 ; CHECK-NEXT: ret <2 x i1> [[TMP1]]
159 %B = udiv <2 x i32> %A, <i32 10, i32 10>
160 %C = icmp eq <2 x i32> %B, <i32 2, i32 2>
164 define i1 @test8(i8 %A) {
165 ; CHECK-LABEL: @test8(
166 ; CHECK-NEXT: [[C:%.*]] = icmp ugt i8 [[A:%.*]], -11
167 ; CHECK-NEXT: ret i1 [[C]]
171 %C = icmp eq i8 %B, 2
175 define <2 x i1> @test8vec(<2 x i8> %A) {
176 ; CHECK-LABEL: @test8vec(
177 ; CHECK-NEXT: [[C:%.*]] = icmp ugt <2 x i8> [[A:%.*]], <i8 -11, i8 -11>
178 ; CHECK-NEXT: ret <2 x i1> [[C]]
180 %B = udiv <2 x i8> %A, <i8 123, i8 123>
181 %C = icmp eq <2 x i8> %B, <i8 2, i8 2>
185 define i1 @test9(i8 %A) {
186 ; CHECK-LABEL: @test9(
187 ; CHECK-NEXT: [[C:%.*]] = icmp ult i8 [[A:%.*]], -10
188 ; CHECK-NEXT: ret i1 [[C]]
192 %C = icmp ne i8 %B, 2
196 define <2 x i1> @test9vec(<2 x i8> %A) {
197 ; CHECK-LABEL: @test9vec(
198 ; CHECK-NEXT: [[C:%.*]] = icmp ult <2 x i8> [[A:%.*]], <i8 -10, i8 -10>
199 ; CHECK-NEXT: ret <2 x i1> [[C]]
201 %B = udiv <2 x i8> %A, <i8 123, i8 123>
202 %C = icmp ne <2 x i8> %B, <i8 2, i8 2>
206 define i32 @test10(i32 %X, i1 %C) {
207 ; CHECK-LABEL: @test10(
208 ; CHECK-NEXT: [[R_V:%.*]] = select i1 [[C:%.*]], i32 6, i32 3
209 ; CHECK-NEXT: [[R:%.*]] = lshr i32 [[X:%.*]], [[R_V]]
210 ; CHECK-NEXT: ret i32 [[R]]
212 %V = select i1 %C, i32 64, i32 8
217 define i32 @test11(i32 %X, i1 %C) {
218 ; CHECK-LABEL: @test11(
219 ; CHECK-NEXT: [[B_V:%.*]] = select i1 [[C:%.*]], i32 10, i32 5
220 ; CHECK-NEXT: [[B:%.*]] = lshr i32 [[X:%.*]], [[B_V]]
221 ; CHECK-NEXT: ret i32 [[B]]
223 %A = select i1 %C, i32 1024, i32 32
229 define i32 @test12(i32 %x) {
230 ; CHECK-LABEL: @test12(
231 ; CHECK-NEXT: ret i32 1
233 %tmp3 = udiv i32 %x, %x ; 1
237 define i32 @test13(i32 %x) {
238 ; CHECK-LABEL: @test13(
239 ; CHECK-NEXT: ret i32 1
241 %tmp3 = sdiv i32 %x, %x ; 1
245 define i32 @test14(i8 %x) {
246 ; CHECK-LABEL: @test14(
247 ; CHECK-NEXT: ret i32 0
249 %zext = zext i8 %x to i32
250 %div = udiv i32 %zext, 257 ; 0
255 define i32 @test15(i32 %a, i32 %b) {
256 ; CHECK-LABEL: @test15(
257 ; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[B:%.*]], -2
258 ; CHECK-NEXT: [[DIV2:%.*]] = lshr i32 [[A:%.*]], [[TMP1]]
259 ; CHECK-NEXT: ret i32 [[DIV2]]
262 %div = lshr i32 %shl, 2
263 %div2 = udiv i32 %a, %div
267 define <2 x i64> @test16(<2 x i64> %x) {
268 ; CHECK-LABEL: @test16(
269 ; CHECK-NEXT: [[DIV:%.*]] = udiv <2 x i64> [[X:%.*]], <i64 192, i64 192>
270 ; CHECK-NEXT: ret <2 x i64> [[DIV]]
272 %shr = lshr <2 x i64> %x, <i64 5, i64 5>
273 %div = udiv <2 x i64> %shr, <i64 6, i64 6>
277 define i32 @test19(i32 %x) {
278 ; CHECK-LABEL: @test19(
279 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[X:%.*]], 1
280 ; CHECK-NEXT: [[A:%.*]] = zext i1 [[TMP1]] to i32
281 ; CHECK-NEXT: ret i32 [[A]]
287 define <2 x i32> @test19vec(<2 x i32> %x) {
288 ; CHECK-LABEL: @test19vec(
289 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i32> [[X:%.*]], <i32 1, i32 1>
290 ; CHECK-NEXT: [[A:%.*]] = zext <2 x i1> [[TMP1]] to <2 x i32>
291 ; CHECK-NEXT: ret <2 x i32> [[A]]
293 %A = udiv <2 x i32> <i32 1, i32 1>, %x
297 define i32 @test20(i32 %x) {
298 ; CHECK-LABEL: @test20(
299 ; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[X:%.*]], 1
300 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i32 [[TMP1]], 3
301 ; CHECK-NEXT: [[A:%.*]] = select i1 [[TMP2]], i32 [[X]], i32 0
302 ; CHECK-NEXT: ret i32 [[A]]
308 define <2 x i32> @test20vec(<2 x i32> %x) {
309 ; CHECK-LABEL: @test20vec(
310 ; CHECK-NEXT: [[TMP1:%.*]] = add <2 x i32> [[X:%.*]], <i32 1, i32 1>
311 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ult <2 x i32> [[TMP1]], <i32 3, i32 3>
312 ; CHECK-NEXT: [[A:%.*]] = select <2 x i1> [[TMP2]], <2 x i32> [[X]], <2 x i32> zeroinitializer
313 ; CHECK-NEXT: ret <2 x i32> [[A]]
315 %A = sdiv <2 x i32> <i32 1, i32 1>, %x
319 define i32 @test21(i32 %a) {
320 ; CHECK-LABEL: @test21(
321 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[A:%.*]], 3
322 ; CHECK-NEXT: ret i32 [[DIV]]
324 %shl = shl nsw i32 %a, 2
325 %div = sdiv i32 %shl, 12
329 define i32 @test22(i32 %a) {
330 ; CHECK-LABEL: @test22(
331 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[A:%.*]], 4
332 ; CHECK-NEXT: ret i32 [[DIV]]
334 %mul = mul nsw i32 %a, 3
335 %div = sdiv i32 %mul, 12
339 define i32 @test23(i32 %a) {
340 ; CHECK-LABEL: @test23(
341 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[A:%.*]], 3
342 ; CHECK-NEXT: ret i32 [[DIV]]
344 %shl = shl nuw i32 %a, 2
345 %div = udiv i32 %shl, 12
349 define i32 @test24(i32 %a) {
350 ; CHECK-LABEL: @test24(
351 ; CHECK-NEXT: [[DIV:%.*]] = lshr i32 [[A:%.*]], 2
352 ; CHECK-NEXT: ret i32 [[DIV]]
354 %mul = mul nuw i32 %a, 3
355 %div = udiv i32 %mul, 12
359 define i32 @test25(i32 %a) {
360 ; CHECK-LABEL: @test25(
361 ; CHECK-NEXT: [[DIV:%.*]] = shl nsw i32 [[A:%.*]], 1
362 ; CHECK-NEXT: ret i32 [[DIV]]
364 %shl = shl nsw i32 %a, 2
365 %div = sdiv i32 %shl, 2
369 define i32 @test26(i32 %a) {
370 ; CHECK-LABEL: @test26(
371 ; CHECK-NEXT: [[DIV:%.*]] = shl nsw i32 [[A:%.*]], 2
372 ; CHECK-NEXT: ret i32 [[DIV]]
374 %mul = mul nsw i32 %a, 12
375 %div = sdiv i32 %mul, 3
379 define i32 @test27(i32 %a) {
380 ; CHECK-LABEL: @test27(
381 ; CHECK-NEXT: [[DIV:%.*]] = shl nuw i32 [[A:%.*]], 1
382 ; CHECK-NEXT: ret i32 [[DIV]]
384 %shl = shl nuw i32 %a, 2
385 %div = udiv i32 %shl, 2
389 define i32 @test28(i32 %a) {
390 ; CHECK-LABEL: @test28(
391 ; CHECK-NEXT: [[DIV:%.*]] = mul nuw i32 [[A:%.*]], 12
392 ; CHECK-NEXT: ret i32 [[DIV]]
394 %mul = mul nuw i32 %a, 36
395 %div = udiv i32 %mul, 3
399 define i32 @test29(i32 %a) {
400 ; CHECK-LABEL: @test29(
401 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i32 [[A:%.*]], -1
402 ; CHECK-NEXT: [[DIV:%.*]] = zext i1 [[TMP1]] to i32
403 ; CHECK-NEXT: ret i32 [[DIV]]
405 %mul = shl nsw i32 %a, 31
406 %div = sdiv i32 %mul, -2147483648
410 define i32 @test30(i32 %a) {
411 ; CHECK-LABEL: @test30(
412 ; CHECK-NEXT: ret i32 [[A:%.*]]
414 %mul = shl nuw i32 %a, 31
415 %div = udiv i32 %mul, -2147483648
419 define <2 x i32> @test31(<2 x i32> %x) {
420 ; CHECK-LABEL: @test31(
421 ; CHECK-NEXT: ret <2 x i32> zeroinitializer
423 %shr = lshr <2 x i32> %x, <i32 31, i32 31>
424 %div = udiv <2 x i32> %shr, <i32 2147483647, i32 2147483647>
428 define i32 @test32(i32 %a, i32 %b) {
429 ; CHECK-LABEL: @test32(
430 ; CHECK-NEXT: [[SHL:%.*]] = shl i32 2, [[B:%.*]]
431 ; CHECK-NEXT: [[DIV:%.*]] = lshr i32 [[SHL]], 2
432 ; CHECK-NEXT: [[DIV2:%.*]] = udiv i32 [[A:%.*]], [[DIV]]
433 ; CHECK-NEXT: ret i32 [[DIV2]]
436 %div = lshr i32 %shl, 2
437 %div2 = udiv i32 %a, %div
441 define <2 x i64> @test33(<2 x i64> %x) {
442 ; CHECK-LABEL: @test33(
443 ; CHECK-NEXT: [[DIV:%.*]] = udiv exact <2 x i64> [[X:%.*]], <i64 192, i64 192>
444 ; CHECK-NEXT: ret <2 x i64> [[DIV]]
446 %shr = lshr exact <2 x i64> %x, <i64 5, i64 5>
447 %div = udiv exact <2 x i64> %shr, <i64 6, i64 6>
451 ; -X / C --> X / -C (if negation does not overflow)
453 define i8 @sdiv_negated_dividend_constant_divisor(i8 %x) {
454 ; CHECK-LABEL: @sdiv_negated_dividend_constant_divisor(
455 ; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[X:%.*]], 42
456 ; CHECK-NEXT: ret i8 [[D]]
458 %neg = sub nsw i8 0, %x
459 %d = sdiv i8 %neg, -42
463 define <2 x i8> @sdiv_negated_dividend_constant_divisor_vec_splat(<2 x i8> %x) {
464 ; CHECK-LABEL: @sdiv_negated_dividend_constant_divisor_vec_splat(
465 ; CHECK-NEXT: [[D:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 42, i8 42>
466 ; CHECK-NEXT: ret <2 x i8> [[D]]
468 %neg = sub nsw <2 x i8> zeroinitializer, %x
469 %d = sdiv <2 x i8> %neg, <i8 -42, i8 -42>
473 define i8 @sdiv_exact_negated_dividend_constant_divisor(i8 %x) {
474 ; CHECK-LABEL: @sdiv_exact_negated_dividend_constant_divisor(
475 ; CHECK-NEXT: [[D:%.*]] = sdiv exact i8 [[X:%.*]], 42
476 ; CHECK-NEXT: ret i8 [[D]]
478 %neg = sub nsw i8 0, %x
479 %d = sdiv exact i8 %neg, -42
483 define <2 x i8> @sdiv_exact_negated_dividend_constant_divisor_vec_splat(<2 x i8> %x) {
484 ; CHECK-LABEL: @sdiv_exact_negated_dividend_constant_divisor_vec_splat(
485 ; CHECK-NEXT: [[D:%.*]] = sdiv exact <2 x i8> [[X:%.*]], <i8 42, i8 42>
486 ; CHECK-NEXT: ret <2 x i8> [[D]]
488 %neg = sub nsw <2 x i8> zeroinitializer, %x
489 %d = sdiv exact <2 x i8> %neg, <i8 -42, i8 -42>
493 define i8 @sdiv_negated_dividend_constant_divisor_smin(i8 %x) {
494 ; CHECK-LABEL: @sdiv_negated_dividend_constant_divisor_smin(
495 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X:%.*]], -128
496 ; CHECK-NEXT: [[D:%.*]] = zext i1 [[TMP1]] to i8
497 ; CHECK-NEXT: ret i8 [[D]]
499 %neg = sub nsw i8 0, %x
500 %d = sdiv i8 %neg, -128
504 define <2 x i8> @sdiv_negated_dividend_constant_divisor_vec_splat_smin(<2 x i8> %x) {
505 ; CHECK-LABEL: @sdiv_negated_dividend_constant_divisor_vec_splat_smin(
506 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 -128, i8 -128>
507 ; CHECK-NEXT: [[D:%.*]] = zext <2 x i1> [[TMP1]] to <2 x i8>
508 ; CHECK-NEXT: ret <2 x i8> [[D]]
510 %neg = sub nsw <2 x i8> zeroinitializer, %x
511 %d = sdiv <2 x i8> %neg, <i8 -128, i8 -128>
515 define <2 x i8> @sdiv_negated_dividend_constant_divisor_vec_undef(<2 x i8> %x) {
516 ; CHECK-LABEL: @sdiv_negated_dividend_constant_divisor_vec_undef(
517 ; CHECK-NEXT: ret <2 x i8> poison
519 %neg = sub nsw <2 x i8> zeroinitializer, %x
520 %d = sdiv <2 x i8> %neg, <i8 -128, i8 undef>
524 define <2 x i64> @sdiv_negated_dividend_constant_divisor_vec(<2 x i64> %x) {
525 ; CHECK-LABEL: @sdiv_negated_dividend_constant_divisor_vec(
526 ; CHECK-NEXT: [[DIV1_NEG:%.*]] = sdiv <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
527 ; CHECK-NEXT: ret <2 x i64> [[DIV1_NEG]]
529 %neg = sub nsw <2 x i64> zeroinitializer, %x
530 %div = sdiv <2 x i64> %neg, <i64 3, i64 4>
534 define <2 x i64> @sdiv_exact_negated_dividend_constant_divisor_vec(<2 x i64> %x) {
535 ; CHECK-LABEL: @sdiv_exact_negated_dividend_constant_divisor_vec(
536 ; CHECK-NEXT: [[DIV1_NEG:%.*]] = sdiv exact <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
537 ; CHECK-NEXT: ret <2 x i64> [[DIV1_NEG]]
539 %neg = sub nsw <2 x i64> zeroinitializer, %x
540 %div = sdiv exact <2 x i64> %neg, <i64 3, i64 4>
544 ; Can't negate signed min vector element.
546 define <2 x i8> @sdiv_exact_negated_dividend_constant_divisor_vec_overflow(<2 x i8> %x) {
547 ; CHECK-LABEL: @sdiv_exact_negated_dividend_constant_divisor_vec_overflow(
548 ; CHECK-NEXT: [[DIV1:%.*]] = sdiv exact <2 x i8> [[X:%.*]], <i8 -128, i8 42>
549 ; CHECK-NEXT: [[DIV:%.*]] = sub nsw <2 x i8> zeroinitializer, [[DIV1]]
550 ; CHECK-NEXT: ret <2 x i8> [[DIV]]
552 %neg = sub nsw <2 x i8> zeroinitializer, %x
553 %div = sdiv exact <2 x i8> %neg, <i8 -128, i8 42>
557 define i32 @test35(i32 %A) {
558 ; CHECK-LABEL: @test35(
559 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[A:%.*]], 2147483647
560 ; CHECK-NEXT: [[MUL:%.*]] = udiv exact i32 [[AND]], 2147483647
561 ; CHECK-NEXT: ret i32 [[MUL]]
563 %and = and i32 %A, 2147483647
564 %mul = sdiv exact i32 %and, 2147483647
568 define <2 x i32> @test35vec(<2 x i32> %A) {
569 ; CHECK-LABEL: @test35vec(
570 ; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[A:%.*]], <i32 2147483647, i32 2147483647>
571 ; CHECK-NEXT: [[MUL:%.*]] = udiv exact <2 x i32> [[AND]], <i32 2147483647, i32 2147483647>
572 ; CHECK-NEXT: ret <2 x i32> [[MUL]]
574 %and = and <2 x i32> %A, <i32 2147483647, i32 2147483647>
575 %mul = sdiv exact <2 x i32> %and, <i32 2147483647, i32 2147483647>
579 define i32 @test36(i32 %A) {
580 ; CHECK-LABEL: @test36(
581 ; CHECK-NEXT: [[AND:%.*]] = and i32 [[A:%.*]], 2147483647
582 ; CHECK-NEXT: [[MUL:%.*]] = lshr exact i32 [[AND]], [[A]]
583 ; CHECK-NEXT: ret i32 [[MUL]]
585 %and = and i32 %A, 2147483647
586 %shl = shl nsw i32 1, %A
587 %mul = sdiv exact i32 %and, %shl
591 define <2 x i32> @test36vec(<2 x i32> %A) {
592 ; CHECK-LABEL: @test36vec(
593 ; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> [[A:%.*]], <i32 2147483647, i32 2147483647>
594 ; CHECK-NEXT: [[MUL:%.*]] = lshr exact <2 x i32> [[AND]], [[A]]
595 ; CHECK-NEXT: ret <2 x i32> [[MUL]]
597 %and = and <2 x i32> %A, <i32 2147483647, i32 2147483647>
598 %shl = shl nsw <2 x i32> <i32 1, i32 1>, %A
599 %mul = sdiv exact <2 x i32> %and, %shl
603 define i32 @test37(i32* %b) {
604 ; CHECK-LABEL: @test37(
606 ; CHECK-NEXT: store i32 0, i32* [[B:%.*]], align 4
607 ; CHECK-NEXT: br i1 undef, label [[LOR_RHS:%.*]], label [[LOR_END:%.*]]
609 ; CHECK-NEXT: br label [[LOR_END]]
611 ; CHECK-NEXT: ret i32 0
614 store i32 0, i32* %b, align 4
615 %0 = load i32, i32* %b, align 4
616 br i1 undef, label %lor.rhs, label %lor.end
618 lor.rhs: ; preds = %entry
619 %mul = mul nsw i32 undef, %0
622 lor.end: ; preds = %lor.rhs, %entry
623 %t.0 = phi i32 [ %0, %entry ], [ %mul, %lor.rhs ]
624 %div = sdiv i32 %t.0, 2
628 ; We can perform the division in the smaller type.
630 define i32 @shrink(i8 %x) {
631 ; CHECK-LABEL: @shrink(
632 ; CHECK-NEXT: [[TMP1:%.*]] = sdiv i8 [[X:%.*]], 127
633 ; CHECK-NEXT: [[DIV:%.*]] = sext i8 [[TMP1]] to i32
634 ; CHECK-NEXT: ret i32 [[DIV]]
636 %conv = sext i8 %x to i32
637 %div = sdiv i32 %conv, 127
641 ; Division in the smaller type can lead to more optimizations.
643 define i32 @zap(i8 %x) {
645 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X:%.*]], -128
646 ; CHECK-NEXT: [[DIV:%.*]] = zext i1 [[TMP1]] to i32
647 ; CHECK-NEXT: ret i32 [[DIV]]
649 %conv = sext i8 %x to i32
650 %div = sdiv i32 %conv, -128
654 ; Splat constant divisors should get the same folds.
656 define <3 x i32> @shrink_vec(<3 x i8> %x) {
657 ; CHECK-LABEL: @shrink_vec(
658 ; CHECK-NEXT: [[TMP1:%.*]] = sdiv <3 x i8> [[X:%.*]], <i8 127, i8 127, i8 127>
659 ; CHECK-NEXT: [[DIV:%.*]] = sext <3 x i8> [[TMP1]] to <3 x i32>
660 ; CHECK-NEXT: ret <3 x i32> [[DIV]]
662 %conv = sext <3 x i8> %x to <3 x i32>
663 %div = sdiv <3 x i32> %conv, <i32 127, i32 127, i32 127>
667 define <2 x i32> @zap_vec(<2 x i8> %x) {
668 ; CHECK-LABEL: @zap_vec(
669 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 -128, i8 -128>
670 ; CHECK-NEXT: [[DIV:%.*]] = zext <2 x i1> [[TMP1]] to <2 x i32>
671 ; CHECK-NEXT: ret <2 x i32> [[DIV]]
673 %conv = sext <2 x i8> %x to <2 x i32>
674 %div = sdiv <2 x i32> %conv, <i32 -128, i32 -128>
678 ; But we can't do this if the signed constant won't fit in the original type.
680 define i32 @shrink_no(i8 %x) {
681 ; CHECK-LABEL: @shrink_no(
682 ; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[X:%.*]] to i32
683 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[CONV]], 128
684 ; CHECK-NEXT: ret i32 [[DIV]]
686 %conv = sext i8 %x to i32
687 %div = sdiv i32 %conv, 128
691 ; When the divisor is known larger than the quotient,
692 ; InstSimplify should kill it before InstCombine sees it.
694 define i32 @shrink_no2(i8 %x) {
695 ; CHECK-LABEL: @shrink_no2(
696 ; CHECK-NEXT: ret i32 0
698 %conv = sext i8 %x to i32
699 %div = sdiv i32 %conv, -129
703 define i32 @shrink_no3(i16 %x) {
704 ; CHECK-LABEL: @shrink_no3(
705 ; CHECK-NEXT: ret i32 0
707 %conv = sext i16 %x to i32
708 %div = sdiv i32 %conv, 65535
712 ; This previously crashed when trying to simplify the zext/icmp this becomes.
713 define <2 x i8> @PR34841(<2 x i8> %x) {
714 ; CHECK-LABEL: @PR34841(
715 ; CHECK-NEXT: ret <2 x i8> zeroinitializer
717 %neg = and <2 x i8> %x, <i8 2, i8 2>
718 %div = udiv <2 x i8> <i8 1, i8 1>, %neg
722 ; X / (X * Y) -> 1 / Y if the multiplication does not overflow
724 define i8 @div_factor_signed(i8 %x, i8 %y) {
725 ; CHECK-LABEL: @div_factor_signed(
726 ; CHECK-NEXT: [[TMP1:%.*]] = add i8 [[Y:%.*]], 1
727 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ult i8 [[TMP1]], 3
728 ; CHECK-NEXT: [[R:%.*]] = select i1 [[TMP2]], i8 [[Y]], i8 0
729 ; CHECK-NEXT: ret i8 [[R]]
731 %a = mul nsw i8 %x, %y
736 ; X / (Y * X) -> 1 / Y if the multiplication does not overflow
738 define <2 x i8> @div_factor_signed_vec(<2 x i8> %x, <2 x i8> %y) {
739 ; CHECK-LABEL: @div_factor_signed_vec(
740 ; CHECK-NEXT: [[TMP1:%.*]] = add <2 x i8> [[Y:%.*]], <i8 1, i8 1>
741 ; CHECK-NEXT: [[TMP2:%.*]] = icmp ult <2 x i8> [[TMP1]], <i8 3, i8 3>
742 ; CHECK-NEXT: [[R:%.*]] = select <2 x i1> [[TMP2]], <2 x i8> [[Y]], <2 x i8> zeroinitializer
743 ; CHECK-NEXT: ret <2 x i8> [[R]]
745 %a = mul nsw <2 x i8> %y, %x
746 %r = sdiv <2 x i8> %x, %a
750 ; X / (Y * X) -> 1 / Y if the multiplication does not overflow
752 define i8 @div_factor_unsigned(i8 %x, i8 %y) {
753 ; CHECK-LABEL: @div_factor_unsigned(
754 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[Y:%.*]], 1
755 ; CHECK-NEXT: [[R:%.*]] = zext i1 [[TMP1]] to i8
756 ; CHECK-NEXT: ret i8 [[R]]
758 %a = mul nuw i8 %y, %x
763 ; X / (X * Y) -> 1 / Y if the multiplication does not overflow
765 define <2 x i8> @div_factor_unsigned_vec(<2 x i8> %x, <2 x i8> %y) {
766 ; CHECK-LABEL: @div_factor_unsigned_vec(
767 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i8> [[Y:%.*]], <i8 1, i8 1>
768 ; CHECK-NEXT: [[R:%.*]] = zext <2 x i1> [[TMP1]] to <2 x i8>
769 ; CHECK-NEXT: ret <2 x i8> [[R]]
771 %a = mul nuw <2 x i8> %x, %y
772 %r = udiv <2 x i8> %x, %a
776 define i8 @udiv_common_factor(i8 %x, i8 %y, i8 %z) {
777 ; CHECK-LABEL: @udiv_common_factor(
778 ; CHECK-NEXT: [[C:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]]
779 ; CHECK-NEXT: ret i8 [[C]]
781 %a = mul nuw i8 %z, %x
782 %b = mul nuw i8 %z, %y
787 define <2 x i8> @udiv_common_factor_commute1_vec(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z) {
788 ; CHECK-LABEL: @udiv_common_factor_commute1_vec(
789 ; CHECK-NEXT: [[C:%.*]] = udiv <2 x i8> [[X:%.*]], [[Y:%.*]]
790 ; CHECK-NEXT: ret <2 x i8> [[C]]
792 %a = mul nuw <2 x i8> %x, %z
793 %b = mul nuw <2 x i8> %z, %y
794 %c = udiv <2 x i8> %a, %b
798 define i8 @udiv_common_factor_commute2(i8 %x, i8 %y, i8 %z) {
799 ; CHECK-LABEL: @udiv_common_factor_commute2(
800 ; CHECK-NEXT: [[C:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]]
801 ; CHECK-NEXT: ret i8 [[C]]
803 %a = mul nuw i8 %x, %z
804 %b = mul nuw i8 %y, %z
809 define i8 @udiv_common_factor_commute3(i8 %x, i8 %y, i8 %z) {
810 ; CHECK-LABEL: @udiv_common_factor_commute3(
811 ; CHECK-NEXT: [[C:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]]
812 ; CHECK-NEXT: ret i8 [[C]]
814 %a = mul nuw i8 %z, %x
815 %b = mul nuw i8 %y, %z
820 ; Negative test: both mul must be 'nuw'.
822 define i8 @udiv_common_factor_not_nuw(i8 %x, i8 %y, i8 %z) {
823 ; CHECK-LABEL: @udiv_common_factor_not_nuw(
824 ; CHECK-NEXT: [[A:%.*]] = mul i8 [[Z:%.*]], [[X:%.*]]
825 ; CHECK-NEXT: [[B:%.*]] = mul nuw i8 [[Z]], [[Y:%.*]]
826 ; CHECK-NEXT: [[C:%.*]] = udiv i8 [[A]], [[B]]
827 ; CHECK-NEXT: ret i8 [[C]]
830 %b = mul nuw i8 %z, %y
835 ; Negative test: both mul must be 'nuw'.
837 define <2 x i8> @udiv_common_factor_not_nuw_vec(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z) {
838 ; CHECK-LABEL: @udiv_common_factor_not_nuw_vec(
839 ; CHECK-NEXT: [[A:%.*]] = mul nuw <2 x i8> [[Z:%.*]], [[X:%.*]]
840 ; CHECK-NEXT: [[B:%.*]] = mul <2 x i8> [[Z]], [[Y:%.*]]
841 ; CHECK-NEXT: [[C:%.*]] = udiv <2 x i8> [[A]], [[B]]
842 ; CHECK-NEXT: ret <2 x i8> [[C]]
844 %a = mul nuw <2 x i8> %z, %x
845 %b = mul <2 x i8> %z, %y
846 %c = udiv <2 x i8> %a, %b
850 define i32 @test_exact_nsw_exact(i32 %x) {
851 ; CHECK-LABEL: @test_exact_nsw_exact(
852 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sdiv exact i32 [[X:%.*]], -3
853 ; CHECK-NEXT: ret i32 [[DIV_NEG]]
855 %div = sdiv exact i32 %x, 3
856 %neg = sub nsw i32 0, %div
860 define <2 x i64> @test_exact_vec(<2 x i64> %x) {
861 ; CHECK-LABEL: @test_exact_vec(
862 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sdiv exact <2 x i64> [[X:%.*]], <i64 -3, i64 -4>
863 ; CHECK-NEXT: ret <2 x i64> [[DIV_NEG]]
865 %div = sdiv exact <2 x i64> %x, <i64 3, i64 4>
866 %neg = sub nsw <2 x i64> zeroinitializer, %div
870 ; Constant is safe to negate.
872 define <2 x i8> @negate_sdiv_vec_splat(<2 x i8> %x) {
873 ; CHECK-LABEL: @negate_sdiv_vec_splat(
874 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 -42, i8 -42>
875 ; CHECK-NEXT: ret <2 x i8> [[DIV_NEG]]
877 %div = sdiv <2 x i8> %x, <i8 42, i8 42>
878 %neg = sub <2 x i8> zeroinitializer, %div
882 ; Dividing by undef is UB.
884 define <2 x i8> @negate_sdiv_vec_undef_elt(<2 x i8> %x) {
885 ; CHECK-LABEL: @negate_sdiv_vec_undef_elt(
886 ; CHECK-NEXT: ret <2 x i8> poison
888 %div = sdiv <2 x i8> %x, <i8 undef, i8 42>
889 %neg = sub <2 x i8> zeroinitializer, %div
893 ; Division by -1 may be UB (if numerator is the signed min val), but div-by-1 can be simplified.
895 define <2 x i8> @negate_sdiv_vec_splat_one(<2 x i8> %x) {
896 ; CHECK-LABEL: @negate_sdiv_vec_splat_one(
897 ; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[X:%.*]]
898 ; CHECK-NEXT: ret <2 x i8> [[NEG]]
900 %div = sdiv <2 x i8> %x, <i8 1, i8 1>
901 %neg = sub <2 x i8> zeroinitializer, %div
905 ; Can't negate signed-min constant, but can convert to a compare..
907 define <2 x i8> @negate_sdiv_vec_splat_signed_min(<2 x i8> %x) {
908 ; CHECK-LABEL: @negate_sdiv_vec_splat_signed_min(
909 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 -128, i8 -128>
910 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sext <2 x i1> [[TMP1]] to <2 x i8>
911 ; CHECK-NEXT: ret <2 x i8> [[DIV_NEG]]
913 %div = sdiv <2 x i8> %x, <i8 -128, i8 -128>
914 %neg = sub <2 x i8> zeroinitializer, %div
918 ; Division by -1 may be UB for any element of a vector.
920 define <2 x i8> @negate_sdiv_vec_one_element(<2 x i8> %x) {
921 ; CHECK-LABEL: @negate_sdiv_vec_one_element(
922 ; CHECK-NEXT: [[DIV:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 -1, i8 1>
923 ; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[DIV]]
924 ; CHECK-NEXT: ret <2 x i8> [[NEG]]
926 %div = sdiv <2 x i8> %x, <i8 -1, i8 1>
927 %neg = sub <2 x i8> zeroinitializer, %div
931 ; Can't negate signed-min constant for any element of a vector.
933 define <2 x i8> @negate_sdiv_vec_signed_min_elt(<2 x i8> %x) {
934 ; CHECK-LABEL: @negate_sdiv_vec_signed_min_elt(
935 ; CHECK-NEXT: [[DIV:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 -1, i8 -128>
936 ; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[DIV]]
937 ; CHECK-NEXT: ret <2 x i8> [[NEG]]
939 %div = sdiv <2 x i8> %x, <i8 -1, i8 -128>
940 %neg = sub <2 x i8> zeroinitializer, %div
944 ; Division by -1 may be UB and can't negate signed-min.
946 define <2 x i8> @negate_sdiv_vec_signed_min_and_one_elt(<2 x i8> %x) {
947 ; CHECK-LABEL: @negate_sdiv_vec_signed_min_and_one_elt(
948 ; CHECK-NEXT: [[DIV:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 1, i8 -128>
949 ; CHECK-NEXT: [[NEG:%.*]] = sub <2 x i8> zeroinitializer, [[DIV]]
950 ; CHECK-NEXT: ret <2 x i8> [[NEG]]
952 %div = sdiv <2 x i8> %x, <i8 1, i8 -128>
953 %neg = sub <2 x i8> zeroinitializer, %div
957 define i32 @test_exact_nonsw_exact(i32 %x) {
958 ; CHECK-LABEL: @test_exact_nonsw_exact(
959 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sdiv exact i32 [[X:%.*]], -3
960 ; CHECK-NEXT: ret i32 [[DIV_NEG]]
962 %div = sdiv exact i32 %x, 3
963 %neg = sub i32 0, %div
967 define i32 @test_exact_nsw_noexact(i32 %x) {
968 ; CHECK-LABEL: @test_exact_nsw_noexact(
969 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sdiv i32 [[X:%.*]], -3
970 ; CHECK-NEXT: ret i32 [[DIV_NEG]]
972 %div = sdiv i32 %x, 3
973 %neg = sub nsw i32 0, %div
977 define i32 @test_exact_nonsw_noexact(i32 %x) {
978 ; CHECK-LABEL: @test_exact_nonsw_noexact(
979 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sdiv i32 [[X:%.*]], -3
980 ; CHECK-NEXT: ret i32 [[DIV_NEG]]
982 %div = sdiv i32 %x, 3
983 %neg = sub i32 0, %div
987 define i32 @test_exact_div_nonconst(i32 %x, i32 %y) {
988 ; CHECK-LABEL: @test_exact_div_nonconst(
989 ; CHECK-NEXT: [[DIV:%.*]] = sdiv exact i32 [[X:%.*]], [[Y:%.*]]
990 ; CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[DIV]]
991 ; CHECK-NEXT: ret i32 [[NEG]]
993 %div = sdiv exact i32 %x, %y
994 %neg = sub nsw i32 0, %div
998 define i32 @test_exact_div_one(i32 %x) {
999 ; CHECK-LABEL: @test_exact_div_one(
1000 ; CHECK-NEXT: [[NEG:%.*]] = sub nsw i32 0, [[X:%.*]]
1001 ; CHECK-NEXT: ret i32 [[NEG]]
1003 %div = sdiv exact i32 %x, 1
1004 %neg = sub nsw i32 0, %div
1008 define i8 @test_exact_div_minSigned(i8 %x) {
1009 ; CHECK-LABEL: @test_exact_div_minSigned(
1010 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X:%.*]], -128
1011 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sext i1 [[TMP1]] to i8
1012 ; CHECK-NEXT: ret i8 [[DIV_NEG]]
1014 %div = sdiv exact i8 %x, -128
1015 %neg = sub nsw i8 0, %div
1019 ; X / INT_MIN --> X == INT_MIN
1021 define i8 @sdiv_by_int_min(i8 %x) {
1022 ; CHECK-LABEL: @sdiv_by_int_min(
1023 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[X:%.*]], -128
1024 ; CHECK-NEXT: [[D:%.*]] = zext i1 [[TMP1]] to i8
1025 ; CHECK-NEXT: ret i8 [[D]]
1027 %d = sdiv i8 %x, -128
1031 define <2 x i8> @sdiv_by_int_min_vec_splat(<2 x i8> %x) {
1032 ; CHECK-LABEL: @sdiv_by_int_min_vec_splat(
1033 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 -128, i8 -128>
1034 ; CHECK-NEXT: [[D:%.*]] = zext <2 x i1> [[TMP1]] to <2 x i8>
1035 ; CHECK-NEXT: ret <2 x i8> [[D]]
1037 %d = sdiv <2 x i8> %x, <i8 -128, i8 -128>
1041 define <2 x i8> @sdiv_by_int_min_vec_splat_undef(<2 x i8> %x) {
1042 ; CHECK-LABEL: @sdiv_by_int_min_vec_splat_undef(
1043 ; CHECK-NEXT: ret <2 x i8> poison
1045 %d = sdiv <2 x i8> %x, <i8 -128, i8 undef>
1049 define <2 x i8> @sdiv_by_negconst_v2i8(<2 x i8> %x) {
1050 ; CHECK-LABEL: @sdiv_by_negconst_v2i8(
1051 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sdiv <2 x i8> [[X:%.*]], <i8 108, i8 108>
1052 ; CHECK-NEXT: ret <2 x i8> [[DIV_NEG]]
1054 %div = sdiv <2 x i8> %x, <i8 -108, i8 -108>
1055 %sub = sub <2 x i8> zeroinitializer, %div
1059 define <vscale x 2 x i8> @sdiv_by_negconst_nxv2i8(<vscale x 2 x i8> %x) {
1060 ; CHECK-LABEL: @sdiv_by_negconst_nxv2i8(
1061 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sdiv <vscale x 2 x i8> [[X:%.*]], shufflevector (<vscale x 2 x i8> insertelement (<vscale x 2 x i8> poison, i8 108, i32 0), <vscale x 2 x i8> poison, <vscale x 2 x i32> zeroinitializer)
1062 ; CHECK-NEXT: ret <vscale x 2 x i8> [[DIV_NEG]]
1064 %div = sdiv <vscale x 2 x i8> %x, shufflevector (<vscale x 2 x i8> insertelement (<vscale x 2 x i8> undef, i8 -108, i32 0), <vscale x 2 x i8> undef, <vscale x 2 x i32> zeroinitializer)
1065 %sub = sub <vscale x 2 x i8> zeroinitializer, %div
1066 ret <vscale x 2 x i8> %sub
1069 define <2 x i8> @sdiv_by_minSigned_v2i8(<2 x i8> %x) {
1070 ; CHECK-LABEL: @sdiv_by_minSigned_v2i8(
1071 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <2 x i8> [[X:%.*]], <i8 -128, i8 -128>
1072 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sext <2 x i1> [[TMP1]] to <2 x i8>
1073 ; CHECK-NEXT: ret <2 x i8> [[DIV_NEG]]
1075 %div = sdiv <2 x i8> %x, <i8 -128, i8 -128>
1076 %sub = sub <2 x i8> zeroinitializer, %div
1080 define <vscale x 2 x i8> @sdiv_by_minSigned_nxv2i8(<vscale x 2 x i8> %x) {
1081 ; CHECK-LABEL: @sdiv_by_minSigned_nxv2i8(
1082 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq <vscale x 2 x i8> [[X:%.*]], shufflevector (<vscale x 2 x i8> insertelement (<vscale x 2 x i8> undef, i8 -128, i32 0), <vscale x 2 x i8> undef, <vscale x 2 x i32> zeroinitializer)
1083 ; CHECK-NEXT: [[DIV_NEG:%.*]] = sext <vscale x 2 x i1> [[TMP1]] to <vscale x 2 x i8>
1084 ; CHECK-NEXT: ret <vscale x 2 x i8> [[DIV_NEG]]
1086 %div = sdiv <vscale x 2 x i8> %x, shufflevector (<vscale x 2 x i8> insertelement (<vscale x 2 x i8> undef, i8 -128, i32 0), <vscale x 2 x i8> undef, <vscale x 2 x i32> zeroinitializer)
1087 %sub = sub <vscale x 2 x i8> zeroinitializer, %div
1088 ret <vscale x 2 x i8> %sub