lra-constraints.c (process_address_1): Swap base_term and index_term if INDEX_REG_CLA...
authorKaz Kojima <kkojima@gcc.gnu.org>
Fri, 19 Dec 2014 04:36:54 +0000 (04:36 +0000)
committerKaz Kojima <kkojima@gcc.gnu.org>
Fri, 19 Dec 2014 04:36:54 +0000 (04:36 +0000)
* lra-constraints.c (process_address_1): Swap base_term and index_term
  if INDEX_REG_CLASS is assigned to base_term already when INDEX_REG_CLASS
  is a single register class.

From-SVN: r218885

gcc/ChangeLog
gcc/lra-constraints.c

index 72e8dfdc55360e850ed0b94d18d48397f21f9f1f..4d83cadb0ee741d0b60292a88a5f3619c14b3d82 100644 (file)
@@ -1,3 +1,9 @@
+2014-12-19  Kaz Kojima  <kkojima@gcc.gnu.org>
+
+       * lra-constraints.c (process_address_1): Swap base_term and
+       index_term if INDEX_REG_CLASS is assigned to base_term already
+       when INDEX_REG_CLASS is a single register class.
+
 2014-12-18  Vladimir Makarov  <vmakarov@redhat.com>
 
        * lra-constraints.c (lra-constraints.c): Exchange places of sclass
index 23fd44db54a3e2fc662b32a40f1f06240354b435..8fc2cb77a5d913d015e67b470bc602bfe99cdec5 100644 (file)
@@ -2834,6 +2834,20 @@ process_address_1 (int nop, bool check_only_p,
     decompose_mem_address (&ad, SUBREG_REG (op));
   else
     return false;
+  /* If INDEX_REG_CLASS is assigned to base_term already and isn't to
+     index_term, swap them so to avoid assigning INDEX_REG_CLASS to both
+     when INDEX_REG_CLASS is a single register class.  */
+  if (ad.base_term != NULL
+      && ad.index_term != NULL
+      && ira_class_hard_regs_num[INDEX_REG_CLASS] == 1
+      && REG_P (*ad.base_term)
+      && REG_P (*ad.index_term)
+      && in_class_p (*ad.base_term, INDEX_REG_CLASS, NULL)
+      && ! in_class_p (*ad.index_term, INDEX_REG_CLASS, NULL))
+    {
+      std::swap (ad.base, ad.index);
+      std::swap (ad.base_term, ad.index_term);
+    }
   if (! check_only_p)
     change_p = equiv_address_substitution (&ad);
   if (ad.base_term != NULL