[llvm-commits] [llvm] r40810 - /llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp

Chris Lattner sabre at nondot.org
Fri Aug 3 19:21:22 PDT 2007


Author: lattner
Date: Fri Aug  3 21:21:22 2007
New Revision: 40810

URL: http://llvm.org/viewvc/llvm-project?rev=40810&view=rev
Log:
switch from using a std::set to using a SmallPtrSet.  This speeds up the
testcase in PR1432 from 6.33s to 2.90s (2.22x)

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

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

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Fri Aug  3 21:21:22 2007
@@ -534,7 +534,7 @@
   StoreInst *OnlyStore = Info.OnlyStore;
   
   // Be aware of loads before the store.
-  std::set<BasicBlock*> ProcessedBlocks;
+  SmallPtrSet<BasicBlock*, 32> ProcessedBlocks;
   for (unsigned i = 0, e = Info.UsingBlocks.size(); i != e; ++i) {
     // If the store dominates the block and if we haven't processed it yet,
     // do so now.
@@ -542,7 +542,7 @@
       continue;
     
     BasicBlock *UseBlock = Info.UsingBlocks[i];
-    if (!ProcessedBlocks.insert(UseBlock).second)
+    if (!ProcessedBlocks.insert(UseBlock))
       continue;
     
     // If the use and store are in the same block, do a quick scan to
@@ -559,7 +559,7 @@
     // Otherwise, if this is a different block or if all uses happen
     // after the store, do a simple linear scan to replace loads with
     // the stored value.
-    for (BasicBlock::iterator I = UseBlock->begin(),E = UseBlock->end();
+    for (BasicBlock::iterator I = UseBlock->begin(), E = UseBlock->end();
          I != E; ) {
       if (LoadInst *LI = dyn_cast<LoadInst>(I++)) {
         if (LI->getOperand(0) == AI) {





More information about the llvm-commits mailing list