[PATCH] D131827: [LoopSimplify][NFC] Replace depth-first order process as depth_first accessor.

luxufan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 12 21:43:13 PDT 2022


StephenFan created this revision.
StephenFan added reviewers: dmgreen, reames.
Herald added a subscriber: hiraditya.
Herald added a project: All.
StephenFan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131827

Files:
  llvm/lib/Transforms/Utils/LoopSimplify.cpp


Index: llvm/lib/Transforms/Utils/LoopSimplify.cpp
===================================================================
--- llvm/lib/Transforms/Utils/LoopSimplify.cpp
+++ llvm/lib/Transforms/Utils/LoopSimplify.cpp
@@ -728,15 +728,8 @@
 
   // Worklist maintains our depth-first queue of loops in this nest to process.
   SmallVector<Loop *, 4> Worklist;
-  Worklist.push_back(L);
-
-  // Walk the worklist from front to back, pushing newly found sub loops onto
-  // the back. This will let us process loops from back to front in depth-first
-  // order. We can use this simple process because loops form a tree.
-  for (unsigned Idx = 0; Idx != Worklist.size(); ++Idx) {
-    Loop *L2 = Worklist[Idx];
-    Worklist.append(L2->begin(), L2->end());
-  }
+  for_each(depth_first(L),
+           [&Worklist](Loop *SubLoop) { Worklist.push_back(SubLoop); });
 
   while (!Worklist.empty())
     Changed |= simplifyOneLoop(Worklist.pop_back_val(), Worklist, DT, LI, SE,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131827.452376.patch
Type: text/x-patch
Size: 964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220813/26af234b/attachment.bin>


More information about the llvm-commits mailing list