[llvm-commits] [llvm] r60338 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Chris Lattner sabre at nondot.org
Sun Nov 30 23:29:03 PST 2008


Author: lattner
Date: Mon Dec  1 01:29:03 2008
New Revision: 60338

URL: http://llvm.org/viewvc/llvm-project?rev=60338&view=rev
Log:
pull the predMap densemap out of the inner loop of performPRE, so
that it isn't reallocated all the time.  This is a tiny speedup for
GVN: 3.90->3.88s

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

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

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Dec  1 01:29:03 2008
@@ -1225,6 +1225,7 @@
 bool GVN::performPRE(Function& F) {
   bool changed = false;
   SmallVector<std::pair<TerminatorInst*, unsigned>, 4> toSplit;
+  DenseMap<BasicBlock*, Value*> predMap;
   for (df_iterator<BasicBlock*> DI = df_begin(&F.getEntryBlock()),
        DE = df_end(&F.getEntryBlock()); DI != DE; ++DI) {
     BasicBlock* CurrentBlock = *DI;
@@ -1252,7 +1253,8 @@
       unsigned numWith = 0;
       unsigned numWithout = 0;
       BasicBlock* PREPred = 0;
-      DenseMap<BasicBlock*, Value*> predMap;
+      predMap.clear();
+
       for (pred_iterator PI = pred_begin(CurrentBlock),
            PE = pred_end(CurrentBlock); PI != PE; ++PI) {
         // We're not interested in PRE where the block is its
@@ -1359,7 +1361,7 @@
       
       Instruction* erase = BI;
       BI++;
-      DEBUG(cerr << "GVN removed: " << *erase);
+      DEBUG(cerr << "GVN PRE removed: " << *erase);
       MD->removeInstruction(erase);
       erase->eraseFromParent();
       changed = true;





More information about the llvm-commits mailing list