[PATCH] D11662: Filter cold blocks off the loop chain when profile data is available.

Cong Hou congh at google.com
Thu Jul 30 14:14:58 PDT 2015


congh created this revision.
congh added reviewers: chandlerc, dexonsmith.
congh added subscribers: llvm-commits, davidxl.

In the current BB placement algorithm, a loop chain always contains all loop blocks. This has a drawback that cold blocks in the loop may be inserted on a hot function path, hence increasing branch cost and also reducing icache locality.

Consider a simple example shown below:


```
A
|
B⇆C
|
D
```

When B->C is quite cold, the best BB-layout should be A,B,D,C. But the current implementation produces A,C,B,D.

This patch filters those cold blocks off from the loop chain by comparing the ratio:

LoopBBFreq / LoopFreq

to 20%: if it is less than 20%, we don't include this BB to the loop chain. Here LoopFreq is the frequency of the loop when we reduce the loop into a single node. In general we have more cold blocks when the loop has few iterations. And vice versa.


http://reviews.llvm.org/D11662

Files:
  lib/CodeGen/MachineBlockPlacement.cpp
  test/CodeGen/X86/code_placement_cold_loop_blocks.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11662.31073.patch
Type: text/x-patch
Size: 4407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150730/adf2acee/attachment.bin>


More information about the llvm-commits mailing list