[llvm-commits] CVS: llvm/lib/CodeGen/IfConversion.cpp

Evan Cheng evan.cheng at apple.com
Mon Jun 4 18:32:02 PDT 2007



Changes in directory llvm/lib/CodeGen:

IfConversion.cpp updated: 1.24 -> 1.25
---
Log message:

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.

---
Diffs of the changes:  (+3 -2)

 IfConversion.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)


Index: llvm/lib/CodeGen/IfConversion.cpp
diff -u llvm/lib/CodeGen/IfConversion.cpp:1.24 llvm/lib/CodeGen/IfConversion.cpp:1.25
--- llvm/lib/CodeGen/IfConversion.cpp:1.24	Mon Jun  4 19:07:37 2007
+++ llvm/lib/CodeGen/IfConversion.cpp	Mon Jun  4 20:31:40 2007
@@ -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))






More information about the llvm-commits mailing list