[all-commits] [llvm/llvm-project] 494db3: [LoopDeletion] Also consider loops with subloops f...

Florian Hahn via All-commits all-commits at lists.llvm.org
Wed Jan 6 06:57:30 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 494db3816b0ece5b6722054f75cc2622ae1b840a
      https://github.com/llvm/llvm-project/commit/494db3816b0ece5b6722054f75cc2622ae1b840a
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2021-01-06 (Wed, 06 Jan 2021)

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

  Log Message:
  -----------
  [LoopDeletion] Also consider loops with subloops for deletion.

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).

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.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D93716




More information about the All-commits mailing list