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