mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-15 06:29:05 +00:00
improve deletion of blocks that just contain branches by knowing that
the pred block doesn't fall through into them if it's a jumptable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31263 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -534,10 +534,14 @@ void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
|
||||
// completely eliminate the block is when the block before this one
|
||||
// falls through into MBB and we can't understand the prior block's branch
|
||||
// condition.
|
||||
if (MBB->empty() && (!PriorUnAnalyzable || !PrevBB.isSuccessor(MBB))) {
|
||||
if (MBB->empty()) {
|
||||
bool PredHasNoFallThrough = TII->BlockHasNoFallThrough(PrevBB);
|
||||
if (PredHasNoFallThrough || !PriorUnAnalyzable ||
|
||||
!PrevBB.isSuccessor(MBB)) {
|
||||
// If the prior block falls through into us, turn it into an
|
||||
// explicit branch to us to make updates simpler.
|
||||
if (PrevBB.isSuccessor(MBB) && PriorTBB != MBB && PriorFBB != MBB) {
|
||||
if (!PredHasNoFallThrough && PrevBB.isSuccessor(MBB) &&
|
||||
PriorTBB != MBB && PriorFBB != MBB) {
|
||||
if (PriorTBB == 0) {
|
||||
assert(PriorCond.empty() && PriorFBB == 0 && "Bad branch analysis");
|
||||
PriorTBB = MBB;
|
||||
@@ -573,6 +577,7 @@ void BranchFolder::OptimizeBlock(MachineBasicBlock *MBB) {
|
||||
if (!HasBranchToSelf) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add the branch back if the block is more than just an uncond branch.
|
||||
TII->InsertBranch(*MBB, CurTBB, 0, CurCond);
|
||||
|
Reference in New Issue
Block a user