[all-commits] [llvm/llvm-project] db4574: [LoopUnroll] Separate peeling from unrolling

Nikita Popov via All-commits all-commits at lists.llvm.org
Sat Jun 5 01:32:19 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: db45746821ab01a54f8df033991c3280c4284e3b
      https://github.com/llvm/llvm-project/commit/db45746821ab01a54f8df033991c3280c4284e3b
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-06-05 (Sat, 05 Jun 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/UnrollLoop.h
    M llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
    M llvm/lib/Transforms/Utils/LoopUnroll.cpp
    M llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
    A llvm/test/Transforms/LoopUnroll/peel-loop-and-unroll.ll
    M llvm/test/Transforms/LoopUnroll/pr33437.ll
    M llvm/test/Transforms/LoopUnroll/pr45939-peel-count-and-complete-unroll.ll
    M llvm/test/Transforms/LoopUnroll/wrong_assert_in_peeling.ll

  Log Message:
  -----------
  [LoopUnroll] Separate peeling from unrolling

Loop peeling is currently performed as part of UnrollLoop().
Outside test scenarios, it is always performed with an unroll
count of 1. This means that unrolling doesn't actually do anything
apart from performing post-unroll simplification.

When testing, it's currently possible to specify both an explicit
peel count and an explicit unroll count. This doesn't perform any
sensible operation and may result in miscompiles, see
https://bugs.llvm.org/show_bug.cgi?id=45939.

This patch moves peeling from UnrollLoop() into tryToUnrollLoop(),
so that peeling does not also perform a susequent unroll. We only
run the post-unroll simplifications. Specifying both an explicit
peel count and unroll count is forbidden.

In the future, we may want to support both (non-PGO) peeling a
loop and unrolling it, but this needs to be done by first performing
the peel and then recalculating unrolling heuristics on a now
possibly analyzable loop.

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




More information about the All-commits mailing list