[PATCH] D116496: [unroll] Prune all but first copy of invariant exit

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 2 09:39:11 PST 2022


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

If we have an exit which is controlled by a loop invariant condition and which dominates the latch, we know only the copy in the first unrolled iteration can be taken.  All other copies are dead.

The change itself is pretty straight forward, but let me add two points of context:

- I'd have expected other transform passes to catch this after unrolling, but I'm seeing multiple examples where we get to the end of O2 <https://reviews.llvm.org/owners/package/2/>/O3 <https://reviews.llvm.org/owners/package/3/> without simplifying.
- I'd like to do a stronger change which did CSE during unroll and accounted for invariant expressions (as defined by SCEV instead of trivial ones from LoopInfo), but that doesn't fit cleanly into the current code structure.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116496

Files:
  llvm/lib/Transforms/Utils/LoopUnroll.cpp
  llvm/test/Transforms/LoopUnroll/nonlatchcondbr.ll
  llvm/test/Transforms/LoopUnroll/pr31718.ll
  llvm/test/Transforms/LoopUnroll/runtime-loop-multiexit-dom-verify.ll
  llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
  llvm/test/Transforms/LoopUnroll/scevunroll.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116496.396935.patch
Type: text/x-patch
Size: 120902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220102/a2e7dade/attachment.bin>


More information about the llvm-commits mailing list