[llvm-commits] [llvm] r71779 - /llvm/trunk/lib/CodeGen/IfConversion.cpp

Bob Wilson bob.wilson at apple.com
Thu May 14 11:08:53 PDT 2009


Author: bwilson
Date: Thu May 14 13:08:41 2009
New Revision: 71779

URL: http://llvm.org/viewvc/llvm-project?rev=71779&view=rev
Log:
Revert r71744.  I must not have understood this correctly, because the
assertion is failing for some tests.

Modified:
    llvm/trunk/lib/CodeGen/IfConversion.cpp

Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=71779&r1=71778&r2=71779&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/IfConversion.cpp (original)
+++ llvm/trunk/lib/CodeGen/IfConversion.cpp Thu May 14 13:08:41 2009
@@ -1187,10 +1187,15 @@
   ToBBI.BB->splice(ToBBI.BB->end(),
                    FromBBI.BB, FromBBI.BB->begin(), FromBBI.BB->end());
 
-  // This only works when FromBBI has no predecessors except ToBBI.
-  assert(FromBBI.BB->pred_size() == 1 &&
-         *FromBBI.BB->pred_begin() == ToBBI.BB &&
-         "if-converter not merging block into its unique predecessor");
+  // Redirect all branches to FromBB to ToBB.
+  std::vector<MachineBasicBlock *> Preds(FromBBI.BB->pred_begin(),
+                                         FromBBI.BB->pred_end());
+  for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
+    MachineBasicBlock *Pred = Preds[i];
+    if (Pred == ToBBI.BB)
+      continue;
+    Pred->ReplaceUsesOfBlockWith(FromBBI.BB, ToBBI.BB);
+  }
  
   std::vector<MachineBasicBlock *> Succs(FromBBI.BB->succ_begin(),
                                          FromBBI.BB->succ_end());





More information about the llvm-commits mailing list