[PATCH] D67905: [LV] Vectorizer should adjust trip count in profile information

Ayal Zaks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 16 23:58:54 PST 2020


Ayal added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/LoopUtils.cpp:775
+      LLVMContext::MD_prof,
+      MDB.createBranchWeights(BackedgeTakenWeight, LatchExitWeight));
+
----------------
ebrevnov wrote:
> Ayal wrote:
> > The last part could call fixupBranchWeights() if moved here from Transforms/Utils/LoopUnrollPeel.cpp
> That would require to change implementation for fixupBranchWeights since it disregards to update when back edge taken count is zero.
> 
Agreed. Regarding disregarding to update when backedge taken weight is zero, note that in `fixupBranchWeights()`, `BackedgeTakenWeight` is called `FallThroughWeight`(?) "The weight of the edge from Latch to Header", and that
  // FallThroughWeight is 0 means that there is no branch weights on original
  // latch block or estimated trip count is zero.

Regarding the first meaning of 0, whoever calls `fixupBranchWeights()` should do so only if there were such weights on the original latch block, similar to the caller of `setLoopEstimatedTripCount()`. Regarding the second meaning of 0, it seem `fixupBranchWeights()` suffers from same +1 issue: estimating trip count to be zero when backedge taken weight is zero.

It would be good to fix and centralize the support for updating weights of loops, but such refactoring can be done  as a separate follow-up patch, after landing this (accepted) patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67905





More information about the llvm-commits mailing list