[PATCH] D63923: [Loop Peeling] Enable peeling for loops with multiple exits

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 15:02:16 PDT 2019


reames requested changes to this revision.
reames added inline comments.
This revision now requires changes to proceed.


================
Comment at: lib/Transforms/Utils/LoopUnrollPeel.cpp:65
+static cl::opt<bool>
+UnrollPeelMultiExit("unroll-peel-multi-exit", cl::init(true), cl::Hidden,
+                    cl::desc("Allow peeling of loops with multiple exits."));
----------------
Submit disabled, then enable in future commit?

And maybe you want a three way choice: none, deopt-only, all?


================
Comment at: lib/Transforms/Utils/LoopUnrollPeel.cpp:84
+
+    if (ExitEdges.size() > 0) {
+      bool SawLatch = false;
----------------
This looks like a useful helper function which could be factored out and reused, for example by canProfitablyUnrollMultiExitLoop.  

Maybe: bool allNonLatchExitsDeoptimize  or allNonLatchExitsPredicatedNeverTaken?


================
Comment at: lib/Transforms/Utils/LoopUtils.cpp:626
   if (!L->getExitingBlock())
     return None;
+  return getLoopEstimatedTripCountBasingOnLatchOnly(L);
----------------
A suggestion here.  Extend the existing function to allow multiple exits, but only if those exits have 0 taken probability.  Return None for any exit with non-zero exit.  

(I'm trying to avoid the need for the new function.)


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

https://reviews.llvm.org/D63923





More information about the llvm-commits mailing list