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]

fix another spec2000 sixtrack misscompilation


Hi,
current mainline misscompiles sixtrack (3.2 untested) for different
reason too.  The problem is fortran array indexed from 1.  Code in
set_mem_attributes ignores the lower bound of array and computes wrong
offset.  I've fixed it by copying code from get_inner_reference.
I think the function can be reorganized to use get_inner_reference
dirrectly, but I am not familiar enought with it to get this working.

Mon Sep  2 12:11:40 CEST 2002  Jan Hubicka  <jh@suse.cz>
	* emit-rtl.c (set_mem_attributes_minus_bitpos): Fix array_ref handling.
*** emit-rtl.c.old	Sun Sep  1 17:48:37 2002
--- emit-rtl.c	Sun Sep  1 18:57:54 2002
*************** set_mem_attributes_minus_bitpos (ref, t,
*** 1805,1815 ****
  
  	  do
  	    {
  	      off_tree
  		= fold (build (PLUS_EXPR, sizetype,
  			       fold (build (MULT_EXPR, sizetype,
! 					    TREE_OPERAND (t, 1),
! 					    TYPE_SIZE_UNIT (TREE_TYPE (t)))),
  			       off_tree));
  	      t = TREE_OPERAND (t, 0);
  	    }
--- 1805,1840 ----
  
  	  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,
! 					    index,
! 					    unit_size)),
  			       off_tree));
  	      t = TREE_OPERAND (t, 0);
  	    }


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