diff options
author | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2009-10-27 17:40:24 +0000 |
---|---|---|
committer | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2009-10-27 17:40:24 +0000 |
commit | e70b89712631a9b65c1da417adce6f89dd9db86c (patch) | |
tree | b4316f1b8783ddedfbdf0eac01c0dd9650a397b7 | |
parent | 9357754d097f006e7aec7b15f0730bb0f6c2f0c5 (diff) |
Remove unnecessary gotos to fall-thru successors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85257 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/PIC16/PIC16InstrInfo.cpp | 22 | ||||
-rw-r--r-- | lib/Target/PIC16/PIC16InstrInfo.h | 5 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/Target/PIC16/PIC16InstrInfo.cpp b/lib/Target/PIC16/PIC16InstrInfo.cpp index 87bd3d9c7e..2fb405e947 100644 --- a/lib/Target/PIC16/PIC16InstrInfo.cpp +++ b/lib/Target/PIC16/PIC16InstrInfo.cpp @@ -214,3 +214,25 @@ InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, // returning NULL. return 0; } + +bool PIC16InstrInfo::AnalyzeBranch(MachineBasicBlock &MBB, + MachineBasicBlock *&TBB, + MachineBasicBlock *&FBB, + SmallVectorImpl<MachineOperand> &Cond, + bool AllowModify) const { + MachineBasicBlock::iterator I = MBB.end(); + if (I == MBB.begin()) + return true; + + // Get the terminator instruction. + --I; + // Handle unconditional branches. If the unconditional branch's target is + // successor basic block then remove the unconditional branch. + if (I->getOpcode() == PIC16::br_uncond && AllowModify) { + if (MBB.isLayoutSuccessor(I->getOperand(0).getMBB())) { + TBB = 0; + I->eraseFromParent(); + } + } + return true; +} diff --git a/lib/Target/PIC16/PIC16InstrInfo.h b/lib/Target/PIC16/PIC16InstrInfo.h index 85c098428c..56f51f00dd 100644 --- a/lib/Target/PIC16/PIC16InstrInfo.h +++ b/lib/Target/PIC16/PIC16InstrInfo.h @@ -68,7 +68,10 @@ public: unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, const SmallVectorImpl<MachineOperand> &Cond) const; - + virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, + MachineBasicBlock *&FBB, + SmallVectorImpl<MachineOperand> &Cond, + bool AllowModify) const; }; } // namespace llvm |