1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instsimplify -S < %s | FileCheck %s
4 define i1 @test_add_nsw(i8 %n, i8 %r) {
5 ; CHECK-LABEL: @test_add_nsw(
7 ; CHECK-NEXT: br label [[LOOP:%.*]]
9 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
10 ; CHECK-NEXT: [[NEXT]] = add nsw i8 [[A]], 1
11 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
12 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
14 ; CHECK-NEXT: ret i1 false
19 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
20 %next = add nsw i8 %A, 1
21 %cmp1 = icmp eq i8 %A, %n
22 br i1 %cmp1, label %exit, label %loop
25 %cmp = icmp eq i8 %add, 0
29 define i1 @test_add_may_wrap(i8 %n, i8 %r) {
30 ; CHECK-LABEL: @test_add_may_wrap(
32 ; CHECK-NEXT: br label [[LOOP:%.*]]
34 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
35 ; CHECK-NEXT: [[NEXT]] = add i8 [[A]], 1
36 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
37 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
39 ; CHECK-NEXT: [[ADD:%.*]] = or i8 [[A]], [[R:%.*]]
40 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[ADD]], 0
41 ; CHECK-NEXT: ret i1 [[CMP]]
46 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
48 %cmp1 = icmp eq i8 %A, %n
49 br i1 %cmp1, label %exit, label %loop
52 %cmp = icmp eq i8 %add, 0
56 define i1 @test_add_nuw(i8 %n, i8 %r) {
57 ; CHECK-LABEL: @test_add_nuw(
59 ; CHECK-NEXT: br label [[LOOP:%.*]]
61 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
62 ; CHECK-NEXT: [[NEXT]] = add nuw i8 [[A]], 1
63 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
64 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
66 ; CHECK-NEXT: ret i1 false
71 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
72 %next = add nuw i8 %A, 1
73 %cmp1 = icmp eq i8 %A, %n
74 br i1 %cmp1, label %exit, label %loop
77 %cmp = icmp eq i8 %add, 0
81 define i1 @test_add_nuw_unknown_step(i8 %n, i8 %r, i8 %s) {
82 ; CHECK-LABEL: @test_add_nuw_unknown_step(
84 ; CHECK-NEXT: br label [[LOOP:%.*]]
86 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
87 ; CHECK-NEXT: [[NEXT]] = add nuw i8 [[A]], [[S:%.*]]
88 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
89 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
91 ; CHECK-NEXT: ret i1 false
96 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
97 %next = add nuw i8 %A, %s
98 %cmp1 = icmp eq i8 %A, %n
99 br i1 %cmp1, label %exit, label %loop
102 %cmp = icmp eq i8 %add, 0
106 define i1 @test_add_zero_start(i8 %n, i8 %r) {
107 ; CHECK-LABEL: @test_add_zero_start(
109 ; CHECK-NEXT: br label [[LOOP:%.*]]
111 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 0, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
112 ; CHECK-NEXT: [[NEXT]] = add nuw i8 [[A]], 1
113 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
114 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
116 ; CHECK-NEXT: [[ADD:%.*]] = or i8 [[A]], [[R:%.*]]
117 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[ADD]], 0
118 ; CHECK-NEXT: ret i1 [[CMP]]
123 %A = phi i8 [ 0, %entry ], [ %next, %loop ]
124 %next = add nuw i8 %A, 1
125 %cmp1 = icmp eq i8 %A, %n
126 br i1 %cmp1, label %exit, label %loop
129 %cmp = icmp eq i8 %add, 0
133 define i1 @test_add_nuw_negative_start(i8 %n, i8 %r) {
134 ; CHECK-LABEL: @test_add_nuw_negative_start(
136 ; CHECK-NEXT: br label [[LOOP:%.*]]
138 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ -2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
139 ; CHECK-NEXT: [[NEXT]] = add nuw i8 [[A]], 1
140 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
141 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
143 ; CHECK-NEXT: ret i1 false
148 %A = phi i8 [ -2, %entry ], [ %next, %loop ]
149 %next = add nuw i8 %A, 1
150 %cmp1 = icmp eq i8 %A, %n
151 br i1 %cmp1, label %exit, label %loop
154 %cmp = icmp eq i8 %add, 0
158 define i1 @test_add_nsw_negative_start(i8 %n, i8 %r) {
159 ; CHECK-LABEL: @test_add_nsw_negative_start(
161 ; CHECK-NEXT: br label [[LOOP:%.*]]
163 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ -2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
164 ; CHECK-NEXT: [[NEXT]] = add nsw i8 [[A]], 1
165 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
166 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
168 ; CHECK-NEXT: [[ADD:%.*]] = or i8 [[A]], [[R:%.*]]
169 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[ADD]], 0
170 ; CHECK-NEXT: ret i1 [[CMP]]
175 %A = phi i8 [ -2, %entry ], [ %next, %loop ]
176 %next = add nsw i8 %A, 1
177 %cmp1 = icmp eq i8 %A, %n
178 br i1 %cmp1, label %exit, label %loop
181 %cmp = icmp eq i8 %add, 0
185 define i1 @test_add_nsw_negative_start_and_step(i8 %n, i8 %r) {
186 ; CHECK-LABEL: @test_add_nsw_negative_start_and_step(
188 ; CHECK-NEXT: br label [[LOOP:%.*]]
190 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ -1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
191 ; CHECK-NEXT: [[NEXT]] = add nsw i8 [[A]], -1
192 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
193 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
195 ; CHECK-NEXT: ret i1 false
200 %A = phi i8 [ -1, %entry ], [ %next, %loop ]
201 %next = add nsw i8 %A, -1
202 %cmp1 = icmp eq i8 %A, %n
203 br i1 %cmp1, label %exit, label %loop
206 %cmp = icmp eq i8 %add, 0
210 define i1 @test_mul_nsw(i8 %n) {
211 ; CHECK-LABEL: @test_mul_nsw(
213 ; CHECK-NEXT: br label [[LOOP:%.*]]
215 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
216 ; CHECK-NEXT: [[NEXT]] = mul nsw i8 [[A]], 2
217 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
218 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
220 ; CHECK-NEXT: ret i1 false
225 %A = phi i8 [ 2, %entry ], [ %next, %loop ]
226 %next = mul nsw i8 %A, 2
227 %cmp1 = icmp eq i8 %A, %n
228 br i1 %cmp1, label %exit, label %loop
230 %cmp = icmp eq i8 %A, 0
234 define i1 @test_mul_may_wrap(i8 %n) {
235 ; CHECK-LABEL: @test_mul_may_wrap(
237 ; CHECK-NEXT: br label [[LOOP:%.*]]
239 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
240 ; CHECK-NEXT: [[NEXT]] = mul i8 [[A]], 2
241 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
242 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
244 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 0
245 ; CHECK-NEXT: ret i1 [[CMP]]
250 %A = phi i8 [ 2, %entry ], [ %next, %loop ]
252 %cmp1 = icmp eq i8 %A, %n
253 br i1 %cmp1, label %exit, label %loop
255 %cmp = icmp eq i8 %A, 0
259 define i1 @test_mul_nuw(i8 %n) {
260 ; CHECK-LABEL: @test_mul_nuw(
262 ; CHECK-NEXT: br label [[LOOP:%.*]]
264 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
265 ; CHECK-NEXT: [[NEXT]] = mul nuw i8 [[A]], 2
266 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
267 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
269 ; CHECK-NEXT: ret i1 false
274 %A = phi i8 [ 2, %entry ], [ %next, %loop ]
275 %next = mul nuw i8 %A, 2
276 %cmp1 = icmp eq i8 %A, %n
277 br i1 %cmp1, label %exit, label %loop
279 %cmp = icmp eq i8 %A, 0
283 define i1 @test_mul_zero_start(i8 %n) {
284 ; CHECK-LABEL: @test_mul_zero_start(
286 ; CHECK-NEXT: br label [[LOOP:%.*]]
288 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 0, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
289 ; CHECK-NEXT: [[NEXT]] = mul nuw i8 [[A]], 2
290 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
291 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
293 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 0
294 ; CHECK-NEXT: ret i1 [[CMP]]
299 %A = phi i8 [ 0, %entry ], [ %next, %loop ]
300 %next = mul nuw i8 %A, 2
301 %cmp1 = icmp eq i8 %A, %n
302 br i1 %cmp1, label %exit, label %loop
304 %cmp = icmp eq i8 %A, 0
308 define i1 @test_mul_nuw_negative_step(i8 %n) {
309 ; CHECK-LABEL: @test_mul_nuw_negative_step(
311 ; CHECK-NEXT: br label [[LOOP:%.*]]
313 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
314 ; CHECK-NEXT: [[NEXT]] = mul nuw i8 [[A]], -2
315 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
316 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
318 ; CHECK-NEXT: ret i1 false
323 %A = phi i8 [ 2, %entry ], [ %next, %loop ]
324 %next = mul nuw i8 %A, -2
325 %cmp1 = icmp eq i8 %A, %n
326 br i1 %cmp1, label %exit, label %loop
328 %cmp = icmp eq i8 %A, 0
332 define i1 @test_mul_nsw_negative_step(i8 %n) {
333 ; CHECK-LABEL: @test_mul_nsw_negative_step(
335 ; CHECK-NEXT: br label [[LOOP:%.*]]
337 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
338 ; CHECK-NEXT: [[NEXT]] = mul nsw i8 [[A]], -2
339 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
340 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
342 ; CHECK-NEXT: ret i1 false
347 %A = phi i8 [ 2, %entry ], [ %next, %loop ]
348 %next = mul nsw i8 %A, -2
349 %cmp1 = icmp eq i8 %A, %n
350 br i1 %cmp1, label %exit, label %loop
352 %cmp = icmp eq i8 %A, 0
356 define i1 @test_mul_nuw_negative_start(i8 %n) {
357 ; CHECK-LABEL: @test_mul_nuw_negative_start(
359 ; CHECK-NEXT: br label [[LOOP:%.*]]
361 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ -2, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
362 ; CHECK-NEXT: [[NEXT]] = mul nuw i8 [[A]], 2
363 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
364 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
366 ; CHECK-NEXT: ret i1 false
371 %A = phi i8 [ -2, %entry ], [ %next, %loop ]
372 %next = mul nuw i8 %A, 2
373 %cmp1 = icmp eq i8 %A, %n
374 br i1 %cmp1, label %exit, label %loop
376 %cmp = icmp eq i8 %A, 0
380 define i1 @test_shl_nuw(i8 %n) {
381 ; CHECK-LABEL: @test_shl_nuw(
383 ; CHECK-NEXT: br label [[LOOP:%.*]]
385 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
386 ; CHECK-NEXT: [[NEXT]] = shl nuw i8 [[A]], 1
387 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
388 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
390 ; CHECK-NEXT: ret i1 false
395 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
396 %next = shl nuw i8 %A, 1
397 %cmp1 = icmp eq i8 %A, %n
398 br i1 %cmp1, label %exit, label %loop
400 %cmp = icmp eq i8 %A, 0
404 define i1 @test_shl_nsw(i8 %n) {
405 ; CHECK-LABEL: @test_shl_nsw(
407 ; CHECK-NEXT: br label [[LOOP:%.*]]
409 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
410 ; CHECK-NEXT: [[NEXT]] = shl nsw i8 [[A]], 1
411 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
412 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
414 ; CHECK-NEXT: ret i1 false
419 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
420 %next = shl nsw i8 %A, 1
421 %cmp1 = icmp eq i8 %A, %n
422 br i1 %cmp1, label %exit, label %loop
424 %cmp = icmp eq i8 %A, 0
428 define i1 @test_shl_dynamic_shift(i8 %n, i8 %shift) {
429 ; CHECK-LABEL: @test_shl_dynamic_shift(
431 ; CHECK-NEXT: br label [[LOOP:%.*]]
433 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
434 ; CHECK-NEXT: [[NEXT]] = shl nuw i8 [[A]], [[SHIFT:%.*]]
435 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
436 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
438 ; CHECK-NEXT: ret i1 false
443 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
444 %next = shl nuw i8 %A, %shift
445 %cmp1 = icmp eq i8 %A, %n
446 br i1 %cmp1, label %exit, label %loop
448 %cmp = icmp eq i8 %A, 0
452 define i1 @test_shl_may_wrap(i8 %n) {
453 ; CHECK-LABEL: @test_shl_may_wrap(
455 ; CHECK-NEXT: br label [[LOOP:%.*]]
457 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
458 ; CHECK-NEXT: [[NEXT]] = shl i8 [[A]], 1
459 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
460 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
462 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 0
463 ; CHECK-NEXT: ret i1 [[CMP]]
468 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
470 %cmp1 = icmp eq i8 %A, %n
471 br i1 %cmp1, label %exit, label %loop
473 %cmp = icmp eq i8 %A, 0
477 define i1 @test_shl_zero_start(i8 %n) {
478 ; CHECK-LABEL: @test_shl_zero_start(
480 ; CHECK-NEXT: br label [[LOOP:%.*]]
482 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 0, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
483 ; CHECK-NEXT: [[NEXT]] = shl nuw i8 [[A]], 1
484 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
485 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
487 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 0
488 ; CHECK-NEXT: ret i1 [[CMP]]
493 %A = phi i8 [ 0, %entry ], [ %next, %loop ]
494 %next = shl nuw i8 %A, 1
495 %cmp1 = icmp eq i8 %A, %n
496 br i1 %cmp1, label %exit, label %loop
498 %cmp = icmp eq i8 %A, 0
503 define i1 @test_lshr_exact(i8 %n) {
504 ; CHECK-LABEL: @test_lshr_exact(
506 ; CHECK-NEXT: br label [[LOOP:%.*]]
508 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 64, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
509 ; CHECK-NEXT: [[NEXT]] = lshr exact i8 [[A]], 1
510 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
511 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
513 ; CHECK-NEXT: ret i1 false
518 %A = phi i8 [ 64, %entry ], [ %next, %loop ]
519 %next = lshr exact i8 %A, 1
520 %cmp1 = icmp eq i8 %A, %n
521 br i1 %cmp1, label %exit, label %loop
523 %cmp = icmp eq i8 %A, 0
527 define i1 @test_lshr_may_wrap(i8 %n) {
528 ; CHECK-LABEL: @test_lshr_may_wrap(
530 ; CHECK-NEXT: br label [[LOOP:%.*]]
532 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
533 ; CHECK-NEXT: [[NEXT]] = lshr i8 [[A]], 1
534 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
535 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
537 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 0
538 ; CHECK-NEXT: ret i1 [[CMP]]
543 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
544 %next = lshr i8 %A, 1
545 %cmp1 = icmp eq i8 %A, %n
546 br i1 %cmp1, label %exit, label %loop
548 %cmp = icmp eq i8 %A, 0
552 define i1 @test_lshr_zero_start(i8 %n) {
553 ; CHECK-LABEL: @test_lshr_zero_start(
555 ; CHECK-NEXT: br label [[LOOP:%.*]]
557 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 0, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
558 ; CHECK-NEXT: [[NEXT]] = lshr exact i8 [[A]], 1
559 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
560 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
562 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 0
563 ; CHECK-NEXT: ret i1 [[CMP]]
568 %A = phi i8 [ 0, %entry ], [ %next, %loop ]
569 %next = lshr exact i8 %A, 1
570 %cmp1 = icmp eq i8 %A, %n
571 br i1 %cmp1, label %exit, label %loop
573 %cmp = icmp eq i8 %A, 0
577 define i1 @test_ashr_exact(i8 %n) {
578 ; CHECK-LABEL: @test_ashr_exact(
580 ; CHECK-NEXT: br label [[LOOP:%.*]]
582 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 64, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
583 ; CHECK-NEXT: [[NEXT]] = ashr exact i8 [[A]], 1
584 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
585 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
587 ; CHECK-NEXT: ret i1 false
592 %A = phi i8 [ 64, %entry ], [ %next, %loop ]
593 %next = ashr exact i8 %A, 1
594 %cmp1 = icmp eq i8 %A, %n
595 br i1 %cmp1, label %exit, label %loop
597 %cmp = icmp eq i8 %A, 0
601 define i1 @test_ashr_may_wrap(i8 %n) {
602 ; CHECK-LABEL: @test_ashr_may_wrap(
604 ; CHECK-NEXT: br label [[LOOP:%.*]]
606 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 1, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
607 ; CHECK-NEXT: [[NEXT]] = ashr i8 [[A]], 1
608 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
609 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
611 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 0
612 ; CHECK-NEXT: ret i1 [[CMP]]
617 %A = phi i8 [ 1, %entry ], [ %next, %loop ]
618 %next = ashr i8 %A, 1
619 %cmp1 = icmp eq i8 %A, %n
620 br i1 %cmp1, label %exit, label %loop
622 %cmp = icmp eq i8 %A, 0
626 define i1 @test_ashr_zero_start(i8 %n) {
627 ; CHECK-LABEL: @test_ashr_zero_start(
629 ; CHECK-NEXT: br label [[LOOP:%.*]]
631 ; CHECK-NEXT: [[A:%.*]] = phi i8 [ 0, [[ENTRY:%.*]] ], [ [[NEXT:%.*]], [[LOOP]] ]
632 ; CHECK-NEXT: [[NEXT]] = ashr exact i8 [[A]], 1
633 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A]], [[N:%.*]]
634 ; CHECK-NEXT: br i1 [[CMP1]], label [[EXIT:%.*]], label [[LOOP]]
636 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[A]], 0
637 ; CHECK-NEXT: ret i1 [[CMP]]
642 %A = phi i8 [ 0, %entry ], [ %next, %loop ]
643 %next = ashr exact i8 %A, 1
644 %cmp1 = icmp eq i8 %A, %n
645 br i1 %cmp1, label %exit, label %loop
647 %cmp = icmp eq i8 %A, 0