aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/MemoryDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-09 06:58:04 +0000
committerChris Lattner <sabre@nondot.org>2008-12-09 06:58:04 +0000
commit1aeadacdadc8c44821300fea01445a2fb39e0420 (patch)
tree443233be564359f4b83865df7773feca95b4ba32 /lib/Analysis/MemoryDependenceAnalysis.cpp
parent511b36c00f3fbe80770e0bbbfe8ed2f266148d65 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60746 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r--lib/Analysis/MemoryDependenceAnalysis.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp
index e75f8875e6..3a4fed6bf9 100644
--- a/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -621,8 +621,19 @@ getNonLocalPointerDepInternal(Value *Pointer, uint64_t PointeeSize,
}
// 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