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]

Problem in inheritance code


Yesterday I tested my local spill patches together with Joern Rennecke's
inheritance patches which I grabbed off egcs-patches.  Doing this revealed
a bug in the reload inheritance code: it uses (spill_reg_order[r] < 0) as
a test whether hard register R is not allocated to a pseudo.  That can be
incorrect with the current code due to block-local pseudos which weren't
spilled, and it will definitely be incorrect with the local spill patches,
unless they are modified to recompute spill_reg_order for every insn.  The
patch below seems like a good solution.  It relies on the life information
being correct and up-to-date in the reload_insn_chain, which should be given
by now.

There are some other places in choose_reload_regs/allocate_reload_reg which
make the same assumption.  I'm wondering whether any of those could be
incorrect as well.

Jeff, what are you planning to do next in the reload pass?  If you want to
integrate Joern's patch first, I'll wait a bit with sending the final piece
of my changes; otherwise you'll get a patch from me tomorrow.

Bernd

	* reload1.c (reg_used_by_pseudo): New static variable.
	(choose_reload_regs): Initialize it.
	Use it instead of testing spill_reg_order to determine whether a
	pseudo is live in a hard register across the current insn.
	Fix a typo in a reference to reload_reg_rtx.

Index: reload1.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/reload1.c,v
retrieving revision 1.78
diff -u -p -r1.78 reload1.c
--- reload1.c	1998/10/14 09:02:48	1.78
+++ reload1.c	1998/10/15 09:49:31
@@ -4551,6 +4551,10 @@ static HARD_REG_SET reload_reg_used_at_a
    in the group.  */
 static HARD_REG_SET reload_reg_used_for_inherit;
 
+/* Records which hard regs are allocated to a pseudo during any point of the
+   current insn.  */
+static HARD_REG_SET reg_used_by_pseudo;
+
 /* Mark reg REGNO as in use for a reload of the sort spec'd by OPNUM and
    TYPE. MODE is used to indicate how many consecutive regs are
    actually used.  */
@@ -5602,6 +5606,10 @@ choose_reload_regs (chain, avoid_return_
   CLEAR_HARD_REG_SET (reload_reg_used_in_insn);
   CLEAR_HARD_REG_SET (reload_reg_used_in_other_addr);
 
+  CLEAR_HARD_REG_SET (reg_used_by_pseudo);
+  compute_use_by_pseudos (&reg_used_by_pseudo, chain->live_before);
+  compute_use_by_pseudos (&reg_used_by_pseudo, chain->live_after);
+  
   for (i = 0; i < reload_n_operands; i++)
     {
       CLEAR_HARD_REG_SET (reload_reg_used_in_output[i]);
@@ -5934,7 +5942,7 @@ choose_reload_regs (chain, avoid_return_
 
 			  if (i1 != n_earlyclobbers
 			      /* Don't use it if we'd clobber a pseudo reg.  */
-			      || (spill_reg_order[i] < 0
+			      || (! TEST_HARD_REG_BIT (reg_used_by_pseudo, i)
 				  && reload_out[r]
 				  && ! TEST_HARD_REG_BIT (reg_reloaded_dead, i))
 			      /* Don't really use the inherited spill reg
@@ -5944,7 +5952,7 @@ choose_reload_regs (chain, avoid_return_
 			      /* If find_reloads chose reload_out as reload
 				 register, stay with it - that leaves the
 				 inherited register for subsequent reloads.  */
-			      || (reload_out[r] && reload_reg_rtx
+			      || (reload_out[r] && reload_reg_rtx[r]
 				  && rtx_equal_p (reload_out[r],
 						  reload_reg_rtx[r])))
 			    reload_override_in[r] = reg_last_reload_reg[regno];



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