[llvm-commits] [llvm] r96613 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/CalcSpillWeights.cpp lib/CodeGen/LiveIntervalAnalysis.cpp test/CodeGen/X86/2008-02-22-ReMatBug.ll test/CodeGen/X86/pr3495-2.ll

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Feb 18 13:54:07 PST 2010


On Feb 18, 2010, at 1:40 PM, Chris Lattner wrote:

> 
> On Feb 18, 2010, at 1:39 PM, Evan Cheng wrote:
> 
>>> 
>>> +    // 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;
>>> +    }
>>> +
>> 
>> Why 25? The new meaning of life? :-)
> 
> Is 25 "scientific"? :)

Yes, 25 is chosen as the square of the number of digits on the human hand. :-)

The normalized weight is calculated as a use density. The +25 makes the calculation more smooth for small intervals - an interval with one instruction doesn't deserve double the weight of one with two instructions. I don't think the exact number is going to make a big difference, but it does happen to work well for one case I cared about.

/jakob





More information about the llvm-commits mailing list