[all-commits] [llvm/llvm-project] 9bd225: [unroll] Prune all but first copy of invariant exit

Philip Reames via All-commits all-commits at lists.llvm.org
Mon Jan 3 09:59:11 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 9bd22595bad36cd19f5e7ae18ccd9f41cba29dc5
      https://github.com/llvm/llvm-project/commit/9bd22595bad36cd19f5e7ae18ccd9f41cba29dc5
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2022-01-03 (Mon, 03 Jan 2022)

  Changed paths:
    M llvm/lib/Transforms/Utils/LoopUnroll.cpp
    M llvm/test/Transforms/LoopUnroll/nonlatchcondbr.ll
    M llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
    M llvm/test/Transforms/LoopUnroll/scevunroll.ll

  Log Message:
  -----------
  [unroll] Prune all but first copy of invariant exit

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/O3 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.

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




More information about the All-commits mailing list