Dave Korn wrote:
Albert Cohen wrote:
Unfortunately, the state of the art (more recent that the thesis
referenced in the original email, see Touati's web page) is limited to
basic block and software-pipelining scopes, and limited to scheduling.
Compared to the tasks currently managed by reload, it certainly misses a
whole bunch of instruction selection and immediate operand/address mode
corner case problems (depending on the target). It also misses global
scheduling, but extended BB scheduling is not very hard to approximate,
as well as superblock scheduling.
I'm not at all a knowledgeable person to tell you what to do in the case
of GCC, but for sure saturation/sufficiency-based approches are not
sufficient to kill the dragon.
In a brief exchange I had with Michael off-list, we discussed that. I
observed that of the things that reload does,
constraint-satisfaction/insn-variant-selection is its primary purpose, and
spill/reload code generation is something it often does suboptimally (and
secondary reloads even worse). If a clever pass running before reload could
insert explicit spill/reload code at well-chosen places (bearing in mind
class-based register pressure), it could relieve reload of the necessity to
generate its own spill code most of the time, and let it just do what it does
best.
IRA actually already inserts spill code in most important places (on
loop borders). Besides loop regions, IRA could be extended to other
regions (and even bb parts to relief pressure inside the blocks). I am
going to work on it to evaluate how much it could give.
Most spill/restore code at least for x86 is generated by reload because
one insn operand should be a register. Some cooperation of IRA and
reload on this issue, I hope, has a potential to improve code
performance more.
So, yes, it doesn't kill the dragon, reload would need to be retained
and would still need the last-resort ability to do all the stuff it does now -
but mostly it wouldn't have to in practice, and a sleeping dragon is still an
improvement on a wide-awake one that's stomping round in a furious bad temper
burning everything in sight.... Reload would definitely generate better code
if it was fed stuff that avoided exercising its weakest points; sounds like a
pre-conditioning pass based on your techniques might work really well.