Skip to content

Commit

Permalink
[LVI] Manually hoist computation from loop
Browse files Browse the repository at this point in the history
Minor compile time win.  Not known to be a hot spot, just something I noticed while reading.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290759 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
preames committed Dec 30, 2016
1 parent 65985d0 commit e008300
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/Analysis/LazyValueInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e008300

Please sign in to comment.