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]
Other format: [Raw text]

Re: 12 GCC regressions, 1 new, with your patch on 2002-07-25T19:37:38Z.


On Thu, Jul 25, 2002 at 11:13:42PM +0000, GCC regression checker wrote:
> native gcc.sum gcc.c-torture/execute/960512-1.c

The problem is that we generated a+72 for the a[9] store
instead of a+36.  I.e. we applied the offset from A twice.
Which broke alias analysis of course.

This cleans up a hack that I'd added for dealing with this
issue wrt COMPONENT_REFs.  i686 testing still in progress.


r~


	* emit-rtl.c (set_mem_attributes_minus_bitpos): Rename from
	set_mem_attributes and add BITPOS argument.  Subtract it from
	OFFSET when same is adjusted.
	(set_mem_attributes): New wrapper function.
	* expr.c (expand_assignment): Use set_mem_attributes_minus_bitpos;
	remove offset adjustment hack.
	* expr.h (set_mem_attributes_minus_bitpos): Declare.

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.287
diff -c -p -d -r1.287 emit-rtl.c
*** emit-rtl.c	25 Jul 2002 17:33:43 -0000	1.287
--- emit-rtl.c	27 Jul 2002 21:52:26 -0000
*************** component_ref_for_mem_expr (ref)
*** 1679,1697 ****
  
  /* 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.  */
  
  void
! set_mem_attributes (ref, t, objectp)
       rtx ref;
       tree t;
       int objectp;
  {
    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);
    tree type;
  
    /* It can happen that type_for_mode was given a mode for which there
--- 1679,1700 ----
  
  /* 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.  BITPOS is nonzero if
!    there is an offset outstanding on T that will be applied later.  */
  
  void
! 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
*************** set_mem_attributes (ref, t, objectp)
*** 1760,1765 ****
--- 1763,1769 ----
  	{
  	  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);
*************** set_mem_attributes (ref, t, objectp)
*** 1784,1789 ****
--- 1788,1794 ----
  	{
  	  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?  */
  	}
*************** set_mem_attributes (ref, t, objectp)
*** 1817,1829 ****
  		  if (aoff && aoff < align)
  	            align = aoff;
  		  offset = GEN_INT (ioff);
  		}
  	    }
  	  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));
  	      /* ??? Any reason the field size would be different than
  		 the size we got from the type?  */
  	    }
--- 1822,1838 ----
  		  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));
! 		  apply_bitpos = bitpos;
! 		}
  	      /* ??? Any reason the field size would be different than
  		 the size we got from the type?  */
  	    }
*************** set_mem_attributes (ref, t, objectp)
*** 1847,1852 ****
--- 1856,1866 ----
  	}
      }
  
+   /* If we modified OFFSET based on T, then subtract the outstanding 
+      bit position offset.  */
+   if (apply_bitpos)
+     offset = plus_constant (offset, -(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));
*************** set_mem_attributes (ref, t, objectp)
*** 1861,1866 ****
--- 1875,1889 ----
  	   || 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: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.471
diff -c -p -d -r1.471 expr.c
*** expr.c	24 Jul 2002 22:05:19 -0000	1.471
--- expr.c	27 Jul 2002 21:52:26 -0000
*************** expand_assignment (to, from, want_value,
*** 3846,3862 ****
  	     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)));
  	}
  
        /* Deal with volatile and readonly fields.  The former is only done
--- 3846,3852 ----
  	     DECL_RTX of the parent struct.  Don't munge it.  */
  	  to_rtx = shallow_copy_rtx (to_rtx);
  
! 	  set_mem_attributes_minus_bitpos (to_rtx, to, 0, bitpos);
  	}
  
        /* Deal with volatile and readonly fields.  The former is only done
Index: expr.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.h,v
retrieving revision 1.118
diff -c -p -d -r1.118 expr.h
*** expr.h	16 Jul 2002 20:58:56 -0000	1.118
--- expr.h	27 Jul 2002 21:52:26 -0000
*************** extern void maybe_set_unchanging PARAMS 
*** 666,671 ****
--- 666,677 ----
     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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]