1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=loop-unroll -mtriple aarch64 | FileCheck %s
4 ; Below loop's trip count is not constant and it blocks to unroll the loop.
5 ; After setting up `UP.UpperBound = true` in `getUnrollingPreferences`,
6 ; the loop should be unrolled.
8 define void @test(i1 %cond) {
11 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
13 ; CHECK-NEXT: switch i32 0, label [[SW_DEFAULT:%.*]] [
14 ; CHECK-NEXT: i32 2, label [[LATCH:%.*]]
17 ; CHECK-NEXT: tail call void @foo()
18 ; CHECK-NEXT: br label [[LATCH]]
20 ; CHECK-NEXT: br i1 false, label [[FOR_END:%.*]], label [[FOR_BODY_1:%.*]]
22 ; CHECK-NEXT: switch i32 1, label [[SW_DEFAULT_1:%.*]] [
23 ; CHECK-NEXT: i32 2, label [[LATCH_1:%.*]]
25 ; CHECK: sw.default.1:
26 ; CHECK-NEXT: tail call void @foo()
27 ; CHECK-NEXT: br label [[LATCH_1]]
29 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[FOR_END]], label [[FOR_BODY_2:%.*]]
31 ; CHECK-NEXT: switch i32 2, label [[SW_DEFAULT_2:%.*]] [
32 ; CHECK-NEXT: i32 2, label [[LATCH_2:%.*]]
34 ; CHECK: sw.default.2:
35 ; CHECK-NEXT: tail call void @foo()
36 ; CHECK-NEXT: br label [[LATCH_2]]
38 ; CHECK-NEXT: br label [[FOR_END]]
40 ; CHECK-NEXT: ret void
43 %0 = select i1 %cond, i32 2, i32 3
47 %i.017 = phi i32 [ 0, %entry ], [ %inc, %latch ]
48 switch i32 %i.017, label %sw.default [
57 %inc = add nuw nsw i32 %i.017, 1
58 %exitcond.not = icmp eq i32 %inc, %0
59 br i1 %exitcond.not, label %for.end, label %for.body