[all-commits] [llvm/llvm-project] f6b0a7: [BPI] Cache LoopExitBlocks to improve compile time

Enna1 via All-commits all-commits at lists.llvm.org
Mon May 27 02:42:35 PDT 2024


  Branch: refs/heads/users/Enna1/bpi-cache-loop-exitblocks
  Home:   https://github.com/llvm/llvm-project
  Commit: f6b0a73402493eeecb75145c2e37eeff244b44f3
      https://github.com/llvm/llvm-project/commit/f6b0a73402493eeecb75145c2e37eeff244b44f3
  Author: xumingjie.enna1 <xumingjie.enna1 at bytedance.com>
  Date:   2024-05-27 (Mon, 27 May 2024)

  Changed paths:
    M llvm/include/llvm/Analysis/BranchProbabilityInfo.h
    M llvm/lib/Analysis/BranchProbabilityInfo.cpp

  Log Message:
  -----------
  [BPI] Cache LoopExitBlocks to improve compile time

The `LoopBlock` stored in `LoopWorkList` consist of basic block and its loop
data information. When iterate `LoopWorkList`, if estimated weight of a loop
is not stored in `EstimatedLoopWeight`, `getLoopExitBlocks()` is called to get
all exit blocks of the loop. The estimated weight of a loop is calculated by
iterating over edges leading from basic block to all exit blocks of the loop.
If at least one edge has unknown estimated weight, the estimated weight of loop
is unknown and will not be stored in `EstimatedLoopWeight`.
`LoopWorkList` can contain different blocks in a same loop, so there is
wasted work that calls `getLoopExitBlocks()` for same loop multiple times.

Since computing the exit blocks of loop is expensive and the loop structure is
not mutated in Branch Probability Analysis, we can cache the result and improve
compile time.

With this change, the overall compile time for a file containing a
very large loop is dropped by around 82%.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list