[llvm-commits] [llvm] r51006 - /llvm/trunk/lib/CodeGen/BranchFolding.cpp
Dale Johannesen
dalej at apple.com
Mon May 12 15:53:13 PDT 2008
Author: johannes
Date: Mon May 12 17:53:12 2008
New Revision: 51006
URL: http://llvm.org/viewvc/llvm-project?rev=51006&view=rev
Log:
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.
Modified:
llvm/trunk/lib/CodeGen/BranchFolding.cpp
Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=51006&r1=51005&r2=51006&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original)
+++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Mon May 12 17:53:12 2008
@@ -495,7 +495,18 @@
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;
More information about the llvm-commits
mailing list