public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
To: Eric Botcazou <ebotcazou@libertysurf.fr>
Cc: Randolph Chung <randolph@tausq.org>,gcc@gcc.gnu.org
Subject: Re: hppa-linux regressions and 3.2.2 release
Date: Mon, 03 Feb 2003 11:42:00 -0000	[thread overview]
Message-ID: <5.2.0.9.2.20030203121659.01b62790@mail.lauterbach.com> (raw)
In-Reply-To: <200302030009.34353@enzo.bigblue.local>

[-- Attachment #1: Type: text/plain, Size: 1018 bytes --]

At 00:09 03.02.2003, Franz Sirl wrote:
>On Sunday 02 February 2003 23:33, Eric Botcazou wrote:
> > Could you post the ChangeLog entries corresponding to the patches?
>
>2002-07-21  Richard Henderson  <rth@redhat.com>
>
>         * emit-rtl.c (set_mem_attributes): Preserve indirection of PARM_DECL
>         when flag_argument_noalias == 2.
>         * alias.c (nonoverlapping_memrefs_p): Handle that.
>         * print-rtl.c (print_mem_expr): Likewise.

Unfortunately this one introduces a regression on powerpc-linux-gnu. It was 
fixed by rth a bit later by this patch:

2002-08-01  Richard Henderson  <rth@redhat.com>

         * integrate.c (copy_rtx_and_substitute): Squash MEM_EXPR when it
         refers to a subroutine parameter.

See <http://gcc.gnu.org/ml/gcc-patches/2002-08/msg00103.html>.

I quickly checked by applying this patch and "make f771 && make check-g77" 
and the regression was fixed. I started a bootstrap on i686-linux-gnu and 
powerpc-linux-gnu with this additional patch applied.

Franz.


[-- Attachment #2: gcc-hppafix-backport-2.patch --]
[-- Type: application/octet-stream, Size: 10563 bytes --]

Index: gcc/alias.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/alias.c,v
retrieving revision 1.166.2.3.2.1
diff -u -p -r1.166.2.3.2.1 alias.c
--- gcc/alias.c	14 Oct 2002 21:04:16 -0000	1.166.2.3.2.1
+++ gcc/alias.c	3 Feb 2003 11:21:00 -0000
@@ -1935,6 +1935,14 @@ nonoverlapping_memrefs_p (x, y)
       moffsetx = adjust_offset_for_component_ref (exprx, moffsetx);
       exprx = t;
     }
+  else if (TREE_CODE (exprx) == INDIRECT_REF)
+    {
+      exprx = TREE_OPERAND (exprx, 0);
+      if (flag_argument_noalias < 2
+	  || TREE_CODE (exprx) != PARM_DECL)
+	return 0;
+    }
+
   moffsety = MEM_OFFSET (y);
   if (TREE_CODE (expry) == COMPONENT_REF)
     {
@@ -1944,6 +1952,13 @@ nonoverlapping_memrefs_p (x, y)
       moffsety = adjust_offset_for_component_ref (expry, moffsety);
       expry = t;
     }
+  else if (TREE_CODE (expry) == INDIRECT_REF)
+    {
+      expry = TREE_OPERAND (expry, 0);
+      if (flag_argument_noalias < 2
+	  || TREE_CODE (expry) != PARM_DECL)
+	return 0;
+    }
 
   if (! DECL_P (exprx) || ! DECL_P (expry))
     return 0;
@@ -2012,7 +2027,7 @@ nonoverlapping_memrefs_p (x, y)
 
   /* If we don't know the size of the lower-offset value, we can't tell
      if they conflict.  Otherwise, we do the test.  */
-  return sizex >= 0 && offsety > offsetx + sizex;
+  return sizex >= 0 && offsety >= offsetx + sizex;
 }
 
 /* True dependence: X is read after store in MEM takes place.  */
Index: gcc/emit-rtl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.249.2.10.2.1
diff -u -p -r1.249.2.10.2.1 emit-rtl.c
--- gcc/emit-rtl.c	12 Sep 2002 02:27:13 -0000	1.249.2.10.2.1
+++ gcc/emit-rtl.c	3 Feb 2003 11:21:00 -0000
@@ -1698,19 +1698,22 @@ component_ref_for_mem_expr (ref)
 
 /* Given REF, a MEM, and T, either the type of X or the expression
    corresponding to REF, set the memory attributes.  OBJECTP is nonzero
-   if we are making a new object of this type.  */
+   if we are making a new object of this type.  BITPOS is nonzero if
+   there is an offset outstanding on T that will be applied later.  */
 
 void
-set_mem_attributes (ref, t, objectp)
+set_mem_attributes_minus_bitpos (ref, t, objectp, bitpos)
      rtx ref;
      tree t;
      int objectp;
+     HOST_WIDE_INT bitpos;
 {
   HOST_WIDE_INT alias = MEM_ALIAS_SET (ref);
   tree expr = MEM_EXPR (ref);
   rtx offset = MEM_OFFSET (ref);
   rtx size = MEM_SIZE (ref);
   unsigned int align = MEM_ALIGN (ref);
+  HOST_WIDE_INT apply_bitpos = 0;
   tree type;
 
   /* It can happen that type_for_mode was given a mode for which there
@@ -1779,6 +1782,7 @@ set_mem_attributes (ref, t, objectp)
 	{
 	  expr = t;
 	  offset = const0_rtx;
+	  apply_bitpos = bitpos;
 	  size = (DECL_SIZE_UNIT (t)
 		  && host_integerp (DECL_SIZE_UNIT (t), 1)
 		  ? GEN_INT (tree_low_cst (DECL_SIZE_UNIT (t), 1)) : 0);
@@ -1803,6 +1807,7 @@ set_mem_attributes (ref, t, objectp)
 	{
 	  expr = component_ref_for_mem_expr (t);
 	  offset = const0_rtx;
+	  apply_bitpos = bitpos;
 	  /* ??? Any reason the field size would be different than
 	     the size we got from the type?  */
 	}
@@ -1814,27 +1819,97 @@ set_mem_attributes (ref, t, objectp)
 
 	  do
 	    {
+	      tree index = TREE_OPERAND (t, 1);
+	      tree array = TREE_OPERAND (t, 0);
+	      tree domain = TYPE_DOMAIN (TREE_TYPE (array));
+	      tree low_bound = (domain ? TYPE_MIN_VALUE (domain) : 0);
+	      tree unit_size = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (array)));
+
+	      /* We assume all arrays have sizes that are a multiple of a byte.
+		 First subtract the lower bound, if any, in the type of the
+		 index, then convert to sizetype and multiply by the size of the
+		 array element.  */
+	      if (low_bound != 0 && ! integer_zerop (low_bound))
+		index = fold (build (MINUS_EXPR, TREE_TYPE (index),
+				     index, low_bound));
+
+	      /* If the index has a self-referential type, pass it to a
+		 WITH_RECORD_EXPR; if the component size is, pass our
+		 component to one.  */
+	      if (! TREE_CONSTANT (index)
+		  && contains_placeholder_p (index))
+		index = build (WITH_RECORD_EXPR, TREE_TYPE (index), index, t);
+	      if (! TREE_CONSTANT (unit_size)
+		  && contains_placeholder_p (unit_size))
+		unit_size = build (WITH_RECORD_EXPR, sizetype,
+				   unit_size, array);
+
 	      off_tree
 		= fold (build (PLUS_EXPR, sizetype,
 			       fold (build (MULT_EXPR, sizetype,
-					    TREE_OPERAND (t, 1),
-					    TYPE_SIZE_UNIT (TREE_TYPE (t)))),
+					    index,
+					    unit_size)),
 			       off_tree));
 	      t = TREE_OPERAND (t, 0);
 	    }
 	  while (TREE_CODE (t) == ARRAY_REF);
 
-	  if (TREE_CODE (t) == COMPONENT_REF)
+	  if (DECL_P (t))
+	    {
+	      expr = t;
+	      offset = NULL;
+	      if (host_integerp (off_tree, 1))
+		{
+		  HOST_WIDE_INT ioff = tree_low_cst (off_tree, 1);
+		  HOST_WIDE_INT aoff = (ioff & -ioff) * BITS_PER_UNIT;
+		  align = DECL_ALIGN (t);
+		  if (aoff && aoff < align)
+	            align = aoff;
+		  offset = GEN_INT (ioff);
+		  apply_bitpos = bitpos;
+		}
+	    }
+	  else if (TREE_CODE (t) == COMPONENT_REF)
 	    {
 	      expr = component_ref_for_mem_expr (t);
 	      if (host_integerp (off_tree, 1))
-		offset = GEN_INT (tree_low_cst (off_tree, 1));
+		{
+		  offset = GEN_INT (tree_low_cst (off_tree, 1));
+		  apply_bitpos = bitpos;
+		}
 	      /* ??? Any reason the field size would be different than
 		 the size we got from the type?  */
 	    }
+	  else if (flag_argument_noalias > 1
+		   && TREE_CODE (t) == INDIRECT_REF
+		   && TREE_CODE (TREE_OPERAND (t, 0)) == PARM_DECL)
+	    {
+	      expr = t;
+	      offset = NULL;
+	    }
+	}
+
+      /* If this is a Fortran indirect argument reference, record the
+	 parameter decl.  */
+      else if (flag_argument_noalias > 1
+	       && TREE_CODE (t) == INDIRECT_REF
+	       && TREE_CODE (TREE_OPERAND (t, 0)) == PARM_DECL)
+	{
+	  expr = t;
+	  offset = NULL;
 	}
     }
 
+  /* If we modified OFFSET based on T, then subtract the outstanding 
+     bit position offset.  Similarly, increase the size of the accessed
+     object to contain the negative offset.  */
+  if (apply_bitpos)
+    {
+      offset = plus_constant (offset, -(apply_bitpos / BITS_PER_UNIT));
+      if (size)
+	size = plus_constant (size, apply_bitpos / BITS_PER_UNIT);
+    }
+
   /* Now set the attributes we computed above.  */
   MEM_ATTRS (ref)
     = get_mem_attrs (alias, expr, offset, size, align, GET_MODE (ref));
@@ -1849,6 +1924,15 @@ set_mem_attributes (ref, t, objectp)
 	   || TREE_CODE (t) == ARRAY_RANGE_REF
 	   || TREE_CODE (t) == BIT_FIELD_REF)
     MEM_IN_STRUCT_P (ref) = 1;
+}
+
+void
+set_mem_attributes (ref, t, objectp)
+     rtx ref;
+     tree t;
+     int objectp;
+{
+  set_mem_attributes_minus_bitpos (ref, t, objectp, 0);
 }
 
 /* Set the alias set of MEM to SET.  */
Index: gcc/expr.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/expr.c,v
retrieving revision 1.423.2.19.4.7
diff -u -p -r1.423.2.19.4.7 expr.c
--- gcc/expr.c	11 Jan 2003 22:44:36 -0000	1.423.2.19.4.7
+++ gcc/expr.c	3 Feb 2003 11:21:01 -0000
@@ -3722,17 +3722,7 @@ expand_assignment (to, from, want_value,
 	     DECL_RTX of the parent struct.  Don't munge it.  */
 	  to_rtx = shallow_copy_rtx (to_rtx);
 
-	  set_mem_attributes (to_rtx, to, 0);
-
-	  /* If we changed MEM_EXPR, that means we're now referencing
-	     the COMPONENT_REF, which means that MEM_OFFSET must be
-	     relative to that field.  But we've not yet reflected BITPOS
-	     in TO_RTX.  This will be done in store_field.  Adjust for
-	     that by biasing MEM_OFFSET by -bitpos.  */
-	  if (MEM_EXPR (to_rtx) != old_expr && MEM_OFFSET (to_rtx)
-	      && (bitpos / BITS_PER_UNIT) != 0)
-	    set_mem_offset (to_rtx, GEN_INT (INTVAL (MEM_OFFSET (to_rtx))
-					     - (bitpos / BITS_PER_UNIT)));
+	  set_mem_attributes_minus_bitpos (to_rtx, to, 0, bitpos);
 	}
 
       /* Deal with volatile and readonly fields.  The former is only done
Index: gcc/expr.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/expr.h,v
retrieving revision 1.110.2.3.4.2
diff -u -p -r1.110.2.3.4.2 expr.h
--- gcc/expr.h	12 Sep 2002 02:27:13 -0000	1.110.2.3.4.2
+++ gcc/expr.h	3 Feb 2003 11:21:01 -0000
@@ -677,6 +677,12 @@ extern void maybe_set_unchanging PARAMS 
    corresponding to REF, set the memory attributes.  OBJECTP is nonzero
    if we are making a new object of this type.  */
 extern void set_mem_attributes PARAMS ((rtx, tree, int));
+
+/* Similar, except that BITPOS has not yet been applied to REF, so if
+   we alter MEM_OFFSET according to T then we should subtract BITPOS
+   expecting that it'll be added back in later.  */
+extern void set_mem_attributes_minus_bitpos PARAMS ((rtx, tree, int,
+						     HOST_WIDE_INT));
 #endif
 
 /* Assemble the static constant template for function entry trampolines.  */
Index: gcc/integrate.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/integrate.c,v
retrieving revision 1.184.2.1
diff -u -p -r1.184.2.1 integrate.c
--- gcc/integrate.c	12 Apr 2002 19:17:54 -0000	1.184.2.1
+++ gcc/integrate.c	3 Feb 2003 11:21:01 -0000
@@ -2320,6 +2320,13 @@ copy_rtx_and_substitute (orig, map, for_
       if (inlining && !for_lhs)
 	RTX_UNCHANGING_P (copy) = 0;
 
+      /* If inlining, squish aliasing data that references the subroutine's
+	 parameter list, since that's no longer applicable.  */
+      if (inlining && MEM_EXPR (copy)
+	  && TREE_CODE (MEM_EXPR (copy)) == INDIRECT_REF
+	  && TREE_CODE (TREE_OPERAND (MEM_EXPR (copy), 0)) == PARM_DECL)
+	set_mem_expr (copy, NULL_TREE);
+
       return copy;
 
     default:
Index: gcc/print-rtl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/print-rtl.c,v
retrieving revision 1.73.6.1
diff -u -p -r1.73.6.1 print-rtl.c
--- gcc/print-rtl.c	10 Jun 2002 21:51:06 -0000	1.73.6.1
+++ gcc/print-rtl.c	3 Feb 2003 11:21:01 -0000
@@ -92,6 +92,12 @@ print_mem_expr (outfile, expr)
 	fprintf (outfile, ".%s",
 		 IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (expr, 1))));
     }
+  else if (TREE_CODE (expr) == INDIRECT_REF)
+    {
+      fputs (" (*", outfile);
+      print_mem_expr (outfile, TREE_OPERAND (expr, 0));
+      fputs (")", outfile);
+    }
   else if (DECL_NAME (expr))
     fprintf (outfile, " %s", IDENTIFIER_POINTER (DECL_NAME (expr)));
   else if (TREE_CODE (expr) == RESULT_DECL)

  parent reply	other threads:[~2003-02-03 11:42 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-02  7:22 Randolph Chung
2003-02-02 11:08 ` Gabriel Dos Reis
2003-02-02 11:27   ` Eric Botcazou
2003-02-02 16:06 ` Eric Botcazou
2003-02-02 17:27   ` Franz Sirl
2003-02-02 22:35     ` Eric Botcazou
2003-02-02 23:09       ` Franz Sirl
2003-02-03  7:48         ` Eric Botcazou
2003-02-03 11:42           ` Franz Sirl
2003-02-03 12:07             ` Eric Botcazou
2003-02-03 11:42         ` Franz Sirl [this message]
2003-02-03 12:00           ` Gabriel Dos Reis
2003-02-03 13:18             ` Franz Sirl
2003-02-03 13:32               ` Gabriel Dos Reis
2003-02-03 13:36               ` Eric Botcazou
2003-02-09 13:19                 ` ChangeLog conventions (was: hppa-linux regressions and 3.2.2 release) Gerald Pfeifer
2003-02-11 10:20                   ` Eric Botcazou
2003-02-11 19:44                     ` Phil Edwards
2003-02-13 17:54                     ` ChangeLog conventions Gerald Pfeifer
2003-02-03 17:30               ` hppa-linux regressions and 3.2.2 release Joseph S. Myers
2003-02-03 21:01             ` Franz Sirl
2003-02-03 21:17               ` Gabriel Dos Reis
2003-02-02 18:09   ` Eric Botcazou
2003-02-02 20:19     ` Gabriel Dos Reis
2003-02-02 23:21       ` Randolph Chung
2003-02-03 10:39         ` Eric Botcazou
2003-02-03  0:25 John David Anglin
2003-02-03  2:19 ` Gabriel Dos Reis
2003-02-03  2:38   ` John David Anglin
2003-02-03 17:10 ` Joe Buck
     [not found] <no.id>
2003-02-03  5:02 ` John David Anglin
2003-02-03 11:03   ` Gabriel Dos Reis
2003-02-03 16:26   ` John David Anglin
2003-02-03 16:54     ` Gabriel Dos Reis
2003-02-03 18:02       ` John David Anglin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5.2.0.9.2.20030203121659.01b62790@mail.lauterbach.com \
    --to=franz.sirl-kernel@lauterbach.com \
    --cc=ebotcazou@libertysurf.fr \
    --cc=gcc@gcc.gnu.org \
    --cc=randolph@tausq.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).