https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61844
--- Comment #10 from Oleg Endo <olegendo at gcc dot gnu.org> --- Created attachment 33197 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33197&action=edit a possible fix (In reply to Kazumoto Kojima from comment #9) > The testcase in #7 can be compiled successfully when -mindexed-addressing > is added. It looks that base+index reg addressing mode is disabled > for shmedia32 and shcompact as default and it makes ira unhappy. > We used to return NO_REGS for INDEX_REG_CLASS when -mindexed-addressing > is disabled and it could suppress the use of reg+index addressing in > the older compilers. It seems that now this isn't the right way to > disable that addressing. With > > --- /svn/trunk/gcc/config/sh/sh.h 2014-05-14 10:20:06.526008871 +0900 > +++ gcc/config/sh/sh.h 2014-07-28 14:16:51.358771570 +0900 > @@ -1723,8 +1723,7 @@ struct sh_args { > #define INDEX_REGISTER_RTX_P(X) MAYBE_INDEX_REGISTER_RTX_P(X, false) > #endif > > -#define ALLOW_INDEXED_ADDRESS \ > - ((!TARGET_SHMEDIA32 && !TARGET_SHCOMPACT) || TARGET_ALLOW_INDEXED_ADDRESS) > +#define ALLOW_INDEXED_ADDRESS 1 > > /* A C compound statement that attempts to replace X, which is an address > that needs reloading, with a valid memory address for an operand of > > my c-only sh64-elf build is completed without errors. Although > I don't think the patch does the right thing, it'll prove that > ALLOW_INDEXED_ADDRESS causes problems. Yeah, always enabling indexed-addressing might not be the right thing in this case. At least reading the description of the -mindexed-addressing option is a bit scary (I'm not that familiar with sh64). With the attached patch applied I was able to build a c,c++ sh64-elf newlib 1.2.0 cross compiler for the default multilib configs {ml,mb} x {m5-32media-nofpu, m5-64media, m5-64media-nofpu, m5-compact, m5-compact-nofpu}. However, I haven't checked whether it produces correct code actually. Thus, feedback is highly appreciated. I don't know what happened to reload, but it seems it needs some extra help. The patch shouldn't have any impact on non-sh64, since ALLOW_INDEXED_ADDRESS always returns 'true' for non-sh64. If it helps, it can be committed to trunk and the 4.9 and 4.8 branches.