summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2016-12-30 22:09:10 +0000
committerPhilip Reames <listmail@philipreames.com>2016-12-30 22:09:10 +0000
commitfdbb05b469648b058dd66cc11793d1f098509554 (patch)
treed828385518e4a8c2b81e2568f822b8d2ef298c6b /llvm/lib/Analysis/LazyValueInfo.cpp
parente7407ba1ef07a6cc4f6456b5787e8237e4a91ccd (diff)
downloadbcm5719-llvm-fdbb05b469648b058dd66cc11793d1f098509554.tar.gz
bcm5719-llvm-fdbb05b469648b058dd66cc11793d1f098509554.zip
[LVI] Remove count/erase idiom in favor of checking result value of erase
Minor compile time win. Avoids an additional O(N) scan in the case where we are removing an element and costs nothing when we aren't. llvm-svn: 290768
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LazyValueInfo.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index cd1f25090d6..4f635523687 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -462,8 +462,7 @@ void LazyValueInfoCache::eraseValue(Value *V) {
SmallVector<AssertingVH<BasicBlock>, 4> ToErase;
for (auto &I : OverDefinedCache) {
SmallPtrSetImpl<Value *> &ValueSet = I.second;
- if (ValueSet.count(V))
- ValueSet.erase(V);
+ ValueSet.erase(V);
if (ValueSet.empty())
ToErase.push_back(I.first);
}
@@ -533,12 +532,9 @@ void LazyValueInfoCache::threadEdgeImpl(BasicBlock *OldSucc,
bool changed = false;
for (Value *V : ValsToClear) {
- // TODO: count and erase can be converted to a find/erase(itr) pattern
- if (!ValueSet.count(V))
+ if (!ValueSet.erase(V))
continue;
- ValueSet.erase(V);
-
// If we removed anything, then we potentially need to update
// blocks successors too.
changed = true;
OpenPOWER on IntegriCloud