[PATCH] D103620: [LoopUnroll] Eliminate PreserveCondBr parameter and fix a bug in the process

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 3 08:21:06 PDT 2021


reames created this revision.
reames added a reviewer: nikic.
Herald added subscribers: zzheng, bollu, hiraditya, mcrosier.
reames requested review of this revision.
Herald added a project: LLVM.

This builds on D103584 <https://reviews.llvm.org/D103584>.  The change eliminates the coupling between unroll heuristic and implementation w.r.t. knowing when the passed in trip count is an exact trip count or a max trip count.  In theory the new code is slightly less powerful (since it relies on exact computable trip counts), but in practice, it appears to cover all the same cases.  It can also be extended if needed.

The test change shows what appears to be a bug in the existing code around the interaction of peeling and unrolling.  The original loop only ran 8 iterations.  The previous output had the loop peeled by 2, and then an exact unroll of 8.  This meant the loop ran a total of 10 iterations which appears to have been a miscompile.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103620

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
  llvm/test/Transforms/LoopUnroll/pr45939-peel-count-and-complete-unroll.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103620.349555.patch
Type: text/x-patch
Size: 15756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210603/92b2b53f/attachment.bin>


More information about the llvm-commits mailing list