[PATCH] D32201: [RALLOC] Increase CSR cost in RegAllocGreedy to favour splitting over CSR first use

Wei Mi via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 30 15:52:44 PDT 2017


The rational of the constant has meaning from two sides.

On one side, for a vreg needing CSR registers in a smaller code
region, we hope it can be split so CSR registers are only used in the
smaller code region and shrinkwrapping is easier to kick in. It
requires CSR cost to be larger so as split for CSR can happen for more
such kind of vregs.

On the other side, we hope the cost of the copies generated by CSR
split to be small, at least, less than func entry frequency. CSR split
only happens when the split cost is lower than CSR cost. That is why
we hope the CSR cost to be as low as possible.

To balance the two sides, I choosed the CSR cost to be 1<<12 in the
end (The patch uses 1<<13 but I found 1<<12 slightly better). That is
1/4 of the func entry frequency (func entry frequency is 1<<14 in ).
Internal testing shows the constant is a good trade off.

Thanks,
Wei.


On Fri, Jun 30, 2017 at 2:24 PM, Quentin Colombet via Phabricator
<reviews at reviews.llvm.org> wrote:
> qcolombet added a comment.
>
> To be concrete here. I'd like to understand why we can have the regalloc to figure out what is the cost of splitting a CSR the first time (which is what it boils down to).
>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D32201
>
>
>


More information about the llvm-commits mailing list