diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2011-10-19 10:30:30 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2011-10-19 10:30:30 +0000 |
commit | 99d01c54a0fd790a48d5aa02bfeb4cc08388b8fa (patch) | |
tree | f937b9c7d85eece81dbc1f73370dfb26006570ae /test/Analysis/BlockFrequencyInfo | |
parent | 6aa5c26c81071e22a23a6f0ae7dcac6080ad6597 (diff) | |
download | llvm-99d01c54a0fd790a48d5aa02bfeb4cc08388b8fa.tar.gz llvm-99d01c54a0fd790a48d5aa02bfeb4cc08388b8fa.tar.bz2 llvm-99d01c54a0fd790a48d5aa02bfeb4cc08388b8fa.tar.xz |
Teach the BranchProbabilityInfo analysis pass to read any metadata
encoding of probabilities. In the absense of metadata, it continues to
fall back on static heuristics.
This allows __builtin_expect, after lowering through llvm.expect
a branch instruction's metadata, to actually enter the branch
probability model. This is one component of resolving PR2577.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142492 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/BlockFrequencyInfo')
-rw-r--r-- | test/Analysis/BlockFrequencyInfo/basic.ll | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/Analysis/BlockFrequencyInfo/basic.ll b/test/Analysis/BlockFrequencyInfo/basic.ll index c09e3ff03e..f043dc08e4 100644 --- a/test/Analysis/BlockFrequencyInfo/basic.ll +++ b/test/Analysis/BlockFrequencyInfo/basic.ll @@ -22,3 +22,28 @@ body: exit: ret i32 %sum } + +define i32 @test2(i32 %i, i32 %a, i32 %b) { +; CHECK: Printing analysis {{.*}} for function 'test2' +; CHECK: entry = 1024 +entry: + %cond = icmp ult i32 %i, 42 + br i1 %cond, label %then, label %else, !prof !0 + +; The 'then' branch is predicted more likely via branch weight metadata. +; CHECK: then = 963 +then: + br label %exit + +; CHECK: else = 60 +else: + br label %exit + +; FIXME: It may be a bug that we don't sum back to 1024. +; CHECK: exit = 1023 +exit: + %result = phi i32 [ %a, %then ], [ %b, %else ] + ret i32 %result +} + +!0 = metadata !{metadata !"branch_weights", i32 64, i32 4} |