diff options
author | Manman Ren <mren@apple.com> | 2012-08-24 18:14:27 +0000 |
---|---|---|
committer | Manman Ren <mren@apple.com> | 2012-08-24 18:14:27 +0000 |
commit | cf10446ffa5e2abd0af6c757ecfc266352b95c4c (patch) | |
tree | f677bd83dc25e58e5c81eec3352d4ced4b03f8f6 /llvm/test/CodeGen/Generic/MachineBranchProb.ll | |
parent | 45c03a8f8d45edd174d715f4245a7984f766e2eb (diff) | |
download | bcm5719-llvm-cf10446ffa5e2abd0af6c757ecfc266352b95c4c.tar.gz bcm5719-llvm-cf10446ffa5e2abd0af6c757ecfc266352b95c4c.zip |
BranchProb: modify the definition of an edge in BranchProbabilityInfo to handle
the case of multiple edges from one block to another.
A simple example is a switch statement with multiple values to the same
destination. The definition of an edge is modified from a pair of blocks to
a pair of PredBlock and an index into the successors.
Also set the weight correctly when building SelectionDAG from LLVM IR,
especially when converting a Switch.
IntegersSubsetMapping is updated to calculate the weight for each cluster.
llvm-svn: 162572
Diffstat (limited to 'llvm/test/CodeGen/Generic/MachineBranchProb.ll')
-rw-r--r-- | llvm/test/CodeGen/Generic/MachineBranchProb.ll | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/Generic/MachineBranchProb.ll b/llvm/test/CodeGen/Generic/MachineBranchProb.ll new file mode 100644 index 00000000000..802ee2cb055 --- /dev/null +++ b/llvm/test/CodeGen/Generic/MachineBranchProb.ll @@ -0,0 +1,32 @@ +; RUN: llc < %s -print-machineinstrs=expand-isel-pseudos -o /dev/null 2>&1 | FileCheck %s + +; Make sure we have the correct weight attached to each successor. +define i32 @test2(i32 %x) nounwind uwtable readnone ssp { +; CHECK: Machine code for function test2: +entry: + %conv = sext i32 %x to i64 + switch i64 %conv, label %return [ + i64 0, label %sw.bb + i64 1, label %sw.bb + i64 4, label %sw.bb + i64 5, label %sw.bb1 + ], !prof !0 +; CHECK: BB#0: derived from LLVM BB %entry +; CHECK: Successors according to CFG: BB#2(64) BB#4(14) +; CHECK: BB#4: derived from LLVM BB %entry +; CHECK: Successors according to CFG: BB#1(10) BB#5(4) +; CHECK: BB#5: derived from LLVM BB %entry +; CHECK: Successors according to CFG: BB#1(4) BB#3(7) + +sw.bb: + br label %return + +sw.bb1: + br label %return + +return: + %retval.0 = phi i32 [ 5, %sw.bb1 ], [ 1, %sw.bb ], [ 0, %entry ] + ret i32 %retval.0 +} + +!0 = metadata !{metadata !"branch_weights", i32 7, i32 6, i32 4, i32 4, i32 64} |