If the predicated block requires an early exit, end the block there and add a unconditional branch to false block. AnalyzeBranch() does not understand early exits.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37430 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp
index bd50121..1023f8f 100644
--- a/lib/CodeGen/IfConversion.cpp
+++ b/lib/CodeGen/IfConversion.cpp
@@ -527,7 +527,8 @@
   PredicateBlock(TrueBBI, BBI.BrCond);
 
   // If 'true' block has a 'false' successor, add an exit branch to it.
-  if (TrueBBI.FalseBB) {
+  bool HasEarlyExit = TrueBBI.FalseBB != NULL;
+  if (HasEarlyExit) {
     std::vector<MachineOperand> RevCond(TrueBBI.BrCond);
     if (TII->ReverseBranchCondition(RevCond))
       assert(false && "Unable to reverse branch condition!");
@@ -538,7 +539,7 @@
   // predecessors. Otherwise, add a unconditional branch from 'true' to 'false'.
   BBInfo &FalseBBI = BBAnalysis[BBI.FalseBB->getNumber()];
   bool FalseBBDead = false;
-  if (FalseBBI.BB->pred_size() == 2) {
+  if (!HasEarlyExit && FalseBBI.BB->pred_size() == 2) {
     MergeBlocks(TrueBBI, FalseBBI);
     FalseBBDead = true;
   } else if (!isNextBlock(TrueBBI.BB, FalseBBI.BB))