[llvm-commits] [llvm] r60163 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Chris Lattner sabre at nondot.org
Wed Nov 26 23:54:12 PST 2008


Author: lattner
Date: Thu Nov 27 01:54:12 2008
New Revision: 60163

URL: http://llvm.org/viewvc/llvm-project?rev=60163&view=rev
Log:
Use the new MergeBasicBlockIntoOnlyPred function.

Modified:
    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=60163&r1=60162&r2=60163&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Thu Nov 27 01:54:12 2008
@@ -205,25 +205,7 @@
   // If the destination block has a single pred, then this is a trivial edge,
   // just collapse it.
   if (DestBB->getSinglePredecessor()) {
-    // If DestBB has single-entry PHI nodes, fold them.
-    while (PHINode *PN = dyn_cast<PHINode>(DestBB->begin())) {
-      Value *NewVal = PN->getIncomingValue(0);
-      // Replace self referencing PHI with undef, it must be dead.
-      if (NewVal == PN) NewVal = UndefValue::get(PN->getType());
-      PN->replaceAllUsesWith(NewVal);
-      PN->eraseFromParent();
-    }
-
-    // Splice all the PHI nodes from BB over to DestBB.
-    DestBB->getInstList().splice(DestBB->begin(), BB->getInstList(),
-                                 BB->begin(), BI);
-
-    // Anything that branched to BB now branches to DestBB.
-    BB->replaceAllUsesWith(DestBB);
-
-    // Nuke BB.
-    BB->eraseFromParent();
-
+    MergeBasicBlockIntoOnlyPred(DestBB);
     DOUT << "AFTER:\n" << *DestBB << "\n\n\n";
     return;
   }





More information about the llvm-commits mailing list