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: [PATCH][alias-improvements] Throttle down TBAA for Fortran


On Mon, 19 Jan 2009, Richard Guenther wrote:

> 
> Fortran has a type merging problem (like it has a function decl merging
> problem).  This causes us to miscompile protein on the alias-improvements
> branch.
> 
> Fixed with the following ugl^Wnice hack.

Well, maybe the following is slightly less embarassing ;)  At least
it looks like type unification and TYPE_CANONICAL should work
semi-automatically by the tree.c machinery - but ARRAY_TYPEs seem
to have too many knobs to make differing types ...

Richard.

2009-01-19  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-alias.c (same_type_for_tbaa): Never say that two
	array types are not equal - that is too unreliable.
	(refs_may_alias_p): Skip first component for path based
	type disambiguation.

Index: gcc/tree-ssa-alias.c
===================================================================
*** gcc/tree-ssa-alias.c	(revision 143496)
--- gcc/tree-ssa-alias.c	(working copy)
*************** same_type_for_tbaa (tree type1, tree typ
*** 373,379 ****
      return -1;
  
    /* Compare the canonical types.  */
!   return (TYPE_CANONICAL (type1) == TYPE_CANONICAL (type2)) ? 1 : 0;
  }
  
  /* Return true, if the two memory references REF1 and REF2 may alias.  */
--- 373,390 ----
      return -1;
  
    /* Compare the canonical types.  */
!   if (TYPE_CANONICAL (type1) == TYPE_CANONICAL (type2))
!     return 1;
! 
!   /* ???  Array types are not properly unified in all cases as we have
!      spurious changes in the index types for example.  Removing this
!      causes all sorts of problems with the Fortran frontend.  */
!   if (TREE_CODE (type1) == ARRAY_TYPE
!       || TREE_CODE (type2) == ARRAY_TYPE)
!     return -1;
! 
!   /* The types are known to be not equal.  */
!   return 0;
  }
  
  /* Return true, if the two memory references REF1 and REF2 may alias.  */
*************** refs_may_alias_p (tree ref1, tree ref2)
*** 520,526 ****
        int same_p;
        /* Now search for the type of base1 in the access path of ref2.  This
  	 would be a common base for doing offset based disambiguation on.  */
!       refp = &ref2;
        while (handled_component_p (*refp)
  	     && same_type_for_tbaa (TREE_TYPE (*refp),
  				    TREE_TYPE (base1)) == 0)
--- 531,538 ----
        int same_p;
        /* Now search for the type of base1 in the access path of ref2.  This
  	 would be a common base for doing offset based disambiguation on.  */
!       /* Skip the outermost ref - we would have caught that earlier.  */
!       refp = &TREE_OPERAND (ref2, 0);
        while (handled_component_p (*refp)
  	     && same_type_for_tbaa (TREE_TYPE (*refp),
  				    TREE_TYPE (base1)) == 0)
*************** refs_may_alias_p (tree ref1, tree ref2)
*** 537,543 ****
  	  return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
  	}
        /* If we didn't find a common base, try the other way around.  */
!       refp = &ref1;
        while (handled_component_p (*refp)
  	     && same_type_for_tbaa (TREE_TYPE (*refp),
  				    TREE_TYPE (base2)) == 0)
--- 549,555 ----
  	  return ranges_overlap_p (offset1, max_size1, offset2, max_size2);
  	}
        /* If we didn't find a common base, try the other way around.  */
!       refp = &TREE_OPERAND (ref1, 0);
        while (handled_component_p (*refp)
  	     && same_type_for_tbaa (TREE_TYPE (*refp),
  				    TREE_TYPE (base2)) == 0)


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