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]

[PATCH] Fix PR32921, prune virtual operands of memory accesses based on TBAA


Now, I was totally suprised to see that while we prune virtual operands
(in the case of PR32921 a bunch of SFTs) based on the offset of the access
but not based on TBAA.  Duh.  Fixed with the following patch that will
do so for all alias symbols (apart from MPTs, those would need more
special treatment).  I also took the liberty to re-shuffle things a bit
in access_can_touch_variable.

Maybe I'm missing something obvious here, but a slightly less invasive
patch (just pruning SFTs) bootstrapped & tested fine.

This patch is currently bootstrapping and testing on 
x86_64-unknown-linux-gnu for all languages including Ada.

Danny?  Am I just crazy this day?

Thanks,
Richard.

:ADDPATCH middle-end:

2007-10-18  Richard Guenther  <rguenther@suse.de>

	PR middle-end/32921
	* tree-ssa-operands.c (access_can_touch_variable): Aliases
	with non-conflicting alias sets with the reference do not
	touch the access.  Re-structure function a bit.

Index: tree-ssa-operands.c
===================================================================
*** tree-ssa-operands.c	(revision 129403)
--- tree-ssa-operands.c	(working copy)
*************** access_can_touch_variable (tree ref, tre
*** 1198,1204 ****
  {
    bool offsetgtz = offset > 0;
    unsigned HOST_WIDE_INT uoffset = (unsigned HOST_WIDE_INT) offset;
!   tree base = ref ? get_base_address (ref) : NULL;
  
    /* If ALIAS is .GLOBAL_VAR then the memory reference REF must be
       using a call-clobbered memory tag.  By definition, call-clobbered
--- 1198,1208 ----
  {
    bool offsetgtz = offset > 0;
    unsigned HOST_WIDE_INT uoffset = (unsigned HOST_WIDE_INT) offset;
!   tree base;
! 
!   /* For NULL refs we cannot prune based on the unknown access.  */
!   if (!ref)
!     return true;
  
    /* If ALIAS is .GLOBAL_VAR then the memory reference REF must be
       using a call-clobbered memory tag.  By definition, call-clobbered
*************** access_can_touch_variable (tree ref, tre
*** 1206,1216 ****
    if (alias == gimple_global_var (cfun))
      return true;
  
    /* If ref is a TARGET_MEM_REF, just return true, as we can't really
!      disambiguate them right now.  */
!   if (ref && TREE_CODE (ref) == TARGET_MEM_REF)
      return true;
!   
    /* If ALIAS is an SFT, it can't be touched if the offset     
       and size of the access is not overlapping with the SFT offset and
       size.  This is only true if we are accessing through a pointer
--- 1210,1230 ----
    if (alias == gimple_global_var (cfun))
      return true;
  
+   /* If the alias sets of an alias does not conflict with the memory reference
+      then the access does not touch the alias.  */
+   if (flag_strict_aliasing
+       && TREE_CODE (alias) != MEMORY_PARTITION_TAG
+       && !alias_sets_conflict_p (get_alias_set (TREE_TYPE (alias)),
+ 				 get_alias_set (TREE_TYPE (ref))))
+     return false;
+ 
    /* If ref is a TARGET_MEM_REF, just return true, as we can't really
!      disambiguate them based on offsets right now.  */
!   if (TREE_CODE (ref) == TARGET_MEM_REF)
      return true;
!  
!   base = get_base_address (ref);
! 
    /* If ALIAS is an SFT, it can't be touched if the offset     
       and size of the access is not overlapping with the SFT offset and
       size.  This is only true if we are accessing through a pointer
*************** access_can_touch_variable (tree ref, tre
*** 1309,1316 ****
       my_char_ref_1 = (char[1:1] &) &my_char;
       D.874_2 = (*my_char_ref_1)[1]{lb: 1 sz: 1};
    */
!   else if (ref 
! 	   && flag_strict_aliasing
  	   && TREE_CODE (ref) != INDIRECT_REF
  	   && !MTAG_P (alias)
  	   && base
--- 1323,1329 ----
       my_char_ref_1 = (char[1:1] &) &my_char;
       D.874_2 = (*my_char_ref_1)[1]{lb: 1 sz: 1};
    */
!   else if (flag_strict_aliasing
  	   && TREE_CODE (ref) != INDIRECT_REF
  	   && !MTAG_P (alias)
  	   && base
*************** access_can_touch_variable (tree ref, tre
*** 1344,1351 ****
    /* If the offset of the access is greater than the size of one of
       the possible aliases, it can't be touching that alias, because it
       would be past the end of the structure.  */
!   else if (ref
! 	   && flag_strict_aliasing
  	   && TREE_CODE (ref) != INDIRECT_REF
  	   && !MTAG_P (alias)
  	   && !POINTER_TYPE_P (TREE_TYPE (alias))
--- 1357,1363 ----
    /* If the offset of the access is greater than the size of one of
       the possible aliases, it can't be touching that alias, because it
       would be past the end of the structure.  */
!   else if (flag_strict_aliasing
  	   && TREE_CODE (ref) != INDIRECT_REF
  	   && !MTAG_P (alias)
  	   && !POINTER_TYPE_P (TREE_TYPE (alias))


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