[PATCH] D64553: [LoopUtils] Extend the scope of getLoopEstimatedTripCount

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 04:01:40 PDT 2019


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/LoopUtils.cpp:624
 Optional<unsigned> llvm::getLoopEstimatedTripCount(Loop *L) {
-  // Only support loops with a unique exiting block, and a latch.
-  if (!L->getExitingBlock())
-    return None;
+  // Support loops with an exiting latch and other existing exists only
+  // deoptimize.
----------------
Would it make sense to remove the restriction of having a single exit block/only deopt non latch exit by generalizing the function?

Wouldn't' it be reasonable to estimate the trip count by summing up the weights of all exit edges and dividing by the weight of the back-edge to the header? That should naturally cover the deopt cases as well, as they should have very low weights, right?

In any case, we should also update the doc-comment in the header describing the new behavior.


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

https://reviews.llvm.org/D64553





More information about the llvm-commits mailing list