summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-10-02 22:15:21 +0000
committerDan Gohman <gohman@apple.com>2008-10-02 22:15:21 +0000
commit1ab1d31f7aaa9123b5f865e00becd3e1a8ff8827 (patch)
tree8344d5c1b94dd34ba429caeb2d7cfe17c9200d3d /llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
parenta78bae34a5a52c3a16d70e296857090f1456120d (diff)
downloadbcm5719-llvm-1ab1d31f7aaa9123b5f865e00becd3e1a8ff8827.tar.gz
bcm5719-llvm-1ab1d31f7aaa9123b5f865e00becd3e1a8ff8827.zip
Optimize conditional branches in X86FastISel. This replaces
sequences like this: sete %al testb %al, %al jne LBB11_1 with this: je LBB11_1 llvm-svn: 56969
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FastISel.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index 9f70bc998c9..c0e8418c4c5 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -461,6 +461,23 @@ FastISel::SelectInstruction(Instruction *I) {
return SelectOperator(I, I->getOpcode());
}
+/// FastEmitBranch - Emit an unconditional branch to the given block,
+/// unless it is the immediate (fall-through) successor, and update
+/// the CFG.
+void
+FastISel::FastEmitBranch(MachineBasicBlock *MSucc) {
+ MachineFunction::iterator NextMBB =
+ next(MachineFunction::iterator(MBB));
+
+ if (MBB->isLayoutSuccessor(MSucc)) {
+ // The unconditional fall-through case, which needs no instructions.
+ } else {
+ // The unconditional branch case.
+ TII.InsertBranch(*MBB, MSucc, NULL, SmallVector<MachineOperand, 0>());
+ }
+ MBB->addSuccessor(MSucc);
+}
+
bool
FastISel::SelectOperator(User *I, unsigned Opcode) {
switch (Opcode) {
@@ -508,18 +525,9 @@ FastISel::SelectOperator(User *I, unsigned Opcode) {
BranchInst *BI = cast<BranchInst>(I);
if (BI->isUnconditional()) {
- MachineFunction::iterator NextMBB =
- next(MachineFunction::iterator(MBB));
BasicBlock *LLVMSucc = BI->getSuccessor(0);
MachineBasicBlock *MSucc = MBBMap[LLVMSucc];
-
- if (NextMBB != MF.end() && MSucc == NextMBB) {
- // The unconditional fall-through case, which needs no instructions.
- } else {
- // The unconditional branch case.
- TII.InsertBranch(*MBB, MSucc, NULL, SmallVector<MachineOperand, 0>());
- }
- MBB->addSuccessor(MSucc);
+ FastEmitBranch(MSucc);
return true;
}
OpenPOWER on IntegriCloud