The following patch adds reload behaviour to LRA for some cases. Some targets assumes such behaviour.

The patch was successfully bootstrapped on x86/x86-64.

Committed as rev. 184631.

2012-02-28  Vladimir Makarov <vmaka...@redhat.com>

        * lra-constraints.c (check_and_process_move): Process source first
        for the secondary move.
        (process_alt_operands): Increase cost for scratch allocations.

Index: lra-constraints.c
===================================================================
--- lra-constraints.c   (revision 184561)
+++ lra-constraints.c   (working copy)
@@ -1097,20 +1097,20 @@ check_and_process_move (bool *change_p, 
   sri.prev_sri = NULL;
   sri.icode = CODE_FOR_nothing;
   sri.extra_cost = 0;
-  if (dclass != NO_REGS)
-    {
-      in_p = true;
-      rclass = dclass;
-      x = sreg;
-      xclass = sclass;
-    }
-  else if (sclass != NO_REGS)
+  if (sclass != NO_REGS)
     {
       in_p = false;
       rclass = sclass;
       x = dreg;
       xclass = dclass;
     }
+  else if (dclass != NO_REGS)
+    {
+      in_p = true;
+      rclass = dclass;
+      x = sreg;
+      xclass = sclass;
+    }
   else
     return false;
   temp_assign_p = false;
@@ -2027,6 +2027,14 @@ process_alt_operands (int only_alternati
                                      this_costly_alternative, NULL))
                        reject++;
                    }
+                 /* We simulate the behaviour of old reload here.
+                    Although scratches need hard registers and it
+                    might result in spilling other pseudos, no reload
+                    insns are generated for the scratches.  So it
+                    might cost something but probably less than old
+                    reload pass believes. */
+                 if (lra_former_scratch_p (REGNO (operand_reg[nop])))
+                   reject += LOSER_COST_FACTOR;
                }
            }
          else if (did_match)

Reply via email to