[all-commits] [llvm/llvm-project] cd0ba9: [LoopPeel] Peel if it turns invariant loads derefe...

Florian Hahn via All-commits all-commits at lists.llvm.org
Tue Oct 12 03:42:59 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cd0ba9dc58c5806f4e3cc9635ab1f64af6973a83
      https://github.com/llvm/llvm-project/commit/cd0ba9dc58c5806f4e3cc9635ab1f64af6973a83
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2021-10-12 (Tue, 12 Oct 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/Utils/LoopPeel.h
    M llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
    M llvm/lib/Transforms/Utils/LoopPeel.cpp
    M llvm/test/Transforms/LoopUnroll/peel-to-turn-invariant-accesses-dereferenceable.ll
    M llvm/test/Transforms/PhaseOrdering/AArch64/peel-multiple-unreachable-exits-for-vectorization.ll

  Log Message:
  -----------
  [LoopPeel] Peel if it turns invariant loads dereferenceable.

This patch adds a new cost heuristic that allows peeling a single
iteration off read-only loops, if the loop contains a load that

    1. is feeding an exit condition,
    2. dominates the latch,
    3. is not already known to be dereferenceable,
    4. and has a loop invariant address.

If all non-latch exits are terminated with unreachable, such loads
in the loop are guaranteed to be dereferenceable after peeling,
enabling hoisting/CSE'ing them.

This enables vectorization of loops with certain runtime-checks, like
multiple calls to `std::vector::at` if the vector is passed as pointer.

Reviewed By: mkazantsev

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




More information about the All-commits mailing list