[PATCH] D64235: [Loop Peeling] Another way to handle branch weights of peeled off branches

Serguei Katkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 21:57:34 PDT 2019


skatkov created this revision.
skatkov added reviewers: reames, mkuper, iajbar, fhahn.
Herald added subscribers: zzheng, hiraditya.
Herald added a project: LLVM.

This patch introduces another way to set the branch weights to peeled of branches.
Let F is a number of dynamic iteration to go to header from latch.
Let E is a number of dynamic iteration to go to exit from latch.
Estimated TripCount = F / E.
For I-th (counting from 0) peeled off iteration we set the the weights for
the peeled latch as (TC - I, 1). It gives us reasonable distribution.
To avoid dealing with division rounding we can just multiple both part
of weights to E and use weight as (F - I * E, E).

The idea is taken from the review of the patch https://reviews.llvm.org/D63918
proposed by Philip.


https://reviews.llvm.org/D64235

Files:
  llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp
  llvm/test/Transforms/LoopUnroll/peel-loop-pgo.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64235.208117.patch
Type: text/x-patch
Size: 9071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190705/8d3b1072/attachment.bin>


More information about the llvm-commits mailing list