[PATCH] D93716: [LoopDeletion] Also consider loops with subloops for deletion.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 22 10:28:45 PST 2020


fhahn created this revision.
fhahn added reviewers: reames, jdoerfert, efriedma.
Herald added subscribers: javed.absar, hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.

Currently, LoopDeletion does skip loops that have sub-loops, but this
means we currently fail to remove some no-op loops.

One example are inner loops with live-out values. Those cannot be
removed by itself. But the containing loop may itself be a no-op and the
whole loop-nest can be deleted.

The legality checks do not seem to rely on analyzing inner-loops only
for correctness.

With LoopDeletion being a LoopPass, the change means that we now
unfortunately need to do some extra work in parent loops, by checking
some conditions we already checked. But there appears to be no
noticeable compile time impact:
http://llvm-compile-time-tracker.com/compare.php?from=02d11f3cda2ab5b8bf4fc02639fd1f4b8c45963e&to=843201e9cf3b6871e18c52aede5897a22994c36c&stat=instructions

This changes patch leads to ~10 more loops being deleted on
MultiSource, SPEC2000, SPEC2006 with -O3 & LTO

This patch is also required (together with a few others) to eliminate a
no-op loop in omnetpp as discussed on llvm-dev 'LoopDeletion / removal of
empty loops.' (http://lists.llvm.org/pipermail/llvm-dev/2020-December/147462.html)

This change becomes relevant after removing potentially infinite loops
is made possible in 'must-progress' loops (D86844 <https://reviews.llvm.org/D86844>).

Note that I added a function call with side-effects to an outer loop in
`llvm/test/Transforms/LoopDeletion/update-scev.ll` to preserve the
original spirit of the test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93716

Files:
  llvm/lib/Transforms/Scalar/LoopDeletion.cpp
  llvm/test/Transforms/LoopDeletion/noop-loops-with-subloops.ll
  llvm/test/Transforms/LoopDeletion/unreachable-loops.ll
  llvm/test/Transforms/LoopDeletion/update-scev.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93716.313387.patch
Type: text/x-patch
Size: 4716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201222/f56bc0f0/attachment.bin>


More information about the llvm-commits mailing list