https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212
--- Comment #164 from Kazumoto Kojima <kkojima at gcc dot gnu.org> --- (In reply to Oleg Endo from comment #162) > (In reply to Kazumoto Kojima from comment #153) > > Created attachment 58886 [details] > > a revised patch for c#135 and c#139 > > > > (In reply to Oleg Endo from comment #139) > > > > If we try to keep the old behavior with -mno-lra as possible, it means that > > when we define new patterns with R0-clobber, they should be guarded with > > sh_lra_p() rigidly and the old patterns should be kept. > > The patch adds these guards to the new patterns in c#135 and fixes the > > testcase 58859. > > I'm not in favor of the R0-clobber approach, to be honest. I think we would > need to add it to the other R0-restricted insns as well. I'm also afraid of > code quality getting worse if we add all those R0-clobbers everywhere. With > LRA we are already getting worse code quality than before, so this will just > make it even worse. > > Then there is the maintenance overhead. So if we use this approach, it's > probably best to make it LRA-only. > > Obviously, the spill failure issues are a problem of LRA. I hope that they > can be addressed adequately by LRA maintainers in time, before forcing > everybody to switch to LRA. > > If this doesn't happen, we could also hide R0 from register allocation and > fix it up using an SH specific RTL post-register-allocation pass to > "optimize the R0 usage". I think this idea has been around for a while, > it's just again quite a bit of work. Agreed. R0 specific pass would be "the Right Thing". It is hard to do right away, though. I've seen the recent argument for an LRA patch which passed the tests on mainstream processors but is causing wrong code on aarch64 and riscv. I guess that RA tends to be "one line change makes the failure on some arch" thing which was warned so for the old reload. Yes, the R0-clobber approach is only workaround for LRA. It should be LRA-only as you pointed out. I don't expect the LRA to improve the code on SH. Only I can try to help -mlra get it into a usable state somehow. And the time I can help may not be not so long.