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

--- Comment #76 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Alexander Klepikov from comment #75)
> I found that patch incorrectly works when '-O0 -fmove-loop-invariants' flags
> are set. Stock loop optimization passes do not run when '-O0' is specified
> desipte '-fmove-loop-invariants' is set. I'll do the same and recheck again.

It'd be good if the newly added passes are ran only with -O2 or higher.  Or
even better, if we can find a way to enable them only when actually needed. 
E.g. when it's splitting a shift insn that will potentially need the loop
optimizations again, set a flag in the function.

One way to do that could be adding SH specific function context class/struct to
store some per-function data for the compilation process.  Right now we'd have
only one entry, that is whether to run the additional passes again or not. 
This per-function 'SH context' can be stored as a global variable in sh.cc. 
Then override 'set_current_function' in the backend to reset the SH specific
per-function context.

However, to get better test coverage, it's better first let the additional loop
passes run all the time to uncover any potential issues.  Later the above can
be added as a supplementary optimization.

Reply via email to