1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -passes=loop-unroll-full -S %s | FileCheck %s
4 ; Validate that loop unroll full doesn't try to fully unroll values whose trip counts are too large.
6 define void @foo(i64 %end) {
7 ; CHECK-LABEL: define void @foo(
8 ; CHECK-SAME: i64 [[END:%.*]]) {
10 ; CHECK-NEXT: br label [[LOOPHEADER:%.*]]
12 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEW:%.*]], [[BACKEDGE:%.*]] ]
13 ; CHECK-NEXT: [[EXIT:%.*]] = icmp eq i64 [[IV]], [[END]]
14 ; CHECK-NEXT: br i1 [[EXIT]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[CONT23:%.*]]
15 ; CHECK: for.cond.cleanup.loopexit:
16 ; CHECK-NEXT: ret void
18 ; CHECK-NEXT: [[EXITCOND241:%.*]] = icmp eq i64 [[IV]], 2147483647
19 ; CHECK-NEXT: br i1 [[EXITCOND241]], label [[HANDLER_ADD_OVERFLOW:%.*]], label [[BACKEDGE]]
20 ; CHECK: handler.add_overflow:
21 ; CHECK-NEXT: unreachable
23 ; CHECK-NEXT: [[IV_NEW]] = add i64 [[IV]], 1
24 ; CHECK-NEXT: br label [[LOOPHEADER]], !llvm.loop [[LOOP0:![0-9]+]]
30 %iv = phi i64 [ 0, %entry ], [ %iv_new, %backedge ]
31 %exit = icmp eq i64 %iv, %end
32 br i1 %exit, label %for.cond.cleanup.loopexit, label %cont23
34 for.cond.cleanup.loopexit:
38 %exitcond241 = icmp eq i64 %iv, 2147483647
39 br i1 %exitcond241, label %handler.add_overflow, label %backedge
44 backedge: ; preds = %cont23
45 %iv_new = add i64 %iv, 1
46 br label %loopheader, !llvm.loop !0
49 !0 = distinct !{!0, !1}
50 !1 = !{!"llvm.loop.unroll.full"}
52 ; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]]}
53 ; CHECK: [[META1]] = !{!"llvm.loop.unroll.full"}