[llvm-commits] CVS: llvm/lib/Target/X86/X86InstrInfo.cpp

Chris Lattner sabre at nondot.org
Fri Oct 20 22:34:37 PDT 2006



Changes in directory llvm/lib/Target/X86:

X86InstrInfo.cpp updated: 1.66 -> 1.67
---
Log message:

allow insertion of a conditional branch with fall-through


---
Diffs of the changes:  (+12 -6)

 X86InstrInfo.cpp |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)


Index: llvm/lib/Target/X86/X86InstrInfo.cpp
diff -u llvm/lib/Target/X86/X86InstrInfo.cpp:1.66 llvm/lib/Target/X86/X86InstrInfo.cpp:1.67
--- llvm/lib/Target/X86/X86InstrInfo.cpp:1.66	Fri Oct 20 23:42:29 2006
+++ llvm/lib/Target/X86/X86InstrInfo.cpp	Sat Oct 21 00:34:23 2006
@@ -374,15 +374,21 @@
                                 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);






More information about the llvm-commits mailing list