diff options
author | Dale Johannesen <dalej@apple.com> | 2009-05-11 21:54:13 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2009-05-11 21:54:13 +0000 |
commit | b5714633638a82f36c898f8ced140821c6fcbb8a (patch) | |
tree | 07ce4aab05dbc1160e4a82670a7fe973be1989d4 /llvm/lib/CodeGen/BranchFolding.cpp | |
parent | c0b879b4a7ebabeb6cc6e384e52355e8975411a5 (diff) | |
download | bcm5719-llvm-b5714633638a82f36c898f8ced140821c6fcbb8a.tar.gz bcm5719-llvm-b5714633638a82f36c898f8ced140821c6fcbb8a.zip |
Fix PR4188. TailMerging can't tolerate inexact
sucessor info.
llvm-svn: 71478
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
-rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 583009c74a3..26353035ae2 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/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); + } } } |