diff options
author | Chris Lattner <sabre@nondot.org> | 2008-12-09 07:05:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-12-09 07:05:45 +0000 |
commit | aeaec0838b54ec48866fb95b34f27b382136efbc (patch) | |
tree | 5ab5dc3bf50af263d6b91aebec4a70a53a4fd1ee /llvm/lib/Analysis | |
parent | 4d1281cdf2508436d5dc71261f793a69dfde1b05 (diff) | |
download | bcm5719-llvm-aeaec0838b54ec48866fb95b34f27b382136efbc.tar.gz bcm5719-llvm-aeaec0838b54ec48866fb95b34f27b382136efbc.zip |
if we have two elements, insert both, don't use std::sort.
This speeds up the new GVN by another 3%
llvm-svn: 60747
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 3a4fed6bf9f..6a63b7c61a8 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -621,16 +621,29 @@ getNonLocalPointerDepInternal(Value *Pointer, uint64_t PointeeSize, } // If we computed new values, re-sort Cache. - if (NumSortedEntries == Cache->size()) { + switch (Cache->size()-NumSortedEntries) { + case 0: // done, no new entries. - } else if (NumSortedEntries+1 == Cache->size()) { + break; + case 2: { + // Two new entries, insert the last one into place. + NonLocalDepEntry Val = Cache->back(); + Cache->pop_back(); + NonLocalDepInfo::iterator Entry = + std::upper_bound(Cache->begin(), Cache->end()-1, Val); + Cache->insert(Entry, Val); + // FALL THROUGH. + } + case 1: { // 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 { + break; + } + default: // Added many values, do a full scale sort. std::sort(Cache->begin(), Cache->end()); } |