Skip to content

Commit

Permalink
[VectorUtils] Use early_inc_range instead of DelSet (NFC).
Browse files Browse the repository at this point in the history
DelSet was used to avoid invalidating the current iterator while
modifying the map we are iterating over.

By using an early_inc_range, (which increments to iterator 'early',
allowing us to remove the current element), we can get rid of DelSet.

Reviewers: gilr, rengolin, Ayal, hsaito

Reviewed By: Ayal

Differential Revision: https://reviews.llvm.org/D78420
  • Loading branch information
fhahn committed Apr 20, 2020
1 parent ee12edc commit 2737362
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions llvm/lib/Analysis/VectorUtils.cpp
Expand Up @@ -1236,24 +1236,23 @@ void InterleavedAccessInfo::invalidateGroupsRequiringScalarEpilogue() {
if (!requiresScalarEpilogue())
return;

// Avoid releasing a Group twice.
SmallPtrSet<InterleaveGroup<Instruction> *, 4> DelSet;
for (auto &I : InterleaveGroupMap) {
InterleaveGroup<Instruction> *Group = I.second;
if (Group->requiresScalarEpilogue())
DelSet.insert(Group);
}
assert(!DelSet.empty() && "At least one group must be invalidated, as a "
"scalar epilogue was required");
for (auto *Ptr : DelSet) {
bool ReleasedGroup = false;
// Release groups requiring scalar epilogues. Note that this also removes them
// from InterleaveGroups.
for (auto *Group : make_early_inc_range(InterleaveGroups)) {
if (!Group->requiresScalarEpilogue())
continue;
LLVM_DEBUG(
dbgs()
<< "LV: Invalidate candidate interleaved group due to gaps that "
"require a scalar epilogue (not allowed under optsize) and cannot "
"be masked (not enabled). \n");
releaseGroup(Ptr);
releaseGroup(Group);
ReleasedGroup = true;
}

assert(ReleasedGroup && "At least one group must be invalidated, as a "
"scalar epilogue was required");
(void)ReleasedGroup;
RequiresScalarEpilogue = false;
}

Expand Down

0 comments on commit 2737362

Please sign in to comment.