[PATCH,committed] fix legitimization of TImode/TFmode addresses

Nathan Froyd froydnj@codesourcery.com
Sat Feb 23 10:43:00 GMT 2008


I've committed the patch David approved here:

  http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00250.html

with minor tweaks.  Peter Bergner suggested that we should do the same
sort of checking for TDmode and I wondered if we shouldn't just be
checking GET_MODE_SIZE.  David approved the GET_MODE_SIZE change on IRC,
so that's what went in.

-Nathan

	* config/rs6000/rs6000.c (rs6000_legitimize_address): Check to
	ensure that we can address an entire entity > 8 bytes.  Don't
	generate reg+reg addressing for such data.

Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c	(revision 132565)
+++ config/rs6000/rs6000.c	(working copy)
@@ -3630,19 +3630,29 @@ rs6000_legitimize_address (rtx x, rtx ol
       /* We accept [reg + reg] and [reg + OFFSET].  */
 
       if (GET_CODE (x) == PLUS)
-	{
-	  rtx op1 = XEXP (x, 0);
-	  rtx op2 = XEXP (x, 1);
-
-	  op1 = force_reg (Pmode, op1);
-
-	  if (GET_CODE (op2) != REG
-	      && (GET_CODE (op2) != CONST_INT
-		  || !SPE_CONST_OFFSET_OK (INTVAL (op2))))
-	    op2 = force_reg (Pmode, op2);
-
-	  return gen_rtx_PLUS (Pmode, op1, op2);
-	}
+       {
+         rtx op1 = XEXP (x, 0);
+         rtx op2 = XEXP (x, 1);
+         rtx y;
+
+         op1 = force_reg (Pmode, op1);
+
+         if (GET_CODE (op2) != REG
+             && (GET_CODE (op2) != CONST_INT
+                 || !SPE_CONST_OFFSET_OK (INTVAL (op2))
+                 || (GET_MODE_SIZE (mode) > 8
+                     && !SPE_CONST_OFFSET_OK (INTVAL (op2) + 8))))
+           op2 = force_reg (Pmode, op2);
+
+         /* We can't always do [reg + reg] for these, because [reg +
+            reg + offset] is not a legitimate addressing mode.  */
+         y = gen_rtx_PLUS (Pmode, op1, op2);
+
+         if (GET_MODE_SIZE (mode) > 8 && REG_P (op2))
+           return force_reg (Pmode, y);
+         else
+           return y;
+       }
 
       return force_reg (Pmode, x);
     }



More information about the Gcc-patches mailing list