diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-02-18 21:33:05 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-02-18 21:33:05 +0000 |
commit | 352d352c023ed411d9e4357ea01f3ec468ff87dc (patch) | |
tree | 39c68041361c761a8290d6c452c02ea0dc9366ea /include/llvm/CodeGen/LiveIntervalAnalysis.h | |
parent | 49d7f8d341a7b4137c674ce0f08f5b18e8195f4a (diff) | |
download | external_llvm-352d352c023ed411d9e4357ea01f3ec468ff87dc.zip external_llvm-352d352c023ed411d9e4357ea01f3ec468ff87dc.tar.gz external_llvm-352d352c023ed411d9e4357ea01f3ec468ff87dc.tar.bz2 |
Always normalize spill weights, also for intervals created by spilling.
Moderate the weight given to very small intervals.
The spill weight given to new intervals created when spilling was not
normalized in the same way as the original spill weights calculated by
CalcSpillWeights. That meant that restored registers would tend to hang around
because they had a much higher spill weight that unspilled registers.
This improves the runtime of a few tests by up to 10%, and there are no
significant regressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96613 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/LiveIntervalAnalysis.h')
-rw-r--r-- | include/llvm/CodeGen/LiveIntervalAnalysis.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index d7ff8da..294eb25 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -74,6 +74,14 @@ namespace llvm { return (isDef + isUse) * powf(10.0F, (float)loopDepth); } + // After summing the spill weights of all defs and uses, the final weight + // should be normalized, dividing the weight of the interval by its size. + // This encourages spilling of intervals that are large and have few uses, + // and discourages spilling of small intervals with many uses. + void normalizeSpillWeight(LiveInterval &li) { + li.weight /= getApproximateInstructionCount(li) + 25; + } + typedef Reg2IntervalMap::iterator iterator; typedef Reg2IntervalMap::const_iterator const_iterator; const_iterator begin() const { return r2iMap_.begin(); } @@ -409,6 +417,9 @@ namespace llvm { DenseMap<unsigned,unsigned> &MBBVRegsMap, std::vector<LiveInterval*> &NewLIs); + // Normalize the spill weight of all the intervals in NewLIs. + void normalizeSpillWeights(std::vector<LiveInterval*> &NewLIs); + static LiveInterval* createInterval(unsigned Reg); void printInstrs(raw_ostream &O) const; |