aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/SimplifyCFG/preserve-branchweights.ll
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-12-27 04:31:52 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-12-27 04:31:52 +0000
commit06cc66f65a5012471835068029f3f4943790f584 (patch)
treead0e9335fcb3e0ec2bd561121bc618b377de7527 /test/Transforms/SimplifyCFG/preserve-branchweights.ll
parentda32cc6176d8ca2cd9cf387f5818ae911c91dc3c (diff)
downloadexternal_llvm-06cc66f65a5012471835068029f3f4943790f584.zip
external_llvm-06cc66f65a5012471835068029f3f4943790f584.tar.gz
external_llvm-06cc66f65a5012471835068029f3f4943790f584.tar.bz2
Teach simplifycfg to recompute branch weights when merging some branches, and
to discard weights when appropriate. Still more to do (and a new TODO), but it's a start! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147286 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyCFG/preserve-branchweights.ll')
-rw-r--r--test/Transforms/SimplifyCFG/preserve-branchweights.ll66
1 files changed, 64 insertions, 2 deletions
diff --git a/test/Transforms/SimplifyCFG/preserve-branchweights.ll b/test/Transforms/SimplifyCFG/preserve-branchweights.ll
index dab0d7c..5ef1c6c 100644
--- a/test/Transforms/SimplifyCFG/preserve-branchweights.ll
+++ b/test/Transforms/SimplifyCFG/preserve-branchweights.ll
@@ -10,6 +10,45 @@ entry:
X:
%c = or i1 %b, false
+ br i1 %c, label %Z, label %Y, !prof !1
+
+Y:
+ call void @helper(i32 0)
+ ret void
+
+Z:
+ call void @helper(i32 1)
+ ret void
+}
+
+define void @test2(i1 %a, i1 %b) {
+; CHECK: @test2
+entry:
+ br i1 %a, label %X, label %Y, !prof !1
+; CHECK: br i1 %or.cond, label %Z, label %Y, !prof !1
+; CHECK-NOT: !prof
+
+X:
+ %c = or i1 %b, false
+ br i1 %c, label %Z, label %Y, !prof !2
+
+Y:
+ call void @helper(i32 0)
+ ret void
+
+Z:
+ call void @helper(i32 1)
+ ret void
+}
+
+define void @test3(i1 %a, i1 %b) {
+; CHECK: @test3
+; CHECK-NOT: !prof
+entry:
+ br i1 %a, label %X, label %Y, !prof !1
+
+X:
+ %c = or i1 %b, false
br i1 %c, label %Z, label %Y
Y:
@@ -21,6 +60,29 @@ Z:
ret void
}
-!0 = metadata !{metadata !"branch_weights", i32 1, i32 2}
+define void @test4(i1 %a, i1 %b) {
+; CHECK: @test4
+; CHECK-NOT: !prof
+entry:
+ br i1 %a, label %X, label %Y
+
+X:
+ %c = or i1 %b, false
+ br i1 %c, label %Z, label %Y, !prof !1
+
+Y:
+ call void @helper(i32 0)
+ ret void
+
+Z:
+ call void @helper(i32 1)
+ 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}
-; CHECK: !0 = metadata !{metadata !"branch_weights", i32 2, i32 1}
+; CHECK: !0 = metadata !{metadata !"branch_weights", i32 5, i32 11}
+; CHECK: !1 = metadata !{metadata !"branch_weights", i32 1, i32 5}
+; CHECK-NOT: !2