The following patch fixes: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58785
LRA chooses constraint 'm' for const_int operand. It means that the const_int should be placed in memory but it does not happen as preferred reload class hook returns LO_REGS for class NO_REGS which is result of LRA choosing 'm'. I don't know why reload pass needs such value but it should be return NO_REGS IMHO as it results in much less reload insns.
Is this patch ok to commit to the trunk? 2013-10-30 Vladimir Makarov <vmaka...@redhat.com> PR target/58785 * config/arm/arm.c (arm_preferred_reload_class): Don't return LO_REGS for NO_REGS for LRA. 2013-10-30 Vladimir Makarov <vmaka...@redhat.com> PR target/58785 * gcc.target/arm/pr58785.c: New.
Index: config/arm/arm.c =================================================================== --- config/arm/arm.c (revision 204213) +++ config/arm/arm.c (working copy) @@ -6884,7 +6884,7 @@ arm_preferred_reload_class (rtx x ATTRIB { if (rclass == GENERAL_REGS || rclass == HI_REGS - || rclass == NO_REGS + || (! lra_in_progress && rclass == NO_REGS) || rclass == STACK_REG) return LO_REGS; else Index: testsuite/gcc.target/arm/pr58785.c =================================================================== --- testsuite/gcc.target/arm/pr58785.c (revision 0) +++ testsuite/gcc.target/arm/pr58785.c (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mthumb" } */ + +typedef _Fract HQtype __attribute__ ((mode (HQ))); +extern void *memcpy (void *,const void *,int); + +HQtype f() +{ + HQtype c; + int z = 0xfada; + memcpy (&c, &z, 2); + return c; +}