From 2737362e7a94a85c959d9e50877ea3efb83927c6 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Mon, 20 Apr 2020 16:03:21 +0100 Subject: [PATCH] [VectorUtils] Use early_inc_range instead of DelSet (NFC). 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 --- llvm/lib/Analysis/VectorUtils.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/llvm/lib/Analysis/VectorUtils.cpp b/llvm/lib/Analysis/VectorUtils.cpp index 7cbcb17..377a094 100644 --- a/llvm/lib/Analysis/VectorUtils.cpp +++ b/llvm/lib/Analysis/VectorUtils.cpp @@ -1236,24 +1236,23 @@ void InterleavedAccessInfo::invalidateGroupsRequiringScalarEpilogue() { if (!requiresScalarEpilogue()) return; - // Avoid releasing a Group twice. - SmallPtrSet *, 4> DelSet; - for (auto &I : InterleaveGroupMap) { - InterleaveGroup *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; } -- 2.7.4