On 10/18/2016 05:31 AM, Maxim Kuvyrkov wrote:
>> > I see your point and agree that current code isn't optimal. However, I
>> > don't think your patch is accurate either. Consider
>> > https://gcc.gnu.org/onlinedocs/gccint/Register-Basics.html and let's
>> > assume that FIXED_REGISTERS in class CL is set for a third of the
>> > registers, and CALL_USED_REGISTERS is set to "1" for another third of
>> > registers. So we have a third available for zero-cost allocation
>> > (CALL_USED_REGISTERS-FIXED_REGISTERS), a third available for spill-cost
>> > allocation (ALL_REGISTERS-CALL_USED_REGISTERS) and a third non-available
>> > (FIXED_REGISTERS).
>> > For a non-loop-single-basic-block function we should be targeting only the
>> > third of register available at zero-cost -- correct?
This is what is done by the current code, but, apparently, by accident. It
seems that the right register count can be obtained with:
>> > for (int i = 0; i < ira_class_hard_regs_num[cl]; ++i)
>> > - if (call_used_regs[ira_class_hard_regs[cl][i]])
>> > - ++call_used_regs_num[cl];
>> > + if (!call_used_regs[ira_class_hard_regs[cl][i]]
>> > + || fixed_regs[ira_class_hard_regs[cl][i]])
>> > + ++call_saved_regs_num[cl];
>> > Does this look correct to you?
> Thinking some more, it seems like fixed_regs should not be available to the
> scheduler no matter what. Therefore, the number of fixed registers should be
> subtracted from ira_class_hard_regs_num[cl] without any scaling (entry_freq /
Ahh, yes, I forgot about FIXED_REGISTERS being included in CALL_USED_REGISTERS.
I agree they should be totally removed from the register limit calculation.
I'll rework the patch.