Fix (work around) LRA infinite loop, PR78911

Vladimir Makarov
Fri Mar 3 16:57:00 GMT 2017

On 03/03/2017 08:36 AM, Bernd Schmidt wrote:
> Reload is designed in a way to avoid cycles and to process all reloads 
> for an insn in order of ascending class so as to avoid this kind of 
> issue. With LRA I'm really not sure how to fix this properly, but the 
> following patch seems to cure the PR at least, by recognizing when 
> we're about to spill a reload reg whose assigned class contains only 
> contains a single register.
I had conversations with several people who worked on different RAs and 
got a conclusion that looping is a pretty general problem in iterative 
classical RAs.  Unfortunately, it is not discussed in a literature and 
ad-hoc approaches are used (that is why it is probably not discussed in 
scientific literature).

On first stages of LRA development, looping was a very frequent bug and 
also add-hoc approaches were used to fix it.  The major way is to 
predict that given decision can result in repeating patterns and to 
avoid such decision (e.g. lra_constraints.c::process_alt_operands 
contains code).

Reasons for looping can have different nature and now I have no 
systematic solution on my mind to avoid all of them.
> Bootstrapped and tested on x86_64-linux, ok?
Yes.  Thank you for working on this, Bernd.  The issue mentioned in 
FIXME part of the comment can be addressed later if we have cases for 
which your fix will be not enough.

More information about the Gcc-patches mailing list