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

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 15 12:07:11 PDT 2023


wenlei added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/LoopRotationUtils.cpp:302
+      // probabilities as if 0-trip count never happens.
+      ExitCount0 = 0;
+    } else {
----------------
MatzeB wrote:
> wenlei wrote:
> > Heuristic is somewhat arbitrary anyways but I would still keep `ExitCount0` as non-zero, so it's a "live" path to be conservative. Also BFI doesn't like zero edge counts is another reason.. 
> I had that in earlier versions, but my experience while writing the tests anyway was that BFI handles zero-count-edges fine and the results just seem more natural and easier to reason about this way. While assigning non-zero immediately felt somewhat murky in what sort of "epsilon" should be used at all...
Problem with BFI often gets exposed with larger CFG that has implicit constraints, so small test case doesn't always show. Is there any specific problem you ran into with having ExitCount0 as 1? 1 should be a reasonable guess too. There are many places where we try to avoid zero when uncertain, which is sort of an unspoken convention.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157462



More information about the llvm-commits mailing list