[Branch probability] Recompute branch weights of tail-merged basic blocks.
authorAkira Hatanaka <ahatanaka@apple.com>
Thu, 7 Aug 2014 19:30:13 +0000 (19:30 +0000)
committerAkira Hatanaka <ahatanaka@apple.com>
Thu, 7 Aug 2014 19:30:13 +0000 (19:30 +0000)
commit70b56056a1ba8e945f2e75b67575920cb816ac69
treeb22a383c54c8961c78c2b273352de2fb07e63ecf
parent71c5eed711005f3969d6a95321a05c985eb9bace
[Branch probability] Recompute branch weights of tail-merged basic blocks.

BranchFolderPass was not correctly setting the basic block branch weights when
tail-merging created or merged blocks. This patch recomutes the weights of
tail-merged blocks using the following formula:

branch_weight(merged block to successor j) =
sum(block_frequency(bb) * branch_probability(bb -> j))

bb is a block that is in the set of merged blocks.

<rdar://problem/16256423>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215135 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/BranchFolding.cpp
lib/CodeGen/BranchFolding.h
lib/CodeGen/IfConversion.cpp
test/CodeGen/ARM/tail-merge-branch-weight.ll [new file with mode: 0644]