diff options
| author | Manman Ren <mren@apple.com> | 2012-09-15 00:39:57 +0000 |
|---|---|---|
| committer | Manman Ren <mren@apple.com> | 2012-09-15 00:39:57 +0000 |
| commit | bfb9d435e43a41531720befc94f990c8daa379ff (patch) | |
| tree | ff7531837f900e958848a22f0eef5339de9b2f3a /llvm/test/Transforms/SimplifyCFG/preserve-branchweights.ll | |
| parent | 1e46d48814c475503cf8469076949c0523ba1613 (diff) | |
| download | bcm5719-llvm-bfb9d435e43a41531720befc94f990c8daa379ff.tar.gz bcm5719-llvm-bfb9d435e43a41531720befc94f990c8daa379ff.zip | |
PGO: preserve branch-weight metadata when simplifying two branches with a common
destination.
Updated previous implementation to fix a case not covered:
// PBI: br i1 %x, TrueDest, BB
// BI: br i1 %y, TrueDest, FalseDest
The other case was handled correctly.
// PBI: br i1 %x, BB, FalseDest
// BI: br i1 %y, TrueDest, FalseDest
Also tried to use 64-bit arithmetic instead of APInt with scale to simplify the
computation. Let me know if you have other opinions about this.
llvm-svn: 163954
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG/preserve-branchweights.ll')
| -rw-r--r-- | llvm/test/Transforms/SimplifyCFG/preserve-branchweights.ll | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/preserve-branchweights.ll b/llvm/test/Transforms/SimplifyCFG/preserve-branchweights.ll index 93bbcfb38c3..1564e4e11d7 100644 --- a/llvm/test/Transforms/SimplifyCFG/preserve-branchweights.ll +++ b/llvm/test/Transforms/SimplifyCFG/preserve-branchweights.ll @@ -154,6 +154,26 @@ sw.epilog: ret void } +;; This test is based on test1 but swapped the targets of the second branch. +define void @test1_swap(i1 %a, i1 %b) { +; CHECK: @test1_swap +entry: + br i1 %a, label %Y, label %X, !prof !0 +; CHECK: br i1 %or.cond, label %Y, label %Z, !prof !4 + +X: + %c = or i1 %b, false + br i1 %c, label %Y, label %Z, !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} @@ -165,4 +185,5 @@ sw.epilog: ; CHECK: !1 = metadata !{metadata !"branch_weights", i32 1, i32 5} ; CHECK: !2 = metadata !{metadata !"branch_weights", i32 7, i32 1, i32 2} ; CHECK: !3 = metadata !{metadata !"branch_weights", i32 49, i32 12, i32 24, i32 35} -; CHECK-NOT: !4 +; CHECK: !4 = metadata !{metadata !"branch_weights", i32 11, i32 5} +; CHECK-NOT: !5 |

