[PATCH] Make alias_sets_conflict_p less conservative

Richard Guenther rguenther@suse.de
Tue Mar 4 20:59:00 GMT 2008


This makes alias_sets_conflict_p less conservative.  rev 34373 (Kenner)
added a check that makes a structure containing a member with alias
set zero alias everything.  Which IMHO is non-obvious and pessimizes
for example the testcase in PR27799.  Richard, can you explain this
change?

I'll bootstrap and test this, but posted for enlightening comments early.
(I can imagine latent bugs that make this necessary, but not a
fundamental alias rule?)

Thanks,
Richard.

2008-03-04  Richard Guenther  <rguenther@suse.de>

	PR middle-end/27799
	* alias.c (alias_sets_conflict_p): A alias set zero member
	in a structure does not mean the structure aliases with
	everything.

	* gcc.dg/alias-2.c: Adjust.
	* gcc.dg/alias-12.c: New testcase.

Index: alias.c
===================================================================
*** alias.c	(revision 132816)
--- alias.c	(working copy)
*************** alias_sets_conflict_p (alias_set_type se
*** 325,341 ****
    /* See if the first alias set is a subset of the second.  */
    ase = get_alias_set_entry (set1);
    if (ase != 0
!       && (ase->has_zero_child
! 	  || splay_tree_lookup (ase->children,
! 				(splay_tree_key) set2)))
      return 1;
  
    /* Now do the same, but with the alias sets reversed.  */
    ase = get_alias_set_entry (set2);
    if (ase != 0
!       && (ase->has_zero_child
! 	  || splay_tree_lookup (ase->children,
! 				(splay_tree_key) set1)))
      return 1;
  
    /* The two alias sets are distinct and neither one is the
--- 325,339 ----
    /* See if the first alias set is a subset of the second.  */
    ase = get_alias_set_entry (set1);
    if (ase != 0
!       && splay_tree_lookup (ase->children,
! 			    (splay_tree_key) set2))
      return 1;
  
    /* Now do the same, but with the alias sets reversed.  */
    ase = get_alias_set_entry (set2);
    if (ase != 0
!       && splay_tree_lookup (ase->children,
! 			    (splay_tree_key) set1))
      return 1;
  
    /* The two alias sets are distinct and neither one is the
Index: testsuite/gcc.dg/alias-2.c
===================================================================
*** testsuite/gcc.dg/alias-2.c	(revision 132816)
--- testsuite/gcc.dg/alias-2.c	(working copy)
*************** struct foo {
*** 11,16 ****
  int
  sub1 (long long int foobar)
  {
!   struct foo *tmp = (struct foo *) &foobar; // { dg-warning "type-punned pointer might" "" }
    return tmp->i;
  }
--- 11,16 ----
  int
  sub1 (long long int foobar)
  {
!   struct foo *tmp = (struct foo *) &foobar; // { dg-warning "type-punned pointer will" "" }
    return tmp->i;
  }
Index: testsuite/gcc.dg/alias-12.c
===================================================================
*** testsuite/gcc.dg/alias-12.c	(revision 0)
--- testsuite/gcc.dg/alias-12.c	(revision 0)
***************
*** 0 ****
--- 1,27 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -fdump-tree-optimized" } */
+ 
+ extern void abort (void);
+ 
+ struct X {double m; int x;};
+ struct Y {int y; short d;};
+ struct YY {int y; short d; char c;};
+ 
+ int foo(struct X *x,  struct Y *y)
+ {
+   x->x =  0;
+   y->y =  1;
+   if (x->x != 0)
+     abort ();
+ }
+ 
+ int foo_no(struct X *x,  struct YY *y)
+ {
+   x->x =  0;
+   y->y =  1;
+   if (x->x != 0)
+     abort ();
+ }
+ 
+ /* { dg-final { scan-tree-dump-not "abort" "optimized" } } */
+ /* { dg-final { cleanup-tree-dump "optimized" } } */



More information about the Gcc-patches mailing list