summaryrefslogtreecommitdiff
path: root/test/Analysis
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-10-19 10:32:19 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-10-19 10:32:19 +0000
commit941aa7b1e8c1b77544d643e8b23ff07f7f83f281 (patch)
tree651ee5eb067c9eb0e6cfc0c43d3a2762c4fdb1ef /test/Analysis
parent99d01c54a0fd790a48d5aa02bfeb4cc08388b8fa (diff)
downloadllvm-941aa7b1e8c1b77544d643e8b23ff07f7f83f281.tar.gz
llvm-941aa7b1e8c1b77544d643e8b23ff07f7f83f281.tar.bz2
llvm-941aa7b1e8c1b77544d643e8b23ff07f7f83f281.tar.xz
Generalize the reading of probability metadata to work for both branches
and switches, with arbitrary numbers of successors. Still optimized for the common case of 2 successors for a conditional branch. Add a test case for switch metadata showing up in the BlockFrequencyInfo pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142493 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/BlockFrequencyInfo/basic.ll43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/Analysis/BlockFrequencyInfo/basic.ll b/test/Analysis/BlockFrequencyInfo/basic.ll
index f043dc08e4..540d06b1f5 100644
--- a/test/Analysis/BlockFrequencyInfo/basic.ll
+++ b/test/Analysis/BlockFrequencyInfo/basic.ll
@@ -47,3 +47,46 @@ exit:
}
!0 = metadata !{metadata !"branch_weights", i32 64, i32 4}
+
+define i32 @test3(i32 %i, i32 %a, i32 %b, i32 %c, i32 %d, i32 %e) {
+; CHECK: Printing analysis {{.*}} for function 'test3'
+; CHECK: entry = 1024
+entry:
+ switch i32 %i, label %case_a [ i32 1, label %case_b
+ i32 2, label %case_c
+ i32 3, label %case_d
+ i32 4, label %case_e ], !prof !1
+
+; CHECK: case_a = 51
+case_a:
+ br label %exit
+
+; CHECK: case_b = 51
+case_b:
+ br label %exit
+
+; The 'case_c' branch is predicted more likely via branch weight metadata.
+; CHECK: case_c = 819
+case_c:
+ br label %exit
+
+; CHECK: case_d = 51
+case_d:
+ br label %exit
+
+; CHECK: case_e = 51
+case_e:
+ 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, %case_a ],
+ [ %b, %case_b ],
+ [ %c, %case_c ],
+ [ %d, %case_d ],
+ [ %e, %case_e ]
+ ret i32 %result
+}
+
+!1 = metadata !{metadata !"branch_weights", i32 4, i32 4, i32 64, i32 4, i32 4}