Skip to content

Commit 0d2a1eb

Browse files
nikicAlexisPerry
authored andcommitted
[VectorUtils] Use SmallPtrSet::remove_if() (NFC)
1 parent b4d00bc commit 0d2a1eb

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,17 @@ class InterleavedAccessInfo {
722722

723723
/// Release the group and remove all the relationships.
724724
void releaseGroup(InterleaveGroup<Instruction> *Group) {
725+
InterleaveGroups.erase(Group);
726+
releaseGroupWithoutRemovingFromSet(Group);
727+
}
728+
729+
/// Do everything necessary to release the group, apart from removing it from
730+
/// the InterleaveGroups set.
731+
void releaseGroupWithoutRemovingFromSet(InterleaveGroup<Instruction> *Group) {
725732
for (unsigned i = 0; i < Group->getFactor(); i++)
726733
if (Instruction *Member = Group->getMember(i))
727734
InterleaveGroupMap.erase(Member);
728735

729-
InterleaveGroups.erase(Group);
730736
delete Group;
731737
}
732738

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,20 +1481,19 @@ void InterleavedAccessInfo::invalidateGroupsRequiringScalarEpilogue() {
14811481
if (!requiresScalarEpilogue())
14821482
return;
14831483

1484-
bool ReleasedGroup = false;
14851484
// Release groups requiring scalar epilogues. Note that this also removes them
14861485
// from InterleaveGroups.
1487-
for (auto *Group : make_early_inc_range(InterleaveGroups)) {
1486+
bool ReleasedGroup = InterleaveGroups.remove_if([&](auto *Group) {
14881487
if (!Group->requiresScalarEpilogue())
1489-
continue;
1488+
return false;
14901489
LLVM_DEBUG(
14911490
dbgs()
14921491
<< "LV: Invalidate candidate interleaved group due to gaps that "
14931492
"require a scalar epilogue (not allowed under optsize) and cannot "
14941493
"be masked (not enabled). \n");
1495-
releaseGroup(Group);
1496-
ReleasedGroup = true;
1497-
}
1494+
releaseGroupWithoutRemovingFromSet(Group);
1495+
return true;
1496+
});
14981497
assert(ReleasedGroup && "At least one group must be invalidated, as a "
14991498
"scalar epilogue was required");
15001499
(void)ReleasedGroup;

0 commit comments

Comments
 (0)