[PBQP] Tweak spill costs and coalescing benefits
authorArnaud A. de Grandmaison <arnaud.degrandmaison@arm.com>
Tue, 4 Nov 2014 20:51:24 +0000 (20:51 +0000)
committerArnaud A. de Grandmaison <arnaud.degrandmaison@arm.com>
Tue, 4 Nov 2014 20:51:24 +0000 (20:51 +0000)
commit8025a39d11d9308afa42d8e252ef23902fbd142d
tree9d8545b8dc75e29aaee3b7a370d9d6bfa22f43b8
parente2463284fcfdc6c06e7bf06fc259d2db451e0acd
[PBQP] Tweak spill costs and coalescing benefits

This patch improves how the different costs (register, interference, spill
and coalescing) relates together. The assumption is now that:
 - coalescing (or any other "side effect" of reg alloc) is negative, and
   instead of being derived from a spill cost, they use the block
   frequency info.
 - spill costs are in the [MinSpillCost:+inf( range
 - register or interference costs are in [0.0:MinSpillCost( or +inf

The current MinSpillCost is set to 10.0, which is a random value high
enough that the current constraint builders do not need to worry about
when settings costs. It would however be worth adding a normalization
step for register and interference costs as the last step in the
constraint builder chain to ensure they are not greater than SpillMinCost
(unless this has some sense for some architectures). This would work well
with the current builder pipeline, where all costs are tweaked relatively
to each others, but could grow above MinSpillCost if the pipeline is
deep enough.

The current heuristic is tuned to depend rather on the number of uses of
a live interval rather than a density of uses, as used by the greedy
allocator. This heuristic provides a few percent improvement on a number
of benchmarks (eembc, spec, ...) and will definitely need to change once
spill placement is implemented: the current spill placement is really
ineficient, so making the cost proportionnal to the number of use is a
clear win.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221292 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/CodeGen/CalcSpillWeights.h
lib/CodeGen/CalcSpillWeights.cpp
lib/CodeGen/RegAllocGreedy.cpp
lib/CodeGen/RegAllocPBQP.cpp