1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='default<Os>' -S %s | FileCheck %s
4 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
9 define void @test_remove_check_with_incrementing_integer_induction(i16 %start, i8 %len.n, i16 %a) {
10 ; CHECK-LABEL: @test_remove_check_with_incrementing_integer_induction(
12 ; CHECK-NEXT: [[LEN:%.*]] = zext i8 [[LEN_N:%.*]] to i16
13 ; CHECK-NEXT: [[LEN_NEG_NOT:%.*]] = icmp ult i16 [[LEN]], [[A:%.*]]
14 ; CHECK-NEXT: [[C1:%.*]] = icmp ne i8 [[LEN_N]], 0
15 ; CHECK-NEXT: [[OR_COND3:%.*]] = and i1 [[LEN_NEG_NOT]], [[C1]]
16 ; CHECK-NEXT: br i1 [[OR_COND3]], label [[LOOP_LATCH_PREHEADER:%.*]], label [[EXIT:%.*]]
17 ; CHECK: loop.latch.preheader:
18 ; CHECK-NEXT: [[TMP0:%.*]] = add i16 [[A]], -1
19 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw i16 [[LEN]], -1
20 ; CHECK-NEXT: [[UMIN:%.*]] = tail call i16 @llvm.umin.i16(i16 [[TMP0]], i16 [[TMP1]])
21 ; CHECK-NEXT: br label [[LOOP_LATCH:%.*]]
23 ; CHECK-NEXT: [[IV2:%.*]] = phi i16 [ [[IV_NEXT:%.*]], [[LOOP_LATCH]] ], [ 0, [[LOOP_LATCH_PREHEADER]] ]
24 ; CHECK-NEXT: tail call void @use(i16 [[IV2]])
25 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i16 [[IV2]], 1
26 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i16 [[IV2]], [[UMIN]]
27 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[EXIT]], label [[LOOP_LATCH]]
29 ; CHECK-NEXT: ret void
32 %len = zext i8 %len.n to i16
33 %upper = add nuw nsw i16 %start, %len
34 %len.neg = icmp uge i16 %len, %a
35 br i1 %len.neg, label %exit, label %loop.ph
41 %iv = phi i16 [ 0, %loop.ph ], [ %iv.next, %loop.latch ]
42 %c = icmp eq i16 %iv, %len
43 br i1 %c, label %exit, label %for.body
46 %t.1 = icmp uge i16 %iv, 0
47 %t.2 = icmp ult i16 %iv, %a
48 %and = and i1 %t.1, %t.2
49 br i1 %and, label %loop.latch, label %exit
52 call void @use(i16 %iv)
53 %iv.next = add nuw nsw i16 %iv, 1