diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2019-06-13 17:00:41 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2019-06-13 15:00:41 +0000 |
commit | 983acf87d6ce85034448b8f654de457c50617090 (patch) | |
tree | 6075c4952eba390990b2664a93c58112b154e596 /gcc/tree-ssa-alias.c | |
parent | 9bc83b61ff2b3353934704befe02c2262c48d2bc (diff) |
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
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r-- | gcc/tree-ssa-alias.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index ebe05544bad..2d2b3b86cfd 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -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; } |