+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
+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
--- /dev/null
+/* { 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" } } */
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
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;
}