aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2009-05-11 21:54:13 +0000
committerDale Johannesen <dalej@apple.com>2009-05-11 21:54:13 +0000
commitbf06f6a6f1be0802ad7b761138ecba568814008a (patch)
tree1d152e8f763dfb0ec243b41d4e775120babd9deb /lib
parentfb3bd472a1a987a97754137914016dbd78c7d5c7 (diff)
downloadexternal_llvm-bf06f6a6f1be0802ad7b761138ecba568814008a.zip
external_llvm-bf06f6a6f1be0802ad7b761138ecba568814008a.tar.gz
external_llvm-bf06f6a6f1be0802ad7b761138ecba568814008a.tar.bz2
Fix PR4188. TailMerging can't tolerate inexact
sucessor info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71478 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/BranchFolding.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp
index 583009c..2635303 100644
--- a/lib/CodeGen/BranchFolding.cpp
+++ b/lib/CodeGen/BranchFolding.cpp
@@ -1092,6 +1092,21 @@ void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
} else {
DidChange = true;
PMBB->ReplaceUsesOfBlockWith(MBB, CurTBB);
+ // If this change resulted in PMBB ending in a conditional
+ // branch where both conditions go to the same destination,
+ // change this to an unconditional branch (and fix the CFG).
+ MachineBasicBlock *NewCurTBB = 0, *NewCurFBB = 0;
+ SmallVector<MachineOperand, 4> NewCurCond;
+ bool NewCurUnAnalyzable = TII->AnalyzeBranch(*PMBB, NewCurTBB,
+ NewCurFBB, NewCurCond, true);
+ if (!NewCurUnAnalyzable && NewCurTBB && NewCurTBB == NewCurFBB) {
+ TII->RemoveBranch(*PMBB);
+ NewCurCond.clear();
+ TII->InsertBranch(*PMBB, NewCurTBB, 0, NewCurCond);
+ MadeChange = true;
+ ++NumBranchOpts;
+ PMBB->CorrectExtraCFGEdges(NewCurTBB, NewCurFBB, false);
+ }
}
}