diff mbox

[PR49888,VTA] don't keep VALUEs bound to modified MEMs

Message ID or395oyxfi.fsf@livre.localdomain
State New
Headers show

Commit Message

Alexandre Oliva June 22, 2012, 12:58 a.m. UTC
On Jun 20, 2012, Richard Guenther <richard.guenther@gmail.com> wrote:

> I have a question on the pre-existing condition

> -      if (GET_CODE (y) == AND || ysize < -INTVAL (XEXP (x, 1)))
>         xsize = -1;

> so if this condition is not true then we simply strip off the AND of X and
> do not adjust xsize at all?  Likewise we do not adjust c?  How can that
> be conservatively correct?

Yeah, xsize = -1 makes x “infinitely large”, so it will overlap if the
RTXs are in any way related, or something like that.

> Thus, I'd rather see

>    if (GET_CODE (x) == AND && CONST_INT_P (XEXP (x, 1)))
>      {
> +      HOST_WIDE_INT sc = INTVAL (XEXP (x, 1));
> +      unsigned HOST_WIDE_INT uc = sc;
> +      if (xsize > 0 && sc < 0 && -uc == (uc & -uc))
> +       {
> +         xsize -= sc + 1;
> +         c -= sc;
>            return memrefs_conflict_p (xsize, canon_rtx (XEXP (x, 0)),
> ysize, y, c);
>          }
>       }

> as the sole supported case.

Ack.  Regstrapped successfully, checking this in.
diff mbox

Patch

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	PR debug/53671
	PR debug/49888
	* alias.c (memrefs_conflict_p): Improve handling of AND for
	alignment.
	
Index: gcc/alias.c
===================================================================
--- gcc/alias.c.orig	2012-06-21 15:05:48.144424495 -0300
+++ gcc/alias.c	2012-06-21 15:21:56.000000000 -0300
@@ -2097,25 +2097,32 @@  memrefs_conflict_p (int xsize, rtx x, in
 	break;
       }
 
-  /* Treat an access through an AND (e.g. a subword access on an Alpha)
-     as an access with indeterminate size.  Assume that references
-     besides AND are aligned, so if the size of the other reference is
-     at least as large as the alignment, assume no other overlap.  */
+  /* Deal with alignment ANDs by adjusting offset and size so as to
+     cover the maximum range, without taking any previously known
+     alignment into account.  */
   if (GET_CODE (x) == AND && CONST_INT_P (XEXP (x, 1)))
     {
-      if (GET_CODE (y) == AND || ysize < -INTVAL (XEXP (x, 1)))
-	xsize = -1;
-      return memrefs_conflict_p (xsize, canon_rtx (XEXP (x, 0)), ysize, y, c);
+      HOST_WIDE_INT sc = INTVAL (XEXP (x, 1));
+      unsigned HOST_WIDE_INT uc = sc;
+      if (xsize > 0 && sc < 0 && -uc == (uc & -uc))
+	{
+	  xsize -= sc + 1;
+	  c -= sc;
+	  return memrefs_conflict_p (xsize, canon_rtx (XEXP (x, 0)),
+				     ysize, y, c);
+	}
     }
   if (GET_CODE (y) == AND && CONST_INT_P (XEXP (y, 1)))
     {
-      /* ??? If we are indexing far enough into the array/structure, we
-	 may yet be able to determine that we can not overlap.  But we
-	 also need to that we are far enough from the end not to overlap
-	 a following reference, so we do nothing with that for now.  */
-      if (GET_CODE (x) == AND || xsize < -INTVAL (XEXP (y, 1)))
-	ysize = -1;
-      return memrefs_conflict_p (xsize, x, ysize, canon_rtx (XEXP (y, 0)), c);
+      HOST_WIDE_INT sc = INTVAL (XEXP (y, 1));
+      unsigned HOST_WIDE_INT uc = sc;
+      if (ysize > 0 && sc < 0 && -uc == (uc & -uc))
+	{
+	  ysize -= sc + 1;
+	  c += sc;
+	  return memrefs_conflict_p (xsize, x,
+				     ysize, canon_rtx (XEXP (y, 0)), c);
+	}
     }
 
   if (CONSTANT_P (x))