This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RFC: adjusting spill preferences


In reload1.c:order_regs_for_reload() we calculate the cost of each
register so that we can select which ones are used for spills.
However, the calculations do not in any way account for the cost of
each use of each register.

For the m32c port, there are registers in the chip and registers in
memory.  The memory ones are more expensive.  I've done all I can with
constraint preferences, but it doesn't always work out because of the
composite classes that reload needs (like A_REGS | MEM_REGS =
A_MEM_REGS) so reload ends up using the expensive registers.  For
--mcpu=m32c, most on-chip registers need to be saved if they're used,
but the memory ones don't, which further complicates the cost logic.

What I'd like to do is add a target hook that's called at the end of
order_regs_for_reload, passing either spill_cost itself or calling it
once for each hard reg to obtain extra costs to add in (multiply by?).
In my case, simply incrementing the cost by one is sufficient to
prefer cpu regs over mem regs in simple tests.

Suggestions?  Comments?  Objections?  Is there some other existing
cost metric I could use here?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]