> I suggest making reload reload the PSImode subreg instead, and
> make the m32c machine description provide for a tertiary
> reload so that the value can be loaded & truncated.

Don't know how to set up a tertiary reload (it's not documented
anywhere).

Is this the type of patch you're thining about?  It seems to compile
that problem case, but I haven't tried anything else yet.

Index: config/m32c/m32c.c
===================================================================
--- config/m32c/m32c.c  (revision 146617)
+++ config/m32c/m32c.c  (working copy)
@@ -2040,12 +2040,37 @@ m32c_legitimize_reload_address (rtx * x,
       push_reload (XEXP (*x, 0), NULL_RTX, &XEXP (*x, 0), NULL,
                   A_REGS, Pmode, VOIDmode, 0, 0, opnum,
                   type);
       return 1;
     }
 
+  /* If we see an RTX like (subreg:PSI (reg:SI ...)) we need to reload
+     the subreg.  We need to check for PLUS and non-PLUS cases.  */
+
+  if (GET_CODE (*x) == SUBREG
+      && GET_MODE (XEXP (*x, 0)) == SImode)
+    {
+      if (type == RELOAD_OTHER)
+       type = RELOAD_FOR_OTHER_ADDRESS;
+      push_reload (*x, NULL_RTX, x, NULL,
+                  A_REGS, Pmode, VOIDmode, 0, 0, opnum,
+                  type);
+      return 1;
+    }
+  if (GET_CODE (*x) == PLUS
+      && GET_CODE (XEXP (*x, 0)) == SUBREG
+      && GET_MODE (XEXP (XEXP (*x, 0), 0)) == SImode)
+    {
+      if (type == RELOAD_OTHER)
+       type = RELOAD_FOR_OTHER_ADDRESS;
+      push_reload (XEXP (*x, 0), NULL_RTX, &(XEXP (*x, 0)), NULL,
+                  A_REGS, Pmode, VOIDmode, 0, 0, opnum,
+                  type);
+      return 1;
+    }
+
   return 0;
 }
 
 /* Implements LEGITIMATE_CONSTANT_P.  We split large constants anyway,
    so we can allow anything.  */
 int

Reply via email to