https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54089
--- Comment #57 from Oleg Endo <olegendo at gcc dot gnu.org> --- (In reply to Alexander Klepikov from comment #56) > > > In that test you can see the unnecessary push/pop of PR. This is because > > initially it wanted to expand as a library call, but then your patterns > > decided to change the insns. This can or can't be avoided, depending on the > > case. > > That's an valuable observation, thank you! I found why. Sometimes 'collapsed > libcall' instruction is emitted in combine pass and 'clobber PR' is set > then. I commented this out and checked that file and it seems to be OK. I > will rerun testsuite again to be sure. Another thing ... the reason why it's desirable to expand into the libcall earlier is to allow hoisting the function call address outside of loops and things like that. That happens only once at the RTL level during compilation and that's before the combine pass. Since there are no loops around optimization passes in the compiler, it's always going to be a compromise. But it might be OK to repeat a particular optimization pass only for SH, if it helps anything. > > Now regarding tests that fail on vanilla GCC and pass with patch. It looks > like something was changed in the middle of GCC and it started to produce > other instruction patterns that cannot be catched by existing isns and thus > expanded to library calls. The patch simply fixed it. Yes, that happens every now and then, as folks work on target independent optimizations in the middle-end. SH backend hasn't been keeping up for a while in this regard.
