summaryrefslogtreecommitdiff
path: root/test/Analysis/BranchProbabilityInfo
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-08-24 18:14:27 +0000
committerManman Ren <mren@apple.com>2012-08-24 18:14:27 +0000
commit1a710fdde197b00107ef55df51054925b9a5d2a2 (patch)
treed9508714f288a9cf07342120f246ced6245d10e1 /test/Analysis/BranchProbabilityInfo
parent91f8dc9baeb35d5812a797d733e689120e041fef (diff)
downloadllvm-1a710fdde197b00107ef55df51054925b9a5d2a2.tar.gz
llvm-1a710fdde197b00107ef55df51054925b9a5d2a2.tar.bz2
llvm-1a710fdde197b00107ef55df51054925b9a5d2a2.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162572 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/BranchProbabilityInfo')
-rw-r--r--test/Analysis/BranchProbabilityInfo/basic.ll27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Analysis/BranchProbabilityInfo/basic.ll b/test/Analysis/BranchProbabilityInfo/basic.ll
index 74d06a18f7..08adfa8a36 100644
--- a/test/Analysis/BranchProbabilityInfo/basic.ll
+++ b/test/Analysis/BranchProbabilityInfo/basic.ll
@@ -88,3 +88,30 @@ exit:
}
!1 = metadata !{metadata !"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4}
+
+define i32 @test4(i32 %x) nounwind uwtable readnone ssp {
+; CHECK: Printing analysis {{.*}} for function 'test4'
+entry:
+ %conv = sext i32 %x to i64
+ switch i64 %conv, label %return [
+ i64 0, label %sw.bb
+ i64 1, label %sw.bb
+ i64 2, label %sw.bb
+ i64 5, label %sw.bb1
+ ], !prof !2
+; CHECK: edge entry -> return probability is 7 / 85
+; CHECK: edge entry -> sw.bb probability is 14 / 85
+; CHECK: edge entry -> sw.bb1 probability is 64 / 85
+
+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
+}
+
+!2 = metadata !{metadata !"branch_weights", i32 7, i32 6, i32 4, i32 4, i32 64}