1; RUN: opt -S -loop-unroll < %s | FileCheck %s
2; RUN: opt < %s -passes='require<opt-remark-emit>,loop(loop-unroll-full)' -S | FileCheck %s
3
4; LLVM should not try to fully unroll this loop.
5
6declare void @f()
7declare void @g()
8declare void @h()
9
10define void @trivial_loop() {
11; CHECK-LABEL: @trivial_loop(
12 entry:
13  br label %loop
14
15 loop:
16  %idx = phi i32 [ 0, %entry ], [ %idx.inc, %loop ]
17  %idx.inc = add i32 %idx, 1
18  call void @f()
19  call void @g()
20  call void @h()
21  call void @f()
22  call void @g()
23  call void @h()
24  call void @f()
25  call void @g()
26  call void @h()
27  call void @f()
28  call void @g()
29  call void @h()
30  call void @f()
31  call void @g()
32  call void @h()
33  %be = icmp slt i32 %idx, 268435456
34  br i1 %be, label %loop, label %exit
35
36; CHECK: loop:
37; CHECK-NEXT:  %idx = phi i32 [ 0, %entry ], [ %idx.inc, %loop ]
38; CHECK-NEXT:  %idx.inc = add i32 %idx, 1
39; CHECK-NEXT:  call void @f()
40; CHECK-NEXT:  call void @g()
41; CHECK-NEXT:  call void @h()
42; CHECK-NEXT:  call void @f()
43; CHECK-NEXT:  call void @g()
44; CHECK-NEXT:  call void @h()
45; CHECK-NEXT:  call void @f()
46; CHECK-NEXT:  call void @g()
47; CHECK-NEXT:  call void @h()
48; CHECK-NEXT:  call void @f()
49; CHECK-NEXT:  call void @g()
50; CHECK-NEXT:  call void @h()
51; CHECK-NEXT:  call void @f()
52; CHECK-NEXT:  call void @g()
53; CHECK-NEXT:  call void @h()
54; CHECK-NEXT:  %be = icmp slt i32 %idx, 268435456
55; CHECK-NEXT:  br i1 %be, label %loop, label %exit
56
57 exit:
58  ret void
59}
60