[llvm-commits] [llvm] r50018 - /llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp

Chris Lattner sabre at nondot.org
Sun Apr 20 17:54:38 PDT 2008


Author: lattner
Date: Sun Apr 20 19:54:38 2008
New Revision: 50018

URL: http://llvm.org/viewvc/llvm-project?rev=50018&view=rev
Log:
Factor dominator tree and frontier updating into SplitBlockPredecessors
instead of doing it after every call.

Modified:
    llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp

Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=50018&r1=50017&r2=50018&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Sun Apr 20 19:54:38 2008
@@ -263,17 +263,18 @@
 /// SplitBlockPredecessors - Split the specified block into two blocks.  We want
 /// to move the predecessors specified in the Preds list to point to the new
 /// block, leaving the remaining predecessors pointing to BB.  This method
-/// updates the SSA PHINode's and AliasAnalysis, but no other analyses.
+/// updates the SSA PHINode's, AliasAnalysis, DominatorTree and
+/// DominanceFrontier, but no other analyses.
 ///
 BasicBlock *LoopSimplify::SplitBlockPredecessors(BasicBlock *BB,
                                                  const char *Suffix,
                                        const std::vector<BasicBlock*> &Preds) {
 
-  // Create new basic block, insert right before the original block...
+  // Create new basic block, insert right before the original block.
   BasicBlock *NewBB =
     BasicBlock::Create(BB->getName()+Suffix, BB->getParent(), BB);
 
-  // The preheader first gets an unconditional branch to the loop header...
+  // The preheader first gets an unconditional branch to the loop header.
   BranchInst *BI = BranchInst::Create(BB, NewBB);
 
   // For every PHI node in the block, insert a PHI node into NewBB where the
@@ -288,6 +289,11 @@
       // Insert dummy values as the incoming value...
       PN->addIncoming(Constant::getNullValue(PN->getType()), NewBB);
     }
+    
+    DT->splitBlock(NewBB);
+    if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
+      DF->splitBlock(NewBB);
+    
     return NewBB;
   }
   
@@ -336,7 +342,7 @@
       // If I is in NewBB, the Dominator call will fail, because NewBB isn't
       // registered in DominatorTree yet.  Handle this case explicitly.
       if (!I || (I->getParent() != NewBB &&
-                 getAnalysis<DominatorTree>().dominates(I, PN))) {
+                 DT->dominates(I, PN))) {
         PN->replaceAllUsesWith(V);
         if (AA) AA->deleteValue(PN);
         BB->getInstList().erase(PN);
@@ -357,6 +363,10 @@
       Preds[i]->setUnwindDest(NewBB);
   }
 
+  DT->splitBlock(NewBB);
+  if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
+    DF->splitBlock(NewBB);
+  
   return NewBB;
 }
 
@@ -387,10 +397,6 @@
   if (Loop *Parent = L->getParentLoop())
     Parent->addBasicBlockToLoop(NewBB, LI->getBase());
 
-  DT->splitBlock(NewBB);
-  if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
-    DF->splitBlock(NewBB);
-
   // Make sure that NewBB is put someplace intelligent, which doesn't mess up
   // code layout too horribly.
   PlaceSplitBlockCarefully(NewBB, OutsideBlocks, L);
@@ -419,11 +425,6 @@
   if (SuccLoop)
     SuccLoop->addBasicBlockToLoop(NewBB, LI->getBase());
 
-  // Update Dominator Information
-  DT->splitBlock(NewBB);
-  if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
-    DF->splitBlock(NewBB);
-
   return NewBB;
 }
 
@@ -543,11 +544,6 @@
   BasicBlock *Header = L->getHeader();
   BasicBlock *NewBB = SplitBlockPredecessors(Header, ".outer", OuterLoopPreds);
 
-  // Update dominator information
-  DT->splitBlock(NewBB);
-  if (DominanceFrontier *DF = getAnalysisToUpdate<DominanceFrontier>())
-    DF->splitBlock(NewBB);
-
   // Make sure that NewBB is put someplace intelligent, which doesn't mess up
   // code layout too horribly.
   PlaceSplitBlockCarefully(NewBB, OuterLoopPreds, L);





More information about the llvm-commits mailing list