[LVI] Manually hoist computation from loop

Minor compile time win.  Not known to be a hot spot, just something I noticed while reading.

llvm-svn: 290759
This commit is contained in:
Philip Reames 2016-12-30 17:56:47 +00:00
parent 3c5a60329b
commit 1e48efcfc5
1 changed files with 12 additions and 7 deletions

View File

@ -525,23 +525,28 @@ void LazyValueInfoCache::threadEdgeImpl(BasicBlock *OldSucc,
// Skip blocks only accessible through NewSucc.
if (ToUpdate == NewSucc) continue;
// If a value was marked overdefined in OldSucc, and is here too...
auto OI = OverDefinedCache.find(ToUpdate);
if (OI == OverDefinedCache.end())
continue;
SmallPtrSetImpl<Value *> &ValueSet = OI->second;
bool changed = false;
for (Value *V : ValsToClear) {
// If a value was marked overdefined in OldSucc, and is here too...
auto OI = OverDefinedCache.find(ToUpdate);
if (OI == OverDefinedCache.end())
continue;
SmallPtrSetImpl<Value *> &ValueSet = OI->second;
// TODO: count and erase can be converted to a find/erase(itr) pattern
if (!ValueSet.count(V))
continue;
ValueSet.erase(V);
if (ValueSet.empty())
OverDefinedCache.erase(OI);
// If we removed anything, then we potentially need to update
// blocks successors too.
changed = true;
if (ValueSet.empty()) {
OverDefinedCache.erase(OI);
break;
}
}
if (!changed) continue;