[PATCH] D104203: [LoopUnroll] Fold all exits based on known trip count/multiple

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 16 11:29:15 PDT 2021


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/LoopUnroll.cpp:747
+    if (RuntimeTripCount) {
+      // When runtime unrolling, information about non-latch exits may be
+      // stale.
----------------
nikic wrote:
> reames wrote:
> > This bit doesn't make sense to me, can you explain?
> The runtime loop unrolling code may insert a prologue, in which case the computed trip counts for the original loop may no longer be correct.
I should mention that runtime unrolling is going to need some more work, in particular I think that the decision whether to use a runtime unroll or not should be made by the caller, not this utility. Once that is done, it might make sense to compute the trip count information after doing the runtime unroll transform, in which case we could still use the trip multiple logic below this for the non-latch exits. If we teach SCEV to recognize the trip multiple from the runtime unroll pattern, then we shouldn't need to specially handle runtime unrolling here at all, though I'm not confident that we can detect the trip multiple sufficiently reliably (once folds get involved).

I think that's all followup work though, and the option used here is the conservative one of only folding the latch exit as we did before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104203



More information about the llvm-commits mailing list