[Bug target/64833] [SH]: Error: pcrel too far when compiling imagemagick and graphicsmagick on Debian sh4

olegendo at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jun 30 02:37:00 GMT 2015


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

--- Comment #17 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Kazumoto Kojima from comment #15)
> sh_reorg calls shorten_branches after the loop which includes
> find_barrier call and get_attr_length will return correct value
> after that.

I see.  If I understand correctly, the computed and cached values in final.c
will not be used by anything else in this case and shorten_branches is always
invoked afterwards.  Now I understand the patch in c#12, thanks.

> > Wouldn't it be easier/safer to just set the length of casesi_worker_1 to "8"?
> 
> It may be safest from the computational viewpoint, though it'll
> affect almost existing pic codes, I'm afraid.  Perhaps it's OK
> for trunk.  The above patch won't affect existing code except
> very limited cases, though it's a bit tricky.

Increasing insn lengths unnecessarily might result in some unlucky constant
pool placements and far branches and some code might get worse.  On the other
hand, constant pool placement and far branch code generation is "a matter of
luck" anyway.  Reading through the sh_reorg code, there are already some
"CODE_FOR_casesi_worker_2" ifs and elses.  Adding one more special case as in
c#12 seems to fit in the picture nicely :)
However, I think the comment in c#12 should be expanded a bit ...

/* get_attr_length returns cached insn lengths which are computed
   once in shorten_branches.  When here, fixup_mova might have replaced
   the insn pattern casesi_worker_1 with casesi_worker_2 and the cached
   insn length will be wrong.  In this case, get the uncached length
   value directly from the insn attribute.  */



More information about the Gcc-bugs mailing list