While working on reload-v2, I noticed that we consistently got better
code by attempting to reassign all unallocated pseudos in reload's
callback to ira_reassign_pseudos.
After a discussion with Vlad, we both agreed that the existing code in
ira_reassign_pseudos should already be handling any cases where spilling
a pseudo allows other pseudos to be assigned a hard register. So
clearly further analysis was needed.
What I found was that the two phase nature of ira_reassign_pseudos often
results in poor allocation choices.
ira_reassign_pseudos first attempts to reassign any pseudo which was
spilled to a new hard register. Then ira_reassign_pseudos will try to
assign a hard reg to any pseudo without a hard reg which conflicts with
the spilled pseudos.
The problem with that two phase approach is the reassignment of spilled
pseudos always has priority over assigning conflicting pseudos, even if
the conflicting unallocated pseudos have a higher priority than the
The fix is relatively simple. We merely collect all the spilled pseudos
and unallocated conflicting pseudos and allocate them based on their
priority. The net result is consistently better allocations.
This was bootstrapped and regression tested on i686-pc-linux-gnu. I'm
assuming this is not suitable for stage3 development so I'll attach it
to our meta-bug for gcc-4.6 pending patches.
Description: Text Data