https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128546

--- Comment #5 from Bernie Innocenti <bernie at codewiz dot org> ---
Attached v2 of the patch, against trunk. It is what the AmigaPorts m68k-amigaos
fork merged after review. The only change from the first candidate is the
limit: LRA_MAX_SPLITS is 20 instead of 30, and a compile-time check keeps it
below LRA_MAX_ASSIGNMENT_ITERATION_NUMBER.

With 30, a compiler built with checking enabled still stopped first, on the
code this was reduced from, with the internal error in lra_assign():

    maximum number of LRA assignment passes is achieved (30)

With 20 it reports the usual "unable to find a register to spill" with and
without checking.

The reviewer of the fork's version (midwan) raised two points that the
patch does not address, and that a fix for trunk may want to:

1. splits_num counts every split, including the ones that make progress,
   and it is reset for each constraint sub-pass. Valid code that needs more
   than 20 productive splits in one sub-pass would now get the spill error
   instead of compiling. We have no such testcase. Counting only the rounds
   in which the set of failed reload pseudos does not shrink would still
   stop this loop without that risk.

2. The compile-time check against LRA_MAX_ASSIGNMENT_ITERATION_NUMBER covers
   one sub-pass. lra_assignment_iter_after_spill is reset only after
   lra_spill(), so with checking enabled, two sub-passes in one outer
   iteration could still add up to more than 30 assignment passes. We have
   not seen it happen.

Reply via email to