X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=lib%2FCodeGen%2FBranchFolding.cpp;h=a56fec468cc94cd282e56543663cecaf565e41ad;hp=bd89ee366962f30dbd72c1c4050bcc9e3eeaa21f;hb=5666fc71f0e2ed2c0400d8bca079a1dd3f33fe53;hpb=0e59c4e3e8f8e105834d137cccb1e1bb731b5a13;ds=sidebyside diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index bd89ee36696..a56fec468cc 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -493,15 +493,6 @@ static void FixTail(MachineBasicBlock *CurMBB, MachineBasicBlock *SuccBB, MachineBasicBlock *NextBB = &*I; if (TBB == NextBB && !Cond.empty() && !FBB) { if (!TII->ReverseBranchCondition(Cond)) { - // XXX-disabled: Don't fold conditional branches that we added - // intentionally. - MachineBasicBlock::iterator I = CurMBB->getLastNonDebugInstr(); - if (I != CurMBB->end()) { - if (I->isConditionalBranch()) { - return; - } - } - TII->RemoveBranch(*CurMBB); TII->InsertBranch(*CurMBB, SuccBB, nullptr, Cond, dl); return; @@ -1125,6 +1116,12 @@ bool BranchFolder::OptimizeBranches(MachineFunction &MF) { for (MachineFunction::iterator I = std::next(MF.begin()), E = MF.end(); I != E; ) { MachineBasicBlock *MBB = &*I++; + // XXX-disabled: Don't optimize blocks that contain intentionally added fake + // conditional branch. + if (!MBB->getCanEliminateMachineBB()) { + continue; + } + MadeChange |= OptimizeBlock(MBB); // If it is dead, remove it. @@ -1302,15 +1299,6 @@ ReoptimizeBlock: // If the previous branch *only* branches to *this* block (conditional or // not) remove the branch. if (PriorTBB == MBB && !PriorFBB) { - // XXX-disabled: Don't fold conditional branches that we added - // intentionally. - MachineBasicBlock::iterator I = PrevBB.getLastNonDebugInstr(); - if (I != PrevBB.end()) { - if (I->isConditionalBranch()) { - return MadeChange ; - } - } - TII->RemoveBranch(PrevBB); MadeChange = true; ++NumBranchOpts; @@ -1320,15 +1308,6 @@ ReoptimizeBlock: // If the prior block branches somewhere else on the condition and here if // the condition is false, remove the uncond second branch. if (PriorFBB == MBB) { - // XXX-disabled: Don't fold conditional branches that we added - // intentionally. - MachineBasicBlock::iterator I = PrevBB.getLastNonDebugInstr(); - if (I != PrevBB.end()) { - if (I->isConditionalBranch()) { - return MadeChange ; - } - } - DebugLoc dl = getBranchDebugLoc(PrevBB); TII->RemoveBranch(PrevBB); TII->InsertBranch(PrevBB, PriorTBB, nullptr, PriorCond, dl); @@ -1341,15 +1320,6 @@ ReoptimizeBlock: // if the branch condition is reversible, reverse the branch to create a // fall-through. if (PriorTBB == MBB) { - // XXX-disabled: Don't fold conditional branches that we added - // intentionally. - MachineBasicBlock::iterator I = PrevBB.getLastNonDebugInstr(); - if (I != PrevBB.end()) { - if (I->isConditionalBranch()) { - return MadeChange ; - } - } - SmallVector NewPriorCond(PriorCond); if (!TII->ReverseBranchCondition(NewPriorCond)) { DebugLoc dl = getBranchDebugLoc(PrevBB);