[llvm-commits] [llvm] r60746 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Chris Lattner sabre at nondot.org
Mon Dec 8 22:58:04 PST 2008


Author: lattner
Date: Tue Dec  9 00:58:04 2008
New Revision: 60746

URL: http://llvm.org/viewvc/llvm-project?rev=60746&view=rev
Log:
If we're only adding one new element to 'Cache', insert it into its known
position instead of using a full sort. This speeds up GVN by ~4% with the
new memdep stuff.

Modified:
    llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=60746&r1=60745&r2=60746&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Tue Dec  9 00:58:04 2008
@@ -621,8 +621,19 @@
   }
   
   // If we computed new values, re-sort Cache.
-  if (NumSortedEntries != Cache->size())
+  if (NumSortedEntries == Cache->size()) {
+    // done, no new entries.
+  } else if (NumSortedEntries+1 == Cache->size()) {
+    // One new entry, Just insert the new value at the appropriate position.
+    NonLocalDepEntry Val = Cache->back();
+    Cache->pop_back();
+    NonLocalDepInfo::iterator Entry =
+      std::upper_bound(Cache->begin(), Cache->end(), Val);
+    Cache->insert(Entry, Val);
+  } else {
+    // Added many values, do a full scale sort.
     std::sort(Cache->begin(), Cache->end());
+  }
 }
 
 /// RemoveCachedNonLocalPointerDependencies - If P exists in





More information about the llvm-commits mailing list