This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the EGCS project.


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

Re: reload and earlyclobber operands


My previous patch did not fix Philip's test case - he didn't send a copy to
the list because it was too big.  I've appended a smaller version below
(compile on arm-linux) as well as another patch.  Note that I still believe
the first patch is necessary.

There seem to be two independent bugs in reload_reg_free_for_value_p.  In
the test case below, the RELOAD_INPUT reload (reload 1) is the first to get
a register; afterwards reload_reg_free_for_value_p is called for the
RELOAD_OTHER reload (reload 0).  When it compares the lifetimes of the two,
time1 (for reload 0) is 55, and time2 (for reload 1) is 12.  Despite the
fact that the lifetimes overlap, the function returns 1, because it ignores
the fact that reload 0 sets the register.  The patch below cures that; but
it may be more conservative than necessary.  We could try computing a third
time (the set time), which would either be (MAX_RECOG_OPERAND * 4 + 3) (for
earlyclobbers) or (MAX_RECOG_OPERAND * 4 + 4) (for normal outputs) and
compare that to the lifetime of the input-only reload.  However, the code is
hairy enough without this complication.

IMNSHO all of the code dealing with reload_when_needed is just horrible...

Bernd

---------------------
typedef struct {
int h, w;
unsigned char *data;
} PixelRegion;

typedef struct {
int red, green, blue, pixel;
} GdkColor;

static void
text_gdk_image_to_region (void    *image,
			  int          scale,
			  PixelRegion *textPR)
{
  GdkColor black;
  int black_pixel;
  int pixel;
  int value;
  int scalex, scaley;
  int scale2;
  int x, y;
  int i, j;
  unsigned char * data;

  scale2 = scale * scale;
 

  black.red = black.green = black.blue = 0;
  gdk_colormap_alloc_color (gdk_colormap_get_system (), &black, (0) , (! (0) ) );
  black_pixel = black.pixel;



  data = textPR->data;

  for (y = 0, scaley = 0; y < textPR->h; y++, scaley += scale)
    {
      for (x = 0, scalex = 0; x < textPR->w; x++, scalex += scale)
	{
	  value = 0;

	  for (i = scaley; i < scaley + scale; i++)
	    for (j = scalex; j < scalex + scale; j++)
	      {
		pixel = 0;
		if (pixel == black_pixel)
		  value ++;
	      }

	   
	  *data++= (unsigned char) ((value * 255) / scale2);

	}
    }
}
---------------------
         
	* reload1.c (reload_reg_free_for_value_p): If two reloads overlap in
	their lifetimes, and one of them has an output, they conflict.

Index: reload1.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/reload1.c,v
retrieving revision 1.147
diff -u -p -r1.147 reload1.c
--- reload1.c	1999/07/08 10:07:30	1.147
+++ reload1.c	1999/07/27 16:24:31
@@ -5375,7 +5380,8 @@ reload_reg_free_for_value_p (regno, opnu
 		}
 	      if ((time1 >= time2
 		   && (! reload_in[i] || reload_out[i]
-		       || ! rtx_equal_p (reload_in[i], value)))
+		       || ! rtx_equal_p (reload_in[i], value)
+		       || out))
 		  || (out && reload_out_reg[reloadnum]
 		      && time2 >= MAX_RECOG_OPERANDS * 4 + 3))
 		return 0;



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