| Diego Novillo | cd64780 | 2014-04-29 20:06:10 +0000 | [diff] [blame] | 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 |
| David Green | 64f53b4 | 2017-10-31 10:47:46 +0000 | [diff] [blame] | 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 |
| Diego Novillo | cd64780 | 2014-04-29 20:06:10 +0000 | [diff] [blame] | 4 | |
| 5 | ; COMPLETE-UNROLL: remark: {{.*}}: completely unrolled loop with 16 iterations |
| 6 | ; PARTIAL-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4 |
| David Green | 64f53b4 | 2017-10-31 10:47:46 +0000 | [diff] [blame] | 7 | ; RUNTIME-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4 |
| Diego Novillo | cd64780 | 2014-04-29 20:06:10 +0000 | [diff] [blame] | 8 | |
| 9 | define i32 @sum() { |
| 10 | entry: |
| 11 | br label %for.body |
| 12 | |
| 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 |
| 22 | |
| 23 | for.end: ; preds = %for.body |
| 24 | ret i32 %add1 |
| 25 | } |
| 26 | |
| David Green | 64f53b4 | 2017-10-31 10:47:46 +0000 | [diff] [blame] | 27 | ; RUNTIME-UNROLL-NOT: remark: {{.*}}: completely unrolled loop with 3 iterations |
| 28 | ; RUNTIME-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4 |
| 29 | |
| 30 | define i32 @runtime(i32 %n) { |
| 31 | entry: |
| 32 | br label %for.body |
| 33 | |
| 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 |
| 43 | |
| 44 | for.end: ; preds = %for.body |
| 45 | ret i32 %add1 |
| 46 | } |
| 47 | |
| 48 | declare i32 @baz(i32) |