[PATCH] D78420: [VectorUtils] Use early_inc_range instead of DelSet (NFC).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 18 03:13:22 PDT 2020


fhahn created this revision.
fhahn added reviewers: gilr, rengolin, Ayal, hsaito.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78420

Files:
  llvm/lib/Analysis/VectorUtils.cpp


Index: llvm/lib/Analysis/VectorUtils.cpp
===================================================================
--- llvm/lib/Analysis/VectorUtils.cpp
+++ llvm/lib/Analysis/VectorUtils.cpp
@@ -1236,24 +1236,21 @@
   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;
+  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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78420.258501.patch
Type: text/x-patch
Size: 1360 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200418/f0b5fecd/attachment.bin>


More information about the llvm-commits mailing list