[LLVMdev] BlockFrequency spill weights
Jakob Stoklund Olesen
stoklund at 2pi.dk
Mon Jun 17 11:03:14 PDT 2013
On Jun 17, 2013, at 10:48 AM, Benjamin Kramer <benny.kra at gmail.com> wrote:
> [Splitting this out from the original thread to reduce noise in it]
>
>
> On 17.06.2013, at 18:43, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:
>> +LiveIntervals::getSpillWeight(bool isDef, bool isUse, BlockFrequency freq) {
>> + return (isDef + isUse) * freq.getFrequency();
>> }
>>
>> This computation can overflow.
>
> Yep, I went down the easy route and converted it to floating point arithmetic. Is that OK here?
Yes, that should be fine.
+LiveIntervals::getSpillWeight(bool isDef, bool isUse, BlockFrequency freq) {
+ float EntryFreq = BlockFrequency::getEntryFrequency();
+ return (isDef + isUse) * (freq.getFrequency() / EntryFreq);
Nitpick: The float division can be constant folded and turned into a multiplication:
const float Scale = 1.0f / getEntryFrequency();
return (isDef + isUse) * (freq.getFrequency() * Scale);
I wouldn’t trust the compiler to do that without -fast-math.
> The attached patch also fixes the regression tests that failed. Mostly minor changes in register allocation. The SPARC one is a bit scary because an instruction now gets moved across inline assembly into a delay slot. Do you know if that is a safe transformation?
That sounds OK. As long as it is safe to move that instruction across the inline asm.
> <block-frequency-spilling.patch>
LGTM
Thanks,
/jakob
More information about the llvm-dev
mailing list