loop.c (express_from): Try harder to unify (* c N) and (* c M) where N and M are...
authorRichard Henderson <rth@cygnus.com>
Wed, 25 Aug 1999 18:14:11 +0000 (11:14 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Wed, 25 Aug 1999 18:14:11 +0000 (11:14 -0700)
        * loop.c (express_from): Try harder to unify (* c N) and (* c M)
        where N and M are constant and N is an integer multiple of M.

From-SVN: r28868

gcc/ChangeLog
gcc/loop.c

index 7267f06..30a31f2 100644 (file)
@@ -1,3 +1,8 @@
+Wed Aug 25 11:13:29 1999  Richard Henderson  <rth@cygnus.com>
+
+       * loop.c (express_from): Try harder to unify (* c N) and (* c M)
+       where N and M are constant and N is an integer multiple of M.
+
 Wed Aug 25 13:55:47 EDT 1999  Andrew MacLeod  <amacleod@cygnus.com>
 
        * sbitmap.h (sbitmap_intersection_of_succs): Add prototype.
 Wed Aug 25 13:55:47 EDT 1999  Andrew MacLeod  <amacleod@cygnus.com>
 
        * sbitmap.h (sbitmap_intersection_of_succs): Add prototype.
index 810f3a2..eb99eca 100644 (file)
@@ -6843,6 +6843,30 @@ express_from (g1, g2)
 
   add = express_from_1 (g1->add_val, g2->add_val, mult);
   if (add == NULL_RTX)
 
   add = express_from_1 (g1->add_val, g2->add_val, mult);
   if (add == NULL_RTX)
+    {
+      /* Failed.  If we've got a multiplication factor between G1 and G2,
+        scale G1's addend and try again.  */
+      if (INTVAL (mult) > 1)
+       {
+         rtx g1_add_val = g1->add_val;
+         if (GET_CODE (g1_add_val) == MULT
+             && GET_CODE (XEXP (g1_add_val, 1)) == CONST_INT)
+           {
+             HOST_WIDE_INT m;
+             m = INTVAL (mult) * INTVAL (XEXP (g1_add_val, 1));
+             g1_add_val = gen_rtx_MULT (GET_MODE (g1_add_val),
+                                        XEXP (g1_add_val, 0), GEN_INT (m));
+           }
+         else
+           {
+             g1_add_val = gen_rtx_MULT (GET_MODE (g1_add_val), g1_add_val,
+                                        mult);
+           }
+
+         add = express_from_1 (g1_add_val, g2->add_val, const1_rtx);
+       }
+    }
+  if (add == NULL_RTX)
     return NULL_RTX;
 
   /* Form simplified final result.  */
     return NULL_RTX;
 
   /* Form simplified final result.  */