[llvm] r204690 - Register Allocator: check other options before using a CSR for the first time.

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri Apr 4 19:46:47 PDT 2014


On 2014 Mar 24, at 17:16, Manman Ren <manman.ren at gmail.com> wrote:

> Author: mren
> Date: Mon Mar 24 19:16:25 2014
> New Revision: 204690
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=204690&view=rev
> Log:
> Register Allocator: check other options before using a CSR for the first time.
> 
> When register allocator's stage is RS_Spill, we choose spill over using the CSR
> for the first time, if the spill cost is lower than CSRCost. 
> When register allocator's stage is < RS_Split, we choose pre-splitting over
> using the CSR for the first time, if the cost of splitting is lower than
> CSRCost.
> 
> CSRCost is set with command-line option "regalloc-csr-first-time-cost". The
> default value is 0 to generate the same codes as before this commit.
> 
> With a value of 15 (1 << 14 is the entry frequency), I measured performance
> gain of 3% on 253.perlbmk and 1.7% on 197.parser, with instrumented PGO,
> on an arm device.
> 
> rdar://16162005
> 
> Added:
>  llvm/trunk/test/CodeGen/AArch64/ragreedy-csr.ll
> Modified:
>  llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp

Hi Manman,

This commit relies on the entry frequency being 1<<14, but the API
of BlockFrequencyInfo does not guarantee anything about the entry
frequency.  While the current implementation happens to use 1<<14,
the patch I'm working on sets it based on how branchy a particular
function is, which causes this test to fail.

The cost value (e.g., 15) needs to be compared to a ratio between
the actual entry frequency and the block frequency in question.

I'm happy to fix this, but there are a couple of possible directions
and I'm not sure which is best.

 1. Keep the meaning (and name) of CSRCost and
    -regalloc-csr-first-time-cost unchanged.  This requires scaling
    the cost by the ratio of entry frequency to 1<<14.

 2. Chose a different meaning for the metric.  For example, we could
    use a value of 1024 (instead of 15), indicating that anything
    colder than entry/1024 is not worth using callee save registers
    for.  This would require some name changes.

 3. ?

I'm leaning towards option (2), but I'm not sure, and naming might
be tough.  What do you think?

Duncan



More information about the llvm-commits mailing list