[PATCH] D102982: [LoopUnroll] Use smallest exact trip count from any exit

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 23 03:48:24 PDT 2021


nikic created this revision.
nikic added reviewers: fhahn, reames, Meinersbur, mkazantsev.
Herald added subscribers: javed.absar, zzheng, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a more general alternative/extension to D102635 <https://reviews.llvm.org/D102635>. Rather than handling the special case of "header exit with non-exiting latch", this unrolls against the smallest constant exact trip count from any (latch-dominating) exit, regardless of whether the latch is also exiting or not.

Some care needs to be taken that if we unroll against an early exit, the latch exit should not get simplified.

The motivating case is in full-unroll-non-latch-exit.ll. Here the header exit is an IV-based exit, while the latch exit is a data comparison. This kind of loop does not get rotated, because the latch is already exiting, and loop rotation doesn't try to distinguish between IV-based/SCEV-able latches.

I believe that unrolling should be treating this kind of loop the same regardless of whether the IV-based comparison happens to be on the latch or some other block.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102982

Files:
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/test/Transforms/LoopUnroll/full-unroll-non-latch-exit.ll
  llvm/test/Transforms/LoopUnroll/nonlatchcondbr.ll
  llvm/test/Transforms/LoopUnroll/scevunroll.ll
  llvm/test/Transforms/LoopUnroll/unroll-header-exiting-with-phis-multiple-exiting-blocks.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102982.347240.patch
Type: text/x-patch
Size: 23262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210523/fb737234/attachment.bin>


More information about the llvm-commits mailing list