[all-commits] [llvm/llvm-project] 5f10ba: [LoopUnroll] Fix freqs for unconditional latches: ...

Joel E. Denny via All-commits all-commits at lists.llvm.org
Thu Jul 30 12:13:42 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5f10bade30ec9e73f19349df7eb833aae323a2e3
      https://github.com/llvm/llvm-project/commit/5f10bade30ec9e73f19349df7eb833aae323a2e3
  Author: Joel E. Denny <jdenny.ornl at gmail.com>
  Date:   2026-07-30 (Thu, 30 Jul 2026)

  Changed paths:
    M llvm/lib/Transforms/Utils/LoopUnroll.cpp
    M llvm/test/Transforms/LoopUnroll/branch-weights-freq/unroll-complete.ll
    M llvm/test/Transforms/LoopUnroll/branch-weights-freq/unroll-partial-unconditional-latch.ll

  Log Message:
  -----------
  [LoopUnroll] Fix freqs for unconditional latches: N>2, uniform (#182405)

This patch introduces the command-line option `-unroll-uniform-weights`.
When computing probabilities for the remaining N conditional latches in
the unrolled loop after converting some iterations' latches to
unconditional, LoopUnroll now supports the following three strategies:

- A. If N <= 2, use a simple formula to compute a single uniform
  probability across those latches.
- B. Otherwise, if `-unroll-uniform-weights` is not specified, apply the
  original loop's probability to all N latches and then, as needed, adjust
  as few of them as possible.
- C. Otherwise, bisect the range [0,1] to find a single uniform
  probability across all N latches. This patch implements this strategy.

An issue with C is that it could impact compiler performance, so this
patch makes it opt-in. Its appeal over B is that it treats all latches
the same given that we have no evidence showing that any latch should
have a higher or lower probability than any other. A has neither
problem, but I do not know how to apply it for N > 2. More experience or
feedback from others might determine that some strategies are not
worthwhile to maintain.

This patch depends on PR #182404.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list