blob: cb273f962f0d19434b90ff6cd40090a43106344c [file] [log] [blame]
Diego Novillocd647802014-04-29 20:06:10 +00001; 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
David Green64f53b42017-10-31 10:47:46 +00003; 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
Diego Novillocd647802014-04-29 20:06:10 +00004
5; COMPLETE-UNROLL: remark: {{.*}}: completely unrolled loop with 16 iterations
6; PARTIAL-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4
David Green64f53b42017-10-31 10:47:46 +00007; RUNTIME-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4
Diego Novillocd647802014-04-29 20:06:10 +00008
9define i32 @sum() {
10entry:
11 br label %for.body
12
13for.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
22
23for.end: ; preds = %for.body
24 ret i32 %add1
25}
26
David Green64f53b42017-10-31 10:47:46 +000027; RUNTIME-UNROLL-NOT: remark: {{.*}}: completely unrolled loop with 3 iterations
28; RUNTIME-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4
29
30define i32 @runtime(i32 %n) {
31entry:
32 br label %for.body
33
34for.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
43
44for.end: ; preds = %for.body
45 ret i32 %add1
46}
47
48declare i32 @baz(i32)