[all-commits] [llvm/llvm-project] b30c9c: LoopUnrollRuntime: Add weights to all branches

Matthias Braun via All-commits all-commits at lists.llvm.org
Mon Sep 11 14:26:02 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b30c9c937802a78ef986cb4219eba51148f76e6c
      https://github.com/llvm/llvm-project/commit/b30c9c937802a78ef986cb4219eba51148f76e6c
  Author: Matthias Braun <matze at braunis.de>
  Date:   2023-09-11 (Mon, 11 Sep 2023)

  Changed paths:
    M llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp
    M llvm/test/Transforms/LoopUnroll/runtime-exit-phi-scev-invalidation.ll
    M llvm/test/Transforms/LoopUnroll/runtime-loop-branchweight.ll
    M llvm/test/Transforms/LoopUnroll/runtime-loop.ll
    M llvm/test/Transforms/LoopUnroll/unroll-heuristics-pgo.ll

  Log Message:
  -----------
  LoopUnrollRuntime: Add weights to all branches

Make sure every conditional branch constructed by `LoopUnrollRuntime`
code sets branch weights.

- Add new 1:127 weights for the conditional jumps checking whether the
  whole (unrolled) loop should be skipped in the generated prolog or
  epilog code.
- Remove `updateLatchBranchWeightsForRemainderLoop` function and just
  add weights immediately when constructing the relevant branches. This
  leads to simpler code and makes the code more obvious as every call
  to `CreateCondBr` now has a `BranchWeights` parameter.
- Rework formula for epilogue latch weights, to assume equal
  distribution of remainders and remove `assert` (as I was able to
  reach this code when forcing small unroll factors on the commandline).

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




More information about the All-commits mailing list