diff mbox

[m32c] fix PR 45800 - subregs of volatile mem

Message ID 201009282201.o8SM1vwN032302@greed.delorie.com
State New
Headers show

Commit Message

DJ Delorie Sept. 28, 2010, 10:01 p.m. UTC
Committed.

2010-09-28  DJ Delorie  <dj@redhat.com>

	PR target/45800
	* config/m32c/m32c.c (m32c_subreg): Force adjustment of subregs of
	volatile MEMs.
diff mbox

Patch

Index: gcc/config/m32c/m32c.c
===================================================================
--- gcc/config/m32c/m32c.c	(revision 164704)
+++ gcc/config/m32c/m32c.c	(working copy)
@@ -3314,13 +3314,25 @@  m32c_subreg (enum machine_mode outer,
       && GET_CODE (XEXP (x, 0)) == MEM
       && (GET_CODE (XEXP (XEXP (x, 0), 0)) == PRE_DEC
 	  || GET_CODE (XEXP (XEXP (x, 0), 0)) == POST_INC))
     return gen_rtx_MEM (outer, XEXP (XEXP (x, 0), 0));
 
   if (GET_CODE (x) != REG)
-    return simplify_gen_subreg (outer, x, inner, byte);
+    {
+      rtx r = simplify_gen_subreg (outer, x, inner, byte);
+      if (GET_CODE (r) == SUBREG
+	  && GET_CODE (x) == MEM
+	  && MEM_VOLATILE_P (x))
+	{
+	  /* Volatile MEMs don't get simplified, but we need them to
+	     be.  We are little endian, so the subreg byte is the
+	     offset.  */
+	  r = adjust_address (x, outer, byte);
+	}
+      return r;
+    }
 
   r = REGNO (x);
   if (r >= FIRST_PSEUDO_REGISTER || r == AP_REGNO)
     return simplify_gen_subreg (outer, x, inner, byte);
 
   if (IS_MEM_REGNO (r))