overridden optional reload may cause a needed reload to bedropped

Bernd Schmidt bernds@redhat.co.uk
Thu Oct 26 04:15:00 GMT 2000


On 26 Oct 2000, Alexandre Oliva wrote:

> On Oct 26, 2000, Bernd Schmidt <bernds@redhat.com> wrote:
> 
> > Apparently we lose the contents of reload_override_in at some point;
> 
> We don't.  It's just that we decide to not reload it because the
> reload is optional.  Or at least that was my understanding of the
> problem.  I may point you to the testcase, if you want to play with
> it.

Here's a patch.  The problem does indeed appear to be that it is harmful to
set reload_override_in for optional reloads.  reload_override_in is used for
a slightly weaker form of inheritance, where the inherited register can't be
used for the reload itself, but can be used as an input.  However, this only
works for non-optional reloads, since optional reloads rely on getting a
register through inheritance.  Just a new input from reload_override_in won't
actually cause an optional reload to get done.
This means that, most of the time, setting reload_override_in for an optional
reload doesn't do anything at all - which is why we haven't noticed the
problem yet.  In Alex's test case, we found a spot that believed that since
reload_override_in was set, the reload would be performed, which was incorrect
for an optional reload.

The patch below fixes it.  Alex has verified it on the original testcase
(which unfortunately can't be posted here), and I've done some experiments
that show that the patch seems to have no effect on normal code generation.

Bernd

	* reload1.c (choose_reload_regs): Never set reload_override_in for
	optional reloads.

Index: reload1.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/reload1.c,v
retrieving revision 1.277
diff -u -p -r1.277 reload1.c
--- reload1.c	2000/10/16 22:11:01	1.277
+++ reload1.c	2000/10/26 09:56:08
@@ -5410,9 +5421,12 @@ choose_reload_regs (chain)
 			      || (rld[r].out && rld[r].reg_rtx
 				  && rtx_equal_p (rld[r].out, rld[r].reg_rtx)))
 			    {
-			      reload_override_in[r] = last_reg;
-			      reload_inheritance_insn[r]
-				= reg_reloaded_insn[i];
+			      if (! rld[r].optional)
+				{
+				  reload_override_in[r] = last_reg;
+				  reload_inheritance_insn[r]
+				    = reg_reloaded_insn[i];
+				}
 			    }
 			  else
 			    {
@@ -5511,7 +5525,8 @@ choose_reload_regs (chain)
 		  if (reg_overlap_mentioned_for_reload_p (equiv,
 							  reload_earlyclobbers[i]))
 		    {
-		      reload_override_in[r] = equiv;
+		      if (! rld[r].optional)
+			reload_override_in[r] = equiv;
 		      equiv = 0;
 		      break;
 		    }
@@ -5534,7 +5549,8 @@ choose_reload_regs (chain)
 		    case RELOAD_OTHER:
 		    case RELOAD_FOR_INPUT:
 		    case RELOAD_FOR_OPERAND_ADDRESS:
-		      reload_override_in[r] = equiv;
+		      if (! rld[r].optional)
+			reload_override_in[r] = equiv;
 		      /* Fall through.  */
 		    default:
 		      equiv = 0;



More information about the Gcc-patches mailing list