[PATCH] D124764: [NFC][GVNSink] Don't pretend that iteration is over instructions when it's actually over blocks

Dawid Jurczak via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 08:21:04 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c46a9cf611f: [NFC][GVNSink] Don't pretend that iteration is over instructions when it's… (authored by yurai007).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124764/new/

https://reviews.llvm.org/D124764

Files:
  llvm/lib/Transforms/Scalar/GVNSink.cpp


Index: llvm/lib/Transforms/Scalar/GVNSink.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -774,12 +774,9 @@
 
   unsigned NumOrigPreds = Preds.size();
   // We can only sink instructions through unconditional branches.
-  for (auto I = Preds.begin(); I != Preds.end();) {
-    if ((*I)->getTerminator()->getNumSuccessors() != 1)
-      I = Preds.erase(I);
-    else
-      ++I;
-  }
+  llvm::erase_if(Preds, [](BasicBlock *BB) {
+    return BB->getTerminator()->getNumSuccessors() != 1;
+  });
 
   LockstepReverseIterator LRI(Preds);
   SmallVector<SinkingInstructionCandidate, 4> Candidates;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124764.426722.patch
Type: text/x-patch
Size: 707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220503/beda3520/attachment.bin>


More information about the llvm-commits mailing list