[PATCH] D19049: [BlockFrequencyInfo] Handling nested irreducible CFG with geometric series and top-down prorogation

Yuanfang Chen via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 12 21:23:34 PDT 2016


kula created this revision.
kula added reviewers: dexonsmith, dnovillo.
kula added a subscriber: llvm-commits.

This patch implements the TODOs in BlockFrequencyInfoImpl.h.
1. handle nested irreducible loop.
2. true weight distribution among multi-heads of irreducible loop, instead of even split + adjustment by backedge later.
3. Use geometric series instead of loop scale for mass iteration. loop scale are still used, but for the purpose of scaling down local mass below 1.0.
4. normal code path for reducible loop is not affected.

This patch passes all regression test. Several test cases are changed accordingly. I've changed the @nonentry_header case in irreducible.ll to use
huge weight on the switch instruction to show that 'bottom' block should not be hot.

Method:
1. for loop a, found all SCCs, create SCC loops and adjust nodes in its parent node list accordingly.
2. In topological order, propagate mass on all SCCs where non-trivial SCCs incur resursion.
3. compute start term of geometric series.
4. for each header, compute its ratio of geometric series by propogation full mass starting from itself and other block hass empty mass. The cumulated backege mass is ratio.
5. find the max ratio among headers.
6. compute local scaled down mass for all headers with geometric series equation [a/(1-r)]. assume n is infinity. I've add a TODO in file to see if we should use [a*(1-r^n)/(1-r)].
7. Propagate with header mass to other blocks in loop.

http://reviews.llvm.org/D19049

Files:
  include/llvm/Analysis/BlockFrequencyInfoImpl.h
  lib/Analysis/BlockFrequencyInfoImpl.cpp
  test/Analysis/BlockFrequencyInfo/irreducible.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19049.53516.patch
Type: text/x-patch
Size: 39063 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160413/253b0031/attachment.bin>


More information about the llvm-commits mailing list