Generates conditional branch instead of fake ones for Select instruction in some...
[oota-llvm.git] / lib / CodeGen / SelectionDAG / SelectionDAGISel.cpp
index 1676e2d..491d7ec 100644 (file)
@@ -663,11 +663,15 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
     MachineBasicBlock* Succ2Succ = nullptr;
     if ((Succ1->size() == 1 && Succ1->begin()->isUnconditionalBranch()) ||
         (Succ1->size() == 0)) {
-      Succ1Succ = *Succ1->succ_begin();
+      if (Succ1->succ_size()) {
+        Succ1Succ = *Succ1->succ_begin();
+      }
     }
     if ((Succ2->size() == 1 && Succ2->begin()->isUnconditionalBranch()) ||
         (Succ2->size() == 0)) {
-      Succ2Succ = *Succ2->succ_begin();
+      if (Succ1->succ_size()) {
+        Succ2Succ = *Succ2->succ_begin();
+      }
     }
 
     bool HasCommonDest = Succ1Succ && Succ1Succ == Succ2Succ;
@@ -675,7 +679,6 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) {
       auto MBBIter = MBB.end();
       std::advance(MBBIter, -2);
       assert(MBBIter->isConditionalBranch());
-      MBBIter->disableCanEliminateMachineInstr();
       MBB.disableCanEliminateMachineBB();
       Succ1->disableCanEliminateMachineBB();
       Succ2->disableCanEliminateMachineBB();