Patchwork [lra] patch to simulate reload behaviour

login
register
mail settings
Submitter Vladimir Makarov
Date Feb. 28, 2012, 5:09 p.m.
Message ID <4F4D0A53.8050301@redhat.com>
Download mbox | patch
Permalink /patch/143507/
State New
Headers show

Comments

Vladimir Makarov - Feb. 28, 2012, 5:09 p.m.
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 <vmakarov@redhat.com>

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

Patch

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)