aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-21 05:34:23 +0000
committerChris Lattner <sabre@nondot.org>2006-10-21 05:34:23 +0000
commit34a84ac81c1ab3cd017203f69ce74283f42be15a (patch)
treedabb5e93f53b2e2e7f0ce10a9257ec13ad77ddb2
parent386e29065db5b05b57440f6b2a6dfa1e7f29a00d (diff)
allow insertion of a conditional branch with fall-through
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31095 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/X86InstrInfo.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp
index b2b9d557e1..0cc4c39cfb 100644
--- a/lib/Target/X86/X86InstrInfo.cpp
+++ b/lib/Target/X86/X86InstrInfo.cpp
@@ -374,15 +374,21 @@ void X86InstrInfo::InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
const std::vector<MachineOperand> &Cond) const {
// Shouldn't be a fall through.
assert(TBB && "InsertBranch must not be told to insert a fallthrough");
-
- // Unconditional branch?
- if (FBB == 0) {
- BuildMI(&MBB, X86::JMP, 1).addMBB(TBB);
+ assert((Cond.size() == 1 || Cond.size() == 0) &&
+ "X86 branch conditions have one component!");
+
+ if (FBB == 0) { // One way branch.
+ if (Cond.empty()) {
+ // Unconditional branch?
+ BuildMI(&MBB, X86::JMP, 1).addMBB(TBB);
+ } else {
+ // Conditional branch.
+ unsigned Opc = GetCondBranchFromCond((X86::CondCode)Cond[0].getImm());
+ BuildMI(&MBB, Opc, 1).addMBB(TBB);
+ }
return;
}
- assert(Cond.size() == 1 && "X86 branch conditions have one component!");
-
// Conditional branch.
unsigned Opc = GetCondBranchFromCond((X86::CondCode)Cond[0].getImm());
BuildMI(&MBB, Opc, 1).addMBB(TBB);