This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fix for missed giv combinations


Sometimes, the function express_from can return a non-canonical expression
of the form (plus (plus x const) y).  This can cause it not to be recognized
as an addressing mode, while the canonical form (plus (plus x y) const)
would be recognized.  This can cause combine_givs to miss possible
combinations.

Bernd
	* loop.c (express_from): Make sure that when generating a PLUS of
	a PLUS, any constant expression appears on the outermost PLUS.

Index: loop.c
===================================================================
RCS file: /usr/local/cvs/gcs/gcc/loop.c,v
retrieving revision 1.1.1.45
diff -u -p -r1.1.1.45 loop.c
--- loop.c	1998/10/15 13:29:35	1.1.1.45
+++ loop.c	1998/10/17 18:33:08
@@ -6230,7 +6225,18 @@ express_from (g1, g2)
   if (add == const0_rtx)
     return mult;
   else
-    return gen_rtx_PLUS (g2->mode, mult, add);
+    {
+      if (GET_CODE (add) == PLUS
+	  && CONSTANT_P (XEXP (add, 1)))
+	{
+	  rtx tem = XEXP (add, 1);
+	  mult = gen_rtx_PLUS (g2->mode, mult, XEXP (add, 0));
+	  add = tem;
+	}
+      
+      return gen_rtx_PLUS (g2->mode, mult, add);
+    }
+  
 }
 
 /* Return an rtx, if any, that expresses giv G2 as a function of the register



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]