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

Joel E. Denny via All-commits all-commits at lists.llvm.org
Thu Feb 19 15:38:57 PST 2026


  Branch: refs/heads/users/jdenny-ornl/fix-blockfreq-unroll-unconditional-latches--uniform
  Home:   https://github.com/llvm/llvm-project
  Commit: d3054a4e08388bda0bb58a0557b871dd6c6cb9df
      https://github.com/llvm/llvm-project/commit/d3054a4e08388bda0bb58a0557b871dd6c6cb9df
  Author: Joel E. Denny <jdenny.ornl at gmail.com>
  Date:   2026-02-19 (Thu, 19 Feb 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

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.



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