[PATCH] D103026: [LoopUnroll] Explicitly specify exit to unroll against (NFCI)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 24 07:13:20 PDT 2021


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

Loop unrolling is usually performed against an exit for which additional information is known, such as a trip count, trip multiple or runtime-enforced trip multiple. This exit receives special treatment, because it can be folded on some or all iterations.

Currently, this exit is not explicitly provided to the unrolling implementation. Instead it assumes that this must be either the unique exit, or the latch exit. For D102635 <https://reviews.llvm.org/D102635> (where the latch is non-exiting) this results in missed folding opportunities, because unrolling doesn't know which exit the trip count refers to. For D102982 <https://reviews.llvm.org/D102982> (where the latch can be exiting) it results in miscompiles, because it assumes the wrong exit.

This patch addresses the problem by explicitly providing the ExitingBlock to unrolling. Currently, this shouldn't have any effect, but would have an effect in conjunction with D102635 <https://reviews.llvm.org/D102635>/D102982 <https://reviews.llvm.org/D102982>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103026

Files:
  llvm/include/llvm/Transforms/Utils/UnrollLoop.h
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/LoopUnroll.cpp
  llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103026.347381.patch
Type: text/x-patch
Size: 8236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210524/64817289/attachment.bin>


More information about the llvm-commits mailing list