File nvl161673.patch of Package gcc41

You asked whether there was a smaller patch that only reordered
operands in the backend to "fix" the indexed load/store problem.
David Edelsohn does have one which I'm attaching here for you.
I just applied the patch to the latest GCC 4.1 branch and
bootstrapped it and regtested it with no problems.

   * config/rs6000/rs6000.c (print_operand, 'y'): Swap position of
   registers in index addresses.
   (print_operand_address): Same.


Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c.orig	2007-01-15 11:11:08.000000000 +0100
+++ gcc/config/rs6000/rs6000.c	2009-11-20 13:41:27.000000000 +0100
@@ -10784,12 +10784,14 @@ print_operand (FILE *file, rtx x, int co
 			&& REG_P (XEXP (tmp, 0))
 			&& REG_P (XEXP (tmp, 1)));
 
-	    if (REGNO (XEXP (tmp, 0)) == 0)
-	      fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (tmp, 1)) ],
-		       reg_names[ REGNO (XEXP (tmp, 0)) ]);
-	    else
+	    /* Second index register frequently contains base address,
+	       preferentially place it in rA position unless it is r0.  */
+	    if (REGNO (XEXP (tmp, 1)) == 0)
 	      fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (tmp, 0)) ],
 		       reg_names[ REGNO (XEXP (tmp, 1)) ]);
+	    else
+	      fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (tmp, 1)) ],
+		       reg_names[ REGNO (XEXP (tmp, 0)) ]);
 	  }
 	break;
       }
@@ -10843,12 +10845,15 @@ print_operand_address (FILE *file, rtx x
   else if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 1)) == REG)
     {
       gcc_assert (REG_P (XEXP (x, 0)));
-      if (REGNO (XEXP (x, 0)) == 0)
-	fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (x, 1)) ],
-		 reg_names[ REGNO (XEXP (x, 0)) ]);
-      else
+
+      /* Second index register frequently contains base address,
+	 preferentially place it in rA position unless it is r0.  */
+      if (REGNO (XEXP (x, 1)) == 0)
 	fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (x, 0)) ],
 		 reg_names[ REGNO (XEXP (x, 1)) ]);
+      else
+	fprintf (file, "%s,%s", reg_names[ REGNO (XEXP (x, 1)) ],
+		 reg_names[ REGNO (XEXP (x, 0)) ]);
     }
   else if (GET_CODE (x) == PLUS && GET_CODE (XEXP (x, 1)) == CONST_INT)
     fprintf (file, HOST_WIDE_INT_PRINT_DEC "(%s)",
openSUSE Build Service is sponsored by