[PATCH] D157462: LoopRotate: Add code to update branch weights

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 8 17:23:49 PDT 2023


MatzeB created this revision.
MatzeB added reviewers: wenlei, hoy, paulkirth, davidxl, dnovillo.
Herald added subscribers: modimo, hiraditya, mcrosier.
Herald added a project: All.
MatzeB requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This adds code to the loop rotation transformation to ensure that the computed block execution counts for the loop bodies are the same before and after the transformation. This isn't always true in practice, but I believe this is because of numeric inaccuracies in the BlockFrequency computation.

The invariants this is modeled on and heuristic choice of 0-trip loop amount is explained in a lenghty comment in the new `updateBranchWeights()` function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157462

Files:
  llvm/include/llvm/IR/ProfDataUtils.h
  llvm/lib/IR/ProfDataUtils.cpp
  llvm/lib/Transforms/Utils/LoopRotationUtils.cpp
  llvm/test/Transforms/LoopRotate/update-branch-weights.ll
  llvm/test/Transforms/LoopSimplify/merge-exits.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157462.548405.patch
Type: text/x-patch
Size: 15239 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230809/46d2d232/attachment.bin>


More information about the llvm-commits mailing list