return false;
}
-// XXX-update: Returns whether we can remove a conditional branch instruction.
-// If it's one that is mannually added by us, then don't remove it (return
-// false). All their successors are the same.
-static bool shouldRemoveConditionalBranch(MachineInstr* I) {
- auto* MBB = I->getParent();
- assert(isCondBranchOpcode(I->getOpcode()));
- bool SameSuccessor = true;
- MachineBasicBlock* BB = nullptr;
- for (auto* Succ : MBB->successors()) {
- if (!BB) {
- BB = Succ;
- }
- if (BB != Succ) {
- SameSuccessor = false;
- }
- }
- return !SameSuccessor;
-}
-
unsigned AArch64InstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
MachineBasicBlock::iterator I = MBB.getLastNonDebugInstr();
if (I == MBB.end())
!isCondBranchOpcode(I->getOpcode()))
return 0;
- // XXX-update: Don't remove fake conditional branches.
- if (isCondBranchOpcode(I->getOpcode()) && !shouldRemoveConditionalBranch(I)) {
- return 0;
- }
-
// Remove the branch.
I->eraseFromParent();
if (!isCondBranchOpcode(I->getOpcode()))
return 1;
- // XXX-update: Don't remove fake conditional branches.
- if (!shouldRemoveConditionalBranch(I)) {
- return 1;
- }
-
// Remove the branch.
I->eraseFromParent();
return 2;