If the predicated block requires an early exit, end the block there and add a uncondi...
authorEvan Cheng <evan.cheng@apple.com>
Tue, 5 Jun 2007 01:31:40 +0000 (01:31 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 5 Jun 2007 01:31:40 +0000 (01:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37430 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/IfConversion.cpp

index bd50121f4b387a4f8943c5c098079a3f5bbe00fb..1023f8fd95064fb7b5bcaf8ce3eac91a7c42edd1 100644 (file)
@@ -527,7 +527,8 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) {
   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 @@ bool IfConverter::IfConvertTriangle(BBInfo &BBI) {
   // 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))