[PATCH] D114039: [runtime-unroll] Prune early exits when unrolling multiple exit loops

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 16 15:54:37 PST 2021


reames created this revision.
reames added reviewers: nikic, fhahn, lebedev.ri, mkazantsev.
Herald added subscribers: javed.absar, zzheng, bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

When we unroll a multiple exit loop, we can chose to pick our split point such that we know *all* the exits (not just latch) become dead on Count-1 iterations of the unrolled loop.   Doing this trades a bit more upfront cost (e.g. computing the whole trip count expression) for reduced code size and runtime cost in the main loop.

Reviewers, while the purpose of this patch is sound, I really really dislike the structure of it.  I've spent a bunch of time trying to message SCEV into eliminating the checks while only changing the loop entry condition (i.e. the split point), but all of my attempts have failed.  Suggestions on how to structure this more cleanly are very very welcome.

FYI, this patch only includes the epilogue case.  If we move forward with this structure, I'll post a following review to do the same thing when unrolling with a prolog.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114039

Files:
  llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
  llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114039.387777.patch
Type: text/x-patch
Size: 26849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211116/8fe4836c/attachment.bin>


More information about the llvm-commits mailing list