summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/BranchFolding.cpp
diff options
context:
space:
mode:
authorHaicheng Wu <haicheng@codeaurora.org>2016-08-12 08:40:24 +0000
committerHaicheng Wu <haicheng@codeaurora.org>2016-08-12 08:40:24 +0000
commitd9cbb1608f5e59c45c7ac6fa5fe7ca88e131f803 (patch)
tree3da07b8ed817721b6b2a22dcc142ff9db074ae05 /llvm/lib/CodeGen/BranchFolding.cpp
parent722a4db1985ca9a8b982074d658dfee9c4624d53 (diff)
downloadbcm5719-llvm-d9cbb1608f5e59c45c7ac6fa5fe7ca88e131f803.tar.gz
bcm5719-llvm-d9cbb1608f5e59c45c7ac6fa5fe7ca88e131f803.zip
Revert "[BranchFolding] Restrict tail merging loop blocks after MBP"
This reverts commit r278463 because it hits the bot. llvm-svn: 278484
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp32
1 files changed, 9 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index a2d304bb078..1a783b61276 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -1005,24 +1005,6 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
MachineBasicBlock *IBB = &*I;
MachineBasicBlock *PredBB = &*std::prev(I);
MergePotentials.clear();
- MachineLoop *ML;
-
- // Bail if merging after placement and IBB is the loop header because
- // -- If merging predecessors that belong to the same loop as IBB, the
- // common tail of merged predecessors may become the loop top if block
- // placement is called again and the predecessors may branch to this common
- // tail and require more branches. This can be relaxed if
- // MachineBlockPlacement::findBestLoopTop is more flexible.
- // --If merging predecessors that do not belong to the same loop as IBB, the
- // loop info of IBB's loop and the other loops may be affected. Calling the
- // block placement again may make big change to the layout and eliminate the
- // reason to do tail merging here.
- if (AfterBlockPlacement && MLI) {
- ML = MLI->getLoopFor(IBB);
- if (ML && IBB == ML->getHeader())
- continue;
- }
-
for (MachineBasicBlock *PBB : I->predecessors()) {
if (MergePotentials.size() == TailMergeThreshold)
break;
@@ -1042,12 +1024,16 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
if (PBB->hasEHPadSuccessor())
continue;
- // After block placement, only consider predecessors that belong to the
- // same loop as IBB. The reason is the same as above when skipping loop
- // header.
+ // Bail out if the loop header (IBB) is not the top of the loop chain
+ // after the block placement. Otherwise, the common tail of IBB's
+ // predecessors may become the loop top if block placement is called again
+ // and the predecessors may branch to this common tail.
+ // FIXME: Relaxed this check if the algorithm of finding loop top is
+ // changed in MBP.
if (AfterBlockPlacement && MLI)
- if (ML != MLI->getLoopFor(PBB))
- continue;
+ if (MachineLoop *ML = MLI->getLoopFor(IBB))
+ if (IBB == ML->getHeader() && ML == MLI->getLoopFor(PBB))
+ continue;
MachineBasicBlock *TBB = nullptr, *FBB = nullptr;
SmallVector<MachineOperand, 4> Cond;
OpenPOWER on IntegriCloud