diff options
author | Chris Lattner <sabre@nondot.org> | 2008-12-09 06:58:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-12-09 06:58:04 +0000 |
commit | 4d1281cdf2508436d5dc71261f793a69dfde1b05 (patch) | |
tree | 44f719f965b50af2614c27dbf233d127129798d2 /llvm/lib | |
parent | e8113a70fa627d9be0e81074c479a073e9047b0d (diff) | |
download | bcm5719-llvm-4d1281cdf2508436d5dc71261f793a69dfde1b05.tar.gz bcm5719-llvm-4d1281cdf2508436d5dc71261f793a69dfde1b05.zip |
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.
llvm-svn: 60746
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index e75f8875e62..3a4fed6bf9f 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/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 |