1 ; RUN: opt < %s -S -loop-unroll -pass-remarks=loop-unroll -unroll-count=16 2>&1 | FileCheck -check-prefix=COMPLETE-UNROLL %s
2 ; RUN: opt < %s -S -loop-unroll -pass-remarks=loop-unroll -unroll-count=4 2>&1 | FileCheck -check-prefix=PARTIAL-UNROLL %s
3 ; RUN: opt < %s -S -loop-unroll -pass-remarks=loop-unroll -unroll-count=4 -unroll-runtime=true -unroll-remainder 2>&1 | FileCheck %s --check-prefix=RUNTIME-UNROLL
5 ; COMPLETE-UNROLL: remark: {{.*}}: completely unrolled loop with 16 iterations
6 ; PARTIAL-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4
7 ; RUNTIME-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4
13 for.body: ; preds = %for.body, %entry
14 %s.06 = phi i32 [ 0, %entry ], [ %add1, %for.body ]
15 %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
16 %add = add nsw i32 %i.05, 4
17 %call = tail call i32 @baz(i32 %add) #2
18 %add1 = add nsw i32 %call, %s.06
19 %inc = add nsw i32 %i.05, 1
20 %exitcond = icmp eq i32 %inc, 16
21 br i1 %exitcond, label %for.end, label %for.body
23 for.end: ; preds = %for.body
27 ; RUNTIME-UNROLL-NOT: remark: {{.*}}: completely unrolled loop with 3 iterations
28 ; RUNTIME-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4
30 define i32 @runtime(i32 %n) {
34 for.body: ; preds = %for.body, %entry
35 %s.06 = phi i32 [ 0, %entry ], [ %add1, %for.body ]
36 %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
37 %add = add nsw i32 %i.05, 4
38 %call = tail call i32 @baz(i32 %add) #2
39 %add1 = add nsw i32 %call, %s.06
40 %inc = add nsw i32 %i.05, 1
41 %exitcond = icmp eq i32 %inc, %n
42 br i1 %exitcond, label %for.end, label %for.body
44 for.end: ; preds = %for.body