summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2009-10-27 17:40:24 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2009-10-27 17:40:24 +0000
commita789f17ffcf1b0f24cad9e29119c0cabe8d9148b (patch)
tree01aeff1d5210a2d57be13a73b060e9e430925c29
parent1f8f60e62f9e51f844e93cc70318cc3501cb760b (diff)
downloadbcm5719-llvm-a789f17ffcf1b0f24cad9e29119c0cabe8d9148b.tar.gz
bcm5719-llvm-a789f17ffcf1b0f24cad9e29119c0cabe8d9148b.zip
Remove unnecessary gotos to fall-thru successors.
llvm-svn: 85257
-rw-r--r--llvm/lib/Target/PIC16/PIC16InstrInfo.cpp22
-rw-r--r--llvm/lib/Target/PIC16/PIC16InstrInfo.h5
2 files changed, 26 insertions, 1 deletions
diff --git a/llvm/lib/Target/PIC16/PIC16InstrInfo.cpp b/llvm/lib/Target/PIC16/PIC16InstrInfo.cpp
index 87bd3d9c7e6..2fb405e947f 100644
--- a/llvm/lib/Target/PIC16/PIC16InstrInfo.cpp
+++ b/llvm/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/llvm/lib/Target/PIC16/PIC16InstrInfo.h b/llvm/lib/Target/PIC16/PIC16InstrInfo.h
index 85c098428c9..56f51f00dd8 100644
--- a/llvm/lib/Target/PIC16/PIC16InstrInfo.h
+++ b/llvm/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
OpenPOWER on IntegriCloud