re PR tree-optimization/90869 (Non-disambiguated memory accesses)

PR tree-optimize/90869
	* tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Watch for view
	converts in MEM_REF referencing decl rather than view converts
	from decl type to MEM_REF type.

	* g++.dg/tree-ssa/alias-access-path-1.C: New testcase.

From-SVN: r272247
This commit is contained in:
Jan Hubicka 2019-06-13 17:00:41 +02:00 committed by Jan Hubicka
parent 9bc83b61ff
commit 983acf87d6
4 changed files with 52 additions and 5 deletions

View File

@ -1,3 +1,10 @@
2019-06-13 Jan Hubicka <hubicka@ucw.cz>
PR tree-optimization/90869
* tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Watch for view
converts in MEM_REF referencing decl rather than view converts
from decl type to MEM_REF type.
2019-06-13 Richard Biener <rguenther@suse.de>
PR tree-optimization/90856

View File

@ -1,3 +1,8 @@
2019-06-13 Jan Hubicka <hubicka@ucw.cz>
PR tree-optimization/90869
* g++.dg/tree-ssa/alias-access-path-1.C: New testcase.
2019-06-13 Richard Biener <rguenther@suse.de>
PR tree-optimization/90856

View File

@ -0,0 +1,24 @@
/* { dg-do compile } */
/* { dg-options "-O3 -fdump-tree-fre1" } */
struct a {int a1; int a2;};
struct b:a {};
struct b bvar,*bptr2;
int
test(void)
{
struct a *bptr = &bvar;
bptr->a2=0;
bptr2->a1=1;
return bptr->a2;
}
int
test2(void)
{
struct b *bptr = &bvar;
bptr->a2=0;
bptr2->a1=1;
return bptr->a2;
}
/* { dg-final { scan-tree-dump-times "return 0" 2 "fre1" } } */

View File

@ -1370,11 +1370,16 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1,
poly_offset_int doffset2 = offset2;
if (TREE_CODE (dbase2) == MEM_REF
|| TREE_CODE (dbase2) == TARGET_MEM_REF)
doffset2 -= mem_ref_offset (dbase2) << LOG2_BITS_PER_UNIT;
{
doffset2 -= mem_ref_offset (dbase2) << LOG2_BITS_PER_UNIT;
tree ptrtype2 = TREE_TYPE (TREE_OPERAND (dbase2, 1));
/* If second reference is view-converted, give up now. */
if (same_type_for_tbaa (TREE_TYPE (dbase2), TREE_TYPE (ptrtype2)) != 1)
return true;
}
/* If either reference is view-converted, give up now. */
if (same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) != 1
|| same_type_for_tbaa (TREE_TYPE (dbase2), TREE_TYPE (base2)) != 1)
/* If first reference is view-converted, give up now. */
if (same_type_for_tbaa (TREE_TYPE (base1), TREE_TYPE (ptrtype1)) != 1)
return true;
/* If both references are through the same type, they do not alias
@ -1408,7 +1413,13 @@ indirect_ref_may_alias_decl_p (tree ref1 ATTRIBUTE_UNUSED, tree base1,
offset1, max_size1,
ref2,
ref2_alias_set, base2_alias_set,
offset2, max_size2, true);
offset2, max_size2,
/* Only if the other reference is actual
decl we can safely check only toplevel
part of access path 1. */
same_type_for_tbaa (TREE_TYPE (dbase2),
TREE_TYPE (base2))
== 1);
return true;
}