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]

Patch: fix gcc.c-torture/execute/930126-1.c on m68k


Hi,

I've sent this patch already before, the version below is for the trunk,
more info about the bug can be found here:
http://gcc.gnu.org/ml/gcc-patches/2001-07/msg01397.html
This time I even sorted the patch and commented the single steps to fix
the bug.

Bootstrapped and regression tested on i686-linux and m68k-linux.

2001-07-24  Roman Zippel  <zippel@linux-m68k.org>

	* alias.c (write_dependence_p): add machine mode argument and use it
	(anti_dependence, output_dependence): pass through machine mode
	* cselib.c (cselib_invalidate_rtx): extract original machine mode
	for sign_extract and zero_extract
	(cselib_invalidate_mem_1, cselib_invalidate_mem, cselib_mem_conflict_p):
	pass through machine mode
	(cselib_process_insn): add default VOIDmode argument
	sched-deps.c (sched_analyze_1): Likewise
	flow.c (insn_dead_p, mark_used_regs): Likewise
	rtl.h (anti_dependence, output_dependence): update prototype

----------
Add a mode argument to write_dependence_p, similiar to true_depence:

Index: gcc/alias.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/alias.c,v
retrieving revision 1.138
diff -u -r1.138 alias.c
--- alias.c	2001/08/22 14:34:41	1.138
+++ alias.c	2001/08/22 15:50:50
@@ -1847,9 +1848,10 @@
    (or, if WRITEP is non-zero, a write to) MEM.  */

 static int
-write_dependence_p (mem, x, writep)
+write_dependence_p (mem, x, x_mode, writep)
      rtx mem;
      rtx x;
+     enum machine_mode x_mode;
      int writep;
 {
   rtx x_addr, mem_addr;
@@ -1872,6 +1874,9 @@
   if (! writep && RTX_UNCHANGING_P (mem))
     return 0;

+  if (x_mode == VOIDmode)
+    x_mode = GET_MODE (x);
+
   x_addr = get_addr (XEXP (x, 0));
   mem_addr = get_addr (XEXP (mem, 0));

@@ -1884,7 +1889,7 @@
 	return 0;
     }

-  if (! base_alias_check (x_addr, mem_addr, GET_MODE (x),
+  if (! base_alias_check (x_addr, mem_addr, x_mode,
 			  GET_MODE (mem)))
     return 0;

@@ -1892,7 +1897,7 @@
   mem_addr = canon_rtx (mem_addr);

   if (!memrefs_conflict_p (SIZE_FOR_MODE (mem), mem_addr,
-			   SIZE_FOR_MODE (x), x_addr, 0))
+			   GET_MODE_SIZE(x_mode), x_addr, 0))
     return 0;

   fixed_scalar

----------
get the original mode, which was stripped away from note_stores

Index: gcc/cselib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cselib.c,v
retrieving revision 1.14
diff -u -r1.14 cselib.c
--- cselib.c	2001/08/22 14:34:53	1.14
+++ cselib.c	2001/08/22 15:51:09
@@ -1114,11 +1124,18 @@
    note_stores; they are ignored.  */

 static void
-cselib_invalidate_rtx (dest, ignore, data)
+cselib_invalidate_rtx (dest, set, data)
      rtx dest;
-     rtx ignore ATTRIBUTE_UNUSED;
+     rtx set;
      void *data ATTRIBUTE_UNUSED;
 {
+  enum machine_mode dest_mode = GET_MODE (dest);
+  if (set && GET_CODE(set) == SET)
+    {
+      if (GET_CODE (SET_DEST (set)) == SIGN_EXTRACT
+	  || GET_CODE (SET_DEST (set)) == ZERO_EXTRACT)
+	dest_mode = GET_MODE (SET_DEST (set));
+    }
   while (GET_CODE (dest) == STRICT_LOW_PART || GET_CODE (dest) == SIGN_EXTRACT
 	 || GET_CODE (dest) == ZERO_EXTRACT || GET_CODE (dest) == SUBREG)
     dest = XEXP (dest, 0);
@@ -1126,7 +1143,7 @@
   if (GET_CODE (dest) == REG)
     cselib_invalidate_regno (REGNO (dest), GET_MODE (dest));
   else if (GET_CODE (dest) == MEM)
-    cselib_invalidate_mem (dest);
+    cselib_invalidate_mem (dest, dest_mode);

   /* Some machines don't define AUTO_INC_DEC, but they still use push
      instructions.  We need to catch that case here in order to

----------
pass both expression and machine mode to cselib_invalidate_mem(_1)

Index: gcc/cselib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cselib.c,v
retrieving revision 1.14
diff -u -r1.14 cselib.c
--- cselib.c	2001/08/22 14:34:53	1.14
+++ cselib.c	2001/08/22 15:51:09
@@ -1047,6 +1048,11 @@

 /* For the value found in SLOT, walk its locations to determine if any overlap
    INFO (which is a MEM rtx).  */
+struct cselib_invalidate_info
+{
+  enum machine_mode mode;
+  rtx exp;
+};

 static int
 cselib_invalidate_mem_1 (slot, info)
@@ -1054,7 +1060,7 @@
      void *info;
 {
   cselib_val *v = (cselib_val *) *slot;
-  rtx mem_rtx = (rtx) info;
+  struct cselib_invalidate_info *i = (struct cselib_invalidate_info *)info;
   struct elt_loc_list **p = &v->locs;
   int had_locs = v->locs != 0;

@@ -1067,7 +1073,7 @@
       /* MEMs may occur in locations only at the top level; below
 	 that every MEM or REG is substituted by its VALUE.  */
       if (GET_CODE (x) != MEM
-	  || ! cselib_mem_conflict_p (mem_rtx, x))
+	  || ! cselib_mem_conflict_p (i->exp, i->mode, x))
 	{
 	  p = &(*p)->next;
 	  continue;
@@ -1103,10 +1109,14 @@
    instruction, MEM_RTX is (mem:BLK const0_rtx).  */

 static void
-cselib_invalidate_mem (mem_rtx)
+cselib_invalidate_mem (mem_rtx, mem_mode)
      rtx mem_rtx;
+     enum machine_mode mem_mode;
 {
-  htab_traverse (hash_table, cselib_invalidate_mem_1, mem_rtx);
+  struct cselib_invalidate_info info;
+  info.exp = mem_rtx;
+  info.mode = mem_mode;
+  htab_traverse (hash_table, cselib_invalidate_mem_1, &info);
 }

 /* Invalidate DEST, which is being assigned to or clobbered.  The second and

----------
cleanup: add additional argument, prototype updates

Index: gcc/alias.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/alias.c,v
retrieving revision 1.138
diff -u -r1.138 alias.c
--- alias.c	2001/08/22 14:34:41	1.138
+++ alias.c	2001/08/22 15:50:50
@@ -104,7 +104,8 @@
 static rtx fixed_scalar_and_varying_struct_p PARAMS ((rtx, rtx, rtx, rtx,
 						      int (*) (rtx, int)));
 static int aliases_everything_p         PARAMS ((rtx));
-static int write_dependence_p           PARAMS ((rtx, rtx, int));
+static int write_dependence_p           PARAMS ((rtx, rtx,
+						 enum machine_mode, int));
 static int nonlocal_mentioned_p         PARAMS ((rtx));

 /* Set up all info needed to perform alias analysis on memory references.  */
@@ -1906,21 +1911,23 @@
 /* Anti dependence: X is written after read in MEM takes place.  */

 int
-anti_dependence (mem, x)
+anti_dependence (mem, x, x_mode)
      rtx mem;
+     enum machine_mode x_mode;
      rtx x;
 {
-  return write_dependence_p (mem, x, /*writep=*/0);
+  return write_dependence_p (mem, x, x_mode, /*writep=*/0);
 }

 /* Output dependence: X is written after store in MEM takes place.  */

 int
-output_dependence (mem, x)
+output_dependence (mem, x, x_mode)
      register rtx mem;
+     enum machine_mode x_mode;
      register rtx x;
 {
-  return write_dependence_p (mem, x, /*writep=*/1);
+  return write_dependence_p (mem, x, x_mode, /*writep=*/1);
 }

 /* Returns non-zero if X mentions something which is not
Index: gcc/cselib.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cselib.c,v
retrieving revision 1.14
diff -u -r1.14 cselib.c
--- cselib.c	2001/08/22 14:34:53	1.14
+++ cselib.c	2001/08/22 15:51:09
@@ -61,9 +61,9 @@
 static cselib_val *cselib_lookup_mem	PARAMS ((rtx, int));
 static void cselib_invalidate_regno	PARAMS ((unsigned int,
 						 enum machine_mode));
-static int cselib_mem_conflict_p	PARAMS ((rtx, rtx));
+static int cselib_mem_conflict_p	PARAMS ((rtx, enum machine_mode, rtx));
 static int cselib_invalidate_mem_1	PARAMS ((void **, void *));
-static void cselib_invalidate_mem	PARAMS ((rtx));
+static void cselib_invalidate_mem	PARAMS ((rtx, enum machine_mode));
 static void cselib_invalidate_rtx	PARAMS ((rtx, rtx, void *));
 static void cselib_record_set		PARAMS ((rtx, cselib_val *,
 						 cselib_val *));
@@ -992,8 +992,9 @@
    Return whether this change will invalidate VAL.  */

 static int
-cselib_mem_conflict_p (mem_base, val)
+cselib_mem_conflict_p (mem_base, mem_mode, val)
      rtx mem_base;
+     enum machine_mode mem_mode;
      rtx val;
 {
   enum rtx_code code;
@@ -1018,7 +1019,7 @@
     case MEM:
       if (GET_MODE (mem_base) == BLKmode
 	  || GET_MODE (val) == BLKmode
-	  || anti_dependence (val, mem_base))
+	  || anti_dependence (val, mem_base, mem_mode))
 	return 1;

       /* The address may contain nested MEMs.  */
@@ -1033,12 +1034,12 @@
     {
       if (fmt[i] == 'e')
 	{
-	  if (cselib_mem_conflict_p (mem_base, XEXP (val, i)))
+	  if (cselib_mem_conflict_p (mem_base, mem_mode, XEXP (val, i)))
 	    return 1;
 	}
       else if (fmt[i] == 'E')
 	for (j = 0; j < XVECLEN (val, i); j++)
-	  if (cselib_mem_conflict_p (mem_base, XVECEXP (val, i, j)))
+	  if (cselib_mem_conflict_p (mem_base, mem_mode, XVECEXP (val, i, j)))
 	    return 1;
     }

@@ -1301,7 +1318,7 @@
 	  cselib_invalidate_regno (i, VOIDmode);

       if (! CONST_OR_PURE_CALL_P (insn))
-	cselib_invalidate_mem (callmem);
+	cselib_invalidate_mem (callmem, VOIDmode);
     }

   cselib_record_sets (insn);
Index: gcc/flow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/flow.c,v
retrieving revision 1.470
diff -u -r1.470 flow.c
--- flow.c	2001/08/22 14:51:32	1.470
+++ flow.c	2001/08/22 15:51:26
@@ -5810,7 +5812,7 @@
 	     rtx_equal_p does not check the alias set or flags, we also
 	     must have the potential for them to conflict (anti_dependence).  */
 	  for (temp = pbi->mem_set_list; temp != 0; temp = XEXP (temp, 1))
-	    if (anti_dependence (r, XEXP (temp, 0)))
+	    if (anti_dependence (r, XEXP (temp, 0), VOIDmode))
 	      {
 		rtx mem = XEXP (temp, 0);

@@ -7401,7 +7403,7 @@
 	      while (temp)
 		{
 		  next = XEXP (temp, 1);
-		  if (anti_dependence (XEXP (temp, 0), x))
+		  if (anti_dependence (XEXP (temp, 0), x, VOIDmode))
 		    {
 		      /* Splice temp out of the list.  */
 		      if (prev)
Index: gcc/rtl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.291
diff -u -r1.291 rtl.h
--- rtl.h	2001/08/22 14:51:31	1.291
+++ rtl.h	2001/08/22 15:51:59
@@ -1994,8 +1994,8 @@
 extern int canon_true_dependence        PARAMS ((rtx, enum machine_mode, rtx,
                                                 rtx, int (*)(rtx, int)));
 extern int read_dependence		PARAMS ((rtx, rtx));
-extern int anti_dependence		PARAMS ((rtx, rtx));
-extern int output_dependence		PARAMS ((rtx, rtx));
+extern int anti_dependence		PARAMS ((rtx, rtx, enum machine_mode));
+extern int output_dependence		PARAMS ((rtx, rtx, enum machine_mode));
 extern void mark_constant_function	PARAMS ((void));
 extern void init_alias_once		PARAMS ((void));
 extern void init_alias_analysis		PARAMS ((void));
Index: gcc/sched-deps.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/sched-deps.c,v
retrieving revision 1.23
diff -u -r1.23 sched-deps.c
--- sched-deps.c	2001/08/22 14:35:39	1.23
+++ sched-deps.c	2001/08/22 15:52:01
@@ -709,7 +709,7 @@
 	  pending_mem = deps->pending_read_mems;
 	  while (pending)
 	    {
-	      if (anti_dependence (XEXP (pending_mem, 0), t))
+	      if (anti_dependence (XEXP (pending_mem, 0), t, VOIDmode))
 		add_dependence (insn, XEXP (pending, 0), REG_DEP_ANTI);

 	      pending = XEXP (pending, 1);
@@ -720,7 +720,7 @@
 	  pending_mem = deps->pending_write_mems;
 	  while (pending)
 	    {
-	      if (output_dependence (XEXP (pending_mem, 0), t))
+	      if (output_dependence (XEXP (pending_mem, 0), t, VOIDmode))
 		add_dependence (insn, XEXP (pending, 0), REG_DEP_OUTPUT);

 	      pending = XEXP (pending, 1);




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