Support unconditional fall-through branches in FastISel.
authorDan Gohman <gohman@apple.com>
Tue, 19 Aug 2008 22:31:46 +0000 (22:31 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 19 Aug 2008 22:31:46 +0000 (22:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55014 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/FastISel.cpp

index 5a7c8964750a2beba6b70dd90db49d7519699a14..ab6c80e18274cc074d8231475f6e51242bf4a42c 100644 (file)
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "llvm/Instructions.h"
 #include "llvm/CodeGen/FastISel.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
@@ -41,6 +42,21 @@ FastISel::SelectInstructions(BasicBlock::iterator Begin, BasicBlock::iterator En
       ValueMap[I] = ResultReg;
       break;
     }
+    case Instruction::Br: {
+      BranchInst *BI = cast<BranchInst>(I);
+
+      // For now, check for and handle just the most trivial case: an
+      // unconditional fall-through branch.
+      if (BI->isUnconditional() &&
+          next(MachineFunction::iterator(MBB))->getBasicBlock() ==
+            BI->getSuccessor(0)) {
+        MBB->addSuccessor(next(MachineFunction::iterator(MBB)));
+        break;
+      }
+
+      // Something more complicated. Halt "fast" selection and bail.
+      return I;
+    }
     default:
       // Unhandled instruction. Halt "fast" selection and bail.
       return I;