[PATCH] D83187: [LoopUnroll] Update branch weight for remainder loop

Alina Sbirlea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 10:55:10 PDT 2020


asbirlea accepted this revision.
asbirlea added a comment.
This revision is now accepted and ready to land.

lgtm with 2 nits to clarify/fix.



================
Comment at: llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp:521
+                              : TrueWeight;
+    uint64_t BackEdgeWeight = (UnrollFactor - 1) * ExitWeight;
+    BasicBlock *Header = RemainderLoop->getHeader();
----------------
Nit: not sure if possible: is it correct if `UnrollFactor = 1` to set `BackEdgeWeight = 0`?


================
Comment at: llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp:808
+  if (remainderLoop && !UnrollRemainder) {
+    uint64_t TrueWeight, FalseWeight;
+    if (LatchBR->extractProfMetadata(TrueWeight, FalseWeight)) {
----------------
hoyFB wrote:
> davidxl wrote:
> > It is better to fold this part into the update method too with one additional parameter for unroll factor.
> I ended up passing the original loop into the helper as well.
Nit: remove if braces.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83187/new/

https://reviews.llvm.org/D83187





More information about the llvm-commits mailing list