* Claudiu Zissulescu <claudiu.zissule...@synopsys.com> [2017-11-27 12:09:50 +0100]:
> From: Claudiu Zissulescu <claz...@gmail.com> > > Sometimes the memory equivalent is not valid due to a large offset. > For example replacing the ap register with its fp/sp-equivalent during > LRA step. To solve this we introduced TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV. > > gcc/ > 2017-08-08 Claudiu Zissulescu <claz...@synopsys.com> > > * config/arc/arc.c (arc_cannot_substitute_mem_equiv_p): New function. > (TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P): Define. > > gcc/testsuite > 2017-08-08 Claudiu Zissulescu <claz...@synopsys.com> > > * gcc.target/arc/lra-1.c: New test. Looks good. Thanks, Andrew > --- > gcc/config/arc/arc.c | 12 ++++++++++++ > gcc/testsuite/gcc.target/arc/lra-1.c | 17 +++++++++++++++++ > 2 files changed, 29 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/arc/lra-1.c > > diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c > index dd922a6..25f123c 100644 > --- a/gcc/config/arc/arc.c > +++ b/gcc/config/arc/arc.c > @@ -11352,12 +11352,24 @@ arc_use_anchors_for_symbol_p (const_rtx symbol) > return default_use_anchors_for_symbol_p (symbol); > } > > +/* Return true if SUBST can't safely replace its equivalent during RA. */ > +static bool > +arc_cannot_substitute_mem_equiv_p (rtx) > +{ > + /* If SUBST is mem[base+index], the address may not fit iSA, > + thus return true. */ > + return true; > +} > + > #undef TARGET_USE_ANCHORS_FOR_SYMBOL_P > #define TARGET_USE_ANCHORS_FOR_SYMBOL_P arc_use_anchors_for_symbol_p > > #undef TARGET_CONSTANT_ALIGNMENT > #define TARGET_CONSTANT_ALIGNMENT constant_alignment_word_strings > > +#undef TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P > +#define TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P > arc_cannot_substitute_mem_equiv_p > + > struct gcc_target targetm = TARGET_INITIALIZER; > > #include "gt-arc.h" > diff --git a/gcc/testsuite/gcc.target/arc/lra-1.c > b/gcc/testsuite/gcc.target/arc/lra-1.c > new file mode 100644 > index 0000000..27336d1 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/arc/lra-1.c > @@ -0,0 +1,17 @@ > +/* { dg-do compile } */ > +/* { dg-options "-Os -w -mlra" } */ > + > +/* ap is replaced with an address like base+offset by lra, > + where offset is larger than s9, resulting into an ICE. */ > + > +typedef struct { char a[500] } b; > +c; > +struct d { > + short e; > + b f > +} g(int h, int i, int j, int k, char l, int m, int n, char *p) { > +again:; > + struct d o; > + *p = c = ({ q(o); }); > + goto again; > +} > -- > 1.9.1 >