Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -S -loop-unroll -pass-remarks=loop-unroll -pass-remarks-with-hotness -unroll-count=16 2>&1 | FileCheck -check-prefix=COMPLETE-UNROLL %s |
| 2 | ; RUN: opt < %s -S -loop-unroll -pass-remarks=loop-unroll -pass-remarks-with-hotness -unroll-count=4 2>&1 | FileCheck -check-prefix=PARTIAL-UNROLL %s |
| 3 | |
| 4 | ; COMPLETE-UNROLL: remark: {{.*}}: completely unrolled loop with 16 iterations (hotness: 300) |
| 5 | ; PARTIAL-UNROLL: remark: {{.*}}: unrolled loop by a factor of 4 {{.*}} (hotness: 300) |
| 6 | |
| 7 | define i32 @sum() !prof !0 { |
| 8 | entry: |
| 9 | br label %for.body |
| 10 | |
| 11 | for.body: ; preds = %for.body, %entry |
| 12 | %s.06 = phi i32 [ 0, %entry ], [ %add1, %for.body ] |
| 13 | %i.05 = phi i32 [ 0, %entry ], [ %inc, %for.body ] |
| 14 | %add = add nsw i32 %i.05, 4 |
| 15 | %call = tail call i32 @baz(i32 %add) #2 |
| 16 | %add1 = add nsw i32 %call, %s.06 |
| 17 | %inc = add nsw i32 %i.05, 1 |
| 18 | %exitcond = icmp eq i32 %inc, 16 |
| 19 | br i1 %exitcond, label %for.end, label %for.body, !prof !1 |
| 20 | |
| 21 | for.end: ; preds = %for.body |
| 22 | ret i32 %add1 |
| 23 | } |
| 24 | |
| 25 | declare i32 @baz(i32) |
| 26 | |
| 27 | !0 = !{!"function_entry_count", i64 3} |
| 28 | !1 = !{!"branch_weights", i32 1, i32 99} |