summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2008-05-12 22:53:12 +0000
committerDale Johannesen <dalej@apple.com>2008-05-12 22:53:12 +0000
commit9d29283fc7d26b5af5ea489e873097b8775bb321 (patch)
tree05958502c3aa7119fa7e2c94437fa9e2d7915881 /llvm/lib/CodeGen/BranchFolding.cpp
parenta98fe19c7e2eb5ddcb30b512417850f53f8168dc (diff)
downloadbcm5719-llvm-9d29283fc7d26b5af5ea489e873097b8775bb321.tar.gz
bcm5719-llvm-9d29283fc7d26b5af5ea489e873097b8775bb321.zip
Be more aggressive about tail-merging small blocks
if those blocks consist entirely of common instructions; merging will not add an extra branch in this case. llvm-svn: 51006
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index a8fee1c9ac3..1807f98cb13 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -495,7 +495,18 @@ unsigned BranchFolder::ComputeSameTails(unsigned CurHash,
CurMPIter->second,
I->second,
TrialBBI1, TrialBBI2);
- if (CommonTailLen >= minCommonTailLength) {
+ // If we will have to split a block, there should be at least
+ // minCommonTailLength instructions in common; if not, at worst
+ // we will be replacing a fallthrough into the common tail with a
+ // branch, which at worst breaks even with falling through into
+ // the duplicated common tail, so 1 instruction in common is enough.
+ // We will always pick a block we do not have to split as the common
+ // tail if there is one.
+ // (Empty blocks will get forwarded and need not be considered.)
+ if (CommonTailLen >= minCommonTailLength ||
+ (CommonTailLen > 0 &&
+ (TrialBBI1==CurMPIter->second->begin() ||
+ TrialBBI2==I->second->begin()))) {
if (CommonTailLen > maxCommonTailLength) {
SameTails.clear();
maxCommonTailLength = CommonTailLen;
OpenPOWER on IntegriCloud