[all-commits] [llvm/llvm-project] de2fed: [unroll] Keep unrolled iterations with initial ite...

Philip Reames via All-commits all-commits at lists.llvm.org
Fri Nov 12 11:41:32 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: de2fed61528a5584dc54c47f6754408597be24de
      https://github.com/llvm/llvm-project/commit/de2fed61528a5584dc54c47f6754408597be24de
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2021-11-12 (Fri, 12 Nov 2021)

  Changed paths:
    M llvm/lib/Transforms/Utils/LoopUnroll.cpp
    M llvm/test/DebugInfo/unrolled-loop-remainder.ll
    M llvm/test/Transforms/LoopUnroll/2011-08-08-PhiUpdate.ll
    M llvm/test/Transforms/LoopUnroll/2011-08-09-PhiUpdate.ll
    M llvm/test/Transforms/LoopUnroll/AArch64/runtime-unroll-generic.ll
    M llvm/test/Transforms/LoopUnroll/AArch64/thresholdO3-cost-model.ll
    M llvm/test/Transforms/LoopUnroll/AArch64/unroll-upperbound.ll
    M llvm/test/Transforms/LoopUnroll/ARM/loop-unrolling.ll
    M llvm/test/Transforms/LoopUnroll/ARM/multi-blocks.ll
    M llvm/test/Transforms/LoopUnroll/ARM/upperbound.ll
    M llvm/test/Transforms/LoopUnroll/full-unroll-keep-first-exit.ll
    M llvm/test/Transforms/LoopUnroll/full-unroll-one-unpredictable-exit.ll
    M llvm/test/Transforms/LoopUnroll/multiple-exits.ll
    M llvm/test/Transforms/LoopUnroll/nonlatchcondbr.ll
    M llvm/test/Transforms/LoopUnroll/partial-unroll-non-latch-exit.ll
    M llvm/test/Transforms/LoopUnroll/partially-unroll-unconditional-latch.ll
    M llvm/test/Transforms/LoopUnroll/runtime-loop-at-most-two-exits.ll
    M llvm/test/Transforms/LoopUnroll/runtime-loop-multiexit-dom-verify.ll
    M llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
    M llvm/test/Transforms/LoopUnroll/runtime-loop5.ll
    M llvm/test/Transforms/LoopUnroll/runtime-multiexit-heuristic.ll
    M llvm/test/Transforms/LoopUnroll/runtime-small-upperbound.ll
    M llvm/test/Transforms/LoopUnroll/runtime-unroll-remainder.ll
    M llvm/test/Transforms/LoopUnroll/scevunroll.ll
    M llvm/test/Transforms/LoopUnroll/shifted-tripcount.ll
    M llvm/test/Transforms/LoopUnroll/unroll-header-exiting-with-phis-multiple-exiting-blocks.ll
    M llvm/test/Transforms/LoopUnroll/unroll-unconditional-latch.ll
    M llvm/test/Transforms/LoopUnrollAndJam/unroll-and-jam.ll
    M llvm/test/Transforms/PhaseOrdering/AArch64/matrix-extract-insert.ll

  Log Message:
  -----------
  [unroll] Keep unrolled iterations with initial iteration

The unrolling code was previously inserting new cloned blocks at the end of the function.  The result of this with typical loop structures is that the new iterations are placed far from the initial iteration.

With unrolling, the general assumption is that the a) the loop is reasonable hot, and b) the first Count-1 copies of the loop are rarely (if ever) loop exiting.  As such, placing Count-1 copies out of line is a fairly poor code placement choice.  We'd much rather fall through into the hot (non-exiting) path.  For code with branch profiles, later layout would fix this, but this may have a positive impact on non-PGO compiled code.

However, the real motivation for this change isn't performance.  Its readability and human understanding.  Having to jump around long distances in an IR file to trace an unrolled loop structure is error prone and tedious.




More information about the All-commits mailing list