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

Chris Lattner sabre at nondot.org
Sat Aug 4 15:03:24 CDT 2007


Author: lattner
Date: Sat Aug  4 15:03:23 2007
New Revision: 40818

URL: http://llvm.org/viewvc/llvm-project?rev=40818&view=rev
Log:
Promoting allocas with the 'single store' fastpath is 
faster than with the 'local to a block' fastpath.  This speeds
up PR1432 from 2.1232 to 2.0686s (2.6%)


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=40818&r1=40817&r2=40818&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/PromoteMemoryToRegister.cpp Sat Aug  4 15:03:23 2007
@@ -273,16 +273,6 @@
     // analogous to finding the 'uses' and 'definitions' of each variable.
     Info.AnalyzeAlloca(AI);
 
-    // If the alloca is only read and written in one basic block, just perform a
-    // linear sweep over the block to eliminate it.
-    if (Info.OnlyUsedInOneBlock) {
-      LocallyUsedAllocas[Info.OnlyBlock].push_back(AI);
-
-      // Remove the alloca from the Allocas list, since it will be processed.
-      RemoveFromAllocasList(AllocaNum);
-      continue;
-    }
-
     // If there is only a single store to this value, replace any loads of
     // it that are directly dominated by the definition with the value stored.
     if (Info.DefiningBlocks.size() == 1) {
@@ -303,6 +293,15 @@
       }
     }
     
+    // If the alloca is only read and written in one basic block, just perform a
+    // linear sweep over the block to eliminate it.
+    if (Info.OnlyUsedInOneBlock) {
+      LocallyUsedAllocas[Info.OnlyBlock].push_back(AI);
+      
+      // Remove the alloca from the Allocas list, since it will be processed.
+      RemoveFromAllocasList(AllocaNum);
+      continue;
+    }
     
     if (AST)
       PointerAllocaValues[AllocaNum] = Info.AllocaPointerVal;





More information about the llvm-commits mailing list