summaryrefslogtreecommitdiffstats
path: root/test/Transforms/SimplifyCFG/preserve-branchweights.ll
diff options
context:
space:
mode:
authorManman Ren <mren@apple.com>2012-09-14 21:53:06 +0000
committerManman Ren <mren@apple.com>2012-09-14 21:53:06 +0000
commitad2890760f9661fb6a3dfa3ca863a87f6aea4139 (patch)
treed8eb4fbb010f17dd044ab643854c954a9aedbd9d /test/Transforms/SimplifyCFG/preserve-branchweights.ll
parent911908dcb820848056a8c23fe762af37ab857779 (diff)
downloadexternal_llvm-ad2890760f9661fb6a3dfa3ca863a87f6aea4139.zip
external_llvm-ad2890760f9661fb6a3dfa3ca863a87f6aea4139.tar.gz
external_llvm-ad2890760f9661fb6a3dfa3ca863a87f6aea4139.tar.bz2
PGO: preserve branch-weight metadata when simplifying a switch with a single
case to a conditional branch and when removing dead cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@163942 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyCFG/preserve-branchweights.ll')
-rw-r--r--test/Transforms/SimplifyCFG/preserve-branchweights.ll50
1 files changed, 49 insertions, 1 deletions
diff --git a/test/Transforms/SimplifyCFG/preserve-branchweights.ll b/test/Transforms/SimplifyCFG/preserve-branchweights.ll
index 71b2780..93bbcfb 100644
--- a/test/Transforms/SimplifyCFG/preserve-branchweights.ll
+++ b/test/Transforms/SimplifyCFG/preserve-branchweights.ll
@@ -109,12 +109,60 @@ sw.epilog:
ret void
}
+;; test6 - Some cases of the second switch are pruned during optimization.
+;; Then the second switch will be converted to a branch, finally, the first
+;; switch and the branch will be merged into a single switch.
+define void @test6(i32 %M, i32 %N) nounwind uwtable {
+entry:
+ switch i32 %N, label %sw2 [
+ i32 1, label %sw2
+ i32 2, label %sw.bb
+ i32 3, label %sw.bb1
+ ], !prof !4
+; CHECK: test6
+; CHECK: switch i32 %N, label %sw.epilog
+; CHECK: i32 3, label %sw.bb1
+; CHECK: i32 2, label %sw.bb
+; CHECK: i32 4, label %sw.bb5
+; CHECK: ], !prof !3
+
+sw.bb:
+ call void @helper(i32 0)
+ br label %sw.epilog
+
+sw.bb1:
+ call void @helper(i32 1)
+ br label %sw.epilog
+
+sw2:
+;; Here "case 2" is invalidated since the default case of the first switch
+;; does not include "case 2".
+ switch i32 %N, label %sw.epilog [
+ i32 2, label %sw.bb4
+ i32 4, label %sw.bb5
+ ], !prof !5
+
+sw.bb4:
+ call void @helper(i32 2)
+ br label %sw.epilog
+
+sw.bb5:
+ call void @helper(i32 3)
+ br label %sw.epilog
+
+sw.epilog:
+ ret void
+}
+
!0 = metadata !{metadata !"branch_weights", i32 3, i32 5}
!1 = metadata !{metadata !"branch_weights", i32 1, i32 1}
!2 = metadata !{metadata !"branch_weights", i32 1, i32 2}
!3 = metadata !{metadata !"branch_weights", i32 4, i32 3, i32 2, i32 1}
+!4 = metadata !{metadata !"branch_weights", i32 4, i32 3, i32 2, i32 1}
+!5 = metadata !{metadata !"branch_weights", i32 7, i32 6, i32 5}
; CHECK: !0 = metadata !{metadata !"branch_weights", i32 5, i32 11}
; CHECK: !1 = metadata !{metadata !"branch_weights", i32 1, i32 5}
; CHECK: !2 = metadata !{metadata !"branch_weights", i32 7, i32 1, i32 2}
-; CHECK-NOT: !3
+; CHECK: !3 = metadata !{metadata !"branch_weights", i32 49, i32 12, i32 24, i32 35}
+; CHECK-NOT: !4