David Zarzycki | 12400b9 | 2019-07-15 14:12:35 +0000 | [diff] [blame] | 1 | ; REQUIRES: asserts |
Serguei Katkov | 3ed93b4 | 2019-07-15 08:26:45 +0000 | [diff] [blame] | 2 | ; RUN: opt < %s -S -debug-only=loop-unroll -loop-unroll -unroll-runtime -unroll-peel-multi-deopt-exit 2>&1 | FileCheck %s |
| 3 | ; RUN: opt < %s -S -debug-only=loop-unroll -unroll-peel-multi-deopt-exit -passes='require<profile-summary>,function(require<opt-remark-emit>,unroll)' 2>&1 | FileCheck %s |
Serguei Katkov | de67aff | 2019-08-02 09:32:52 +0000 | [diff] [blame] | 4 | ; RUN: opt < %s -S -debug-only=loop-unroll -unroll-peel-multi-deopt-exit -passes='require<profile-summary>,function(require<opt-remark-emit>,unroll<no-profile-peeling>)' 2>&1 | FileCheck %s --check-prefixes=CHECK-NO-PEEL |
Serguei Katkov | 3ed93b4 | 2019-07-15 08:26:45 +0000 | [diff] [blame] | 5 | |
| 6 | ; Make sure we use the profile information correctly to peel-off 3 iterations |
| 7 | ; from the loop, and update the branch weights for the peeled loop properly. |
Serguei Katkov | c6c31da | 2019-07-22 05:15:34 +0000 | [diff] [blame] | 8 | ; All side exits to deopt does not change weigths. |
Serguei Katkov | 3ed93b4 | 2019-07-15 08:26:45 +0000 | [diff] [blame] | 9 | |
| 10 | ; CHECK: Loop Unroll: F[basic] |
| 11 | ; CHECK: PEELING loop %for.body with iteration count 3! |
Serguei Katkov | de67aff | 2019-08-02 09:32:52 +0000 | [diff] [blame] | 12 | ; CHECK-NO-PEEL-NOT: PEELING loop %for.body |
Serguei Katkov | 3ed93b4 | 2019-07-15 08:26:45 +0000 | [diff] [blame] | 13 | ; CHECK-LABEL: @basic |
Serguei Katkov | c6c31da | 2019-07-22 05:15:34 +0000 | [diff] [blame] | 14 | ; CHECK: br i1 %c, label %{{.*}}, label %side_exit, !prof !15 |
Serguei Katkov | 3ed93b4 | 2019-07-15 08:26:45 +0000 | [diff] [blame] | 15 | ; CHECK: br i1 %{{.*}}, label %[[NEXT0:.*]], label %for.cond.for.end_crit_edge, !prof !16 |
| 16 | ; CHECK: [[NEXT0]]: |
Serguei Katkov | c6c31da | 2019-07-22 05:15:34 +0000 | [diff] [blame] | 17 | ; CHECK: br i1 %c, label %{{.*}}, label %side_exit, !prof !15 |
Serguei Katkov | 3ed93b4 | 2019-07-15 08:26:45 +0000 | [diff] [blame] | 18 | ; CHECK: br i1 %{{.*}}, label %[[NEXT1:.*]], label %for.cond.for.end_crit_edge, !prof !17 |
| 19 | ; CHECK: [[NEXT1]]: |
Serguei Katkov | c6c31da | 2019-07-22 05:15:34 +0000 | [diff] [blame] | 20 | ; CHECK: br i1 %c, label %{{.*}}, label %side_exit, !prof !15 |
Serguei Katkov | 3ed93b4 | 2019-07-15 08:26:45 +0000 | [diff] [blame] | 21 | ; CHECK: br i1 %{{.*}}, label %[[NEXT2:.*]], label %for.cond.for.end_crit_edge, !prof !18 |
| 22 | ; CHECK: [[NEXT2]]: |
Serguei Katkov | c6c31da | 2019-07-22 05:15:34 +0000 | [diff] [blame] | 23 | ; CHECK: br i1 %c, label %{{.*}}, label %side_exit.loopexit, !prof !15 |
Serguei Katkov | 3ed93b4 | 2019-07-15 08:26:45 +0000 | [diff] [blame] | 24 | ; CHECK: br i1 %{{.*}}, label %for.body, label %{{.*}}, !prof !19 |
| 25 | |
| 26 | define i32 @basic(i32* %p, i32 %k, i1 %c) #0 !prof !15 { |
| 27 | entry: |
| 28 | %cmp3 = icmp slt i32 0, %k |
| 29 | br i1 %cmp3, label %for.body.lr.ph, label %for.end |
| 30 | |
| 31 | for.body.lr.ph: ; preds = %entry |
| 32 | br label %for.body |
| 33 | |
| 34 | for.body: ; preds = %for.body.lr.ph, %for.body |
| 35 | %i.05 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %continue ] |
| 36 | %p.addr.04 = phi i32* [ %p, %for.body.lr.ph ], [ %incdec.ptr, %continue ] |
| 37 | %incdec.ptr = getelementptr inbounds i32, i32* %p.addr.04, i32 1 |
| 38 | store i32 %i.05, i32* %p.addr.04, align 4 |
| 39 | %inc = add nsw i32 %i.05, 1 |
| 40 | %cmp = icmp slt i32 %inc, %k |
| 41 | br i1 %c, label %continue, label %side_exit, !prof !17 |
| 42 | |
| 43 | continue: |
| 44 | br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge, !prof !16 |
| 45 | |
| 46 | for.cond.for.end_crit_edge: ; preds = %for.body |
| 47 | br label %for.end |
| 48 | |
| 49 | for.end: ; preds = %for.cond.for.end_crit_edge, %entry |
| 50 | %res = phi i32 [ 0, %entry ], [ %inc, %for.cond.for.end_crit_edge ] |
| 51 | ret i32 %res |
| 52 | |
| 53 | side_exit: |
| 54 | %rval = call i32(...) @llvm.experimental.deoptimize.i32() [ "deopt"(i32 %inc) ] |
| 55 | ret i32 %rval |
| 56 | } |
| 57 | |
| 58 | declare i32 @llvm.experimental.deoptimize.i32(...) |
| 59 | |
| 60 | attributes #0 = { nounwind } |
| 61 | attributes #1 = { nounwind optsize } |
| 62 | |
| 63 | !llvm.module.flags = !{!1} |
| 64 | |
| 65 | !1 = !{i32 1, !"ProfileSummary", !2} |
| 66 | !2 = !{!3, !4, !5, !6, !7, !8, !9, !10} |
| 67 | !3 = !{!"ProfileFormat", !"InstrProf"} |
| 68 | !4 = !{!"TotalCount", i64 10} |
| 69 | !5 = !{!"MaxCount", i64 3} |
| 70 | !6 = !{!"MaxInternalCount", i64 1} |
| 71 | !7 = !{!"MaxFunctionCount", i64 3} |
| 72 | !8 = !{!"NumCounts", i64 2} |
| 73 | !9 = !{!"NumFunctions", i64 2} |
| 74 | !10 = !{!"DetailedSummary", !11} |
| 75 | !11 = !{!12, !13, !14} |
| 76 | !12 = !{i32 10000, i64 3, i32 2} |
| 77 | !13 = !{i32 999000, i64 1, i32 10} |
| 78 | !14 = !{i32 999999, i64 1, i32 10} |
| 79 | !15 = !{!"function_entry_count", i64 1} |
| 80 | !16 = !{!"branch_weights", i32 3001, i32 1001} |
| 81 | !17 = !{!"branch_weights", i32 1, i32 0} |
| 82 | |
Serguei Katkov | c6c31da | 2019-07-22 05:15:34 +0000 | [diff] [blame] | 83 | ; This is a weights of deopt side-exit. |
| 84 | ;CHECK: !15 = !{!"branch_weights", i32 1, i32 0} |
| 85 | ; This is a weights of latch and its copies. |
| 86 | ;CHECK: !16 = !{!"branch_weights", i32 3001, i32 1001} |
| 87 | ;CHECK: !17 = !{!"branch_weights", i32 2000, i32 1001} |
| 88 | ;CHECK: !18 = !{!"branch_weights", i32 999, i32 1001} |
| 89 | ;CHECK: !19 = !{!"branch_weights", i32 1, i32 1001} |
Serguei Katkov | 3ed93b4 | 2019-07-15 08:26:45 +0000 | [diff] [blame] | 90 | |