tree-ssa-sccvn.c (struct vn_walk_cb_data): Add orig_ref member.

2019-07-09  Richard Biener  <rguenther@suse.de>

	* tree-ssa-sccvn.c (struct vn_walk_cb_data): Add orig_ref member.
	(vn_reference_lookup_3): If the main ref has no access path recorded
	but orig_ref has use it to do access-path based disambiguation.
	(vn_reference_lookup_pieces): Adjust.
	(vn_reference_lookup): Pass down original ref if we valueized.

	* gcc.dg/tree-ssa/alias-access-path-1.c: Scan fre1 dump.
	* gcc.dg/tree-ssa/alias-access-path-2.c: Likewise.
	* gcc.dg/tree-ssa/alias-access-path-8.c: Likewise.

From-SVN: r273294
This commit is contained in:
Richard Biener 2019-07-09 08:04:37 +00:00 committed by Richard Biener
parent 5e0f7ab2fb
commit c2851dc289
6 changed files with 58 additions and 12 deletions

View file

@ -1,3 +1,11 @@
2019-07-09 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.c (struct vn_walk_cb_data): Add orig_ref member.
(vn_reference_lookup_3): If the main ref has no access path recorded
but orig_ref has use it to do access-path based disambiguation.
(vn_reference_lookup_pieces): Adjust.
(vn_reference_lookup): Pass down original ref if we valueized.
2019-07-09 Martin Liska <mliska@suse.cz>
* lto-compress.c (lto_normalized_zstd_level): Do not use

View file

@ -1,3 +1,9 @@
2019-07-09 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/alias-access-path-1.c: Scan fre1 dump.
* gcc.dg/tree-ssa/alias-access-path-2.c: Likewise.
* gcc.dg/tree-ssa/alias-access-path-8.c: Likewise.
2019-07-09 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/predicate10.adb, gnat.dg/predicate10_pkg.adb,

View file

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-fre3" } */
/* { dg-options "-O2 -fdump-tree-fre1" } */
struct foo
{
int val;
@ -18,4 +18,4 @@ test ()
return barptr->val2;
}
/* { dg-final { scan-tree-dump-times "return 123" 1 "fre3"} } */
/* { dg-final { scan-tree-dump-times "return 123" 1 "fre1"} } */

View file

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-fre3" } */
/* { dg-options "-O2 -fdump-tree-fre1" } */
struct a {
int val;
};
@ -19,4 +19,4 @@ test (int i, int j, int k, int l)
dptr->c.b[k].a2[l].val=2;
return cptr->b[i].a[j].val;
}
/* { dg-final { scan-tree-dump-times "return 123" 1 "fre3"} } */
/* { dg-final { scan-tree-dump-times "return 123" 1 "fre1"} } */

View file

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-fre3" } */
/* { dg-options "-O2 -fdump-tree-fre1" } */
struct a {
int val;
};
@ -18,4 +18,4 @@ test (int i, int j, int k, int l)
cptr2->b[k].a2[l].val=2;
return cptr->b[i].a[j].val;
}
/* { dg-final { scan-tree-dump-times "return 123" 1 "fre3"} } */
/* { dg-final { scan-tree-dump-times "return 123" 1 "fre1"} } */

View file

@ -1670,15 +1670,18 @@ struct pd_data
struct vn_walk_cb_data
{
vn_walk_cb_data (vn_reference_t vr_, tree *last_vuse_ptr_,
vn_walk_cb_data (vn_reference_t vr_, tree orig_ref_, tree *last_vuse_ptr_,
vn_lookup_kind vn_walk_kind_, bool tbaa_p_)
: vr (vr_), last_vuse_ptr (last_vuse_ptr_), vn_walk_kind (vn_walk_kind_),
tbaa_p (tbaa_p_), known_ranges (NULL)
{}
: vr (vr_), last_vuse_ptr (last_vuse_ptr_),
vn_walk_kind (vn_walk_kind_), tbaa_p (tbaa_p_), known_ranges (NULL)
{
ao_ref_init (&orig_ref, orig_ref_);
}
~vn_walk_cb_data ();
void *push_partial_def (const pd_data& pd, tree, HOST_WIDE_INT);
vn_reference_t vr;
ao_ref orig_ref;
tree *last_vuse_ptr;
vn_lookup_kind vn_walk_kind;
bool tbaa_p;
@ -2246,6 +2249,28 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
lhs_ref_ok = true;
}
/* Besides valueizing the LHS we can also use access-path based
disambiguation on the original non-valueized ref. */
if (!ref->ref
&& lhs_ref_ok
&& data->orig_ref.ref)
{
/* We want to use the non-valueized LHS for this, but avoid redundant
work. */
ao_ref *lref = &lhs_ref;
ao_ref lref_alt;
if (valueized_anything)
{
ao_ref_init (&lref_alt, lhs);
lref = &lref_alt;
}
if (!refs_may_alias_p_1 (&data->orig_ref, lref, data->tbaa_p))
{
*disambiguate_only = true;
return NULL;
}
}
/* If we reach a clobbering statement try to skip it and see if
we find a VN result with exactly the same value as the
possible clobber. In this case we can ignore the clobber
@ -2763,6 +2788,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
/* Do not update last seen VUSE after translating. */
data->last_vuse_ptr = NULL;
/* Invalidate the original access path since it now contains
the wrong base. */
data->orig_ref.ref = NULL_TREE;
/* Keep looking for the adjusted *REF / VR pair. */
return NULL;
@ -2923,6 +2951,9 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
/* Do not update last seen VUSE after translating. */
data->last_vuse_ptr = NULL;
/* Invalidate the original access path since it now contains
the wrong base. */
data->orig_ref.ref = NULL_TREE;
/* Keep looking for the adjusted *REF / VR pair. */
return NULL;
@ -2983,7 +3014,7 @@ vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type,
{
ao_ref r;
unsigned limit = PARAM_VALUE (PARAM_SCCVN_MAX_ALIAS_QUERIES_PER_ACCESS);
vn_walk_cb_data data (&vr1, NULL, kind, true);
vn_walk_cb_data data (&vr1, NULL_TREE, NULL, kind, true);
if (ao_ref_init_from_vn_reference (&r, set, type, vr1.operands))
*vnresult =
(vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse, true,
@ -3040,7 +3071,8 @@ vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind,
|| !ao_ref_init_from_vn_reference (&r, vr1.set, vr1.type,
vr1.operands))
ao_ref_init (&r, op);
vn_walk_cb_data data (&vr1, last_vuse_ptr, kind, tbaa_p);
vn_walk_cb_data data (&vr1, r.ref ? NULL_TREE : op,
last_vuse_ptr, kind, tbaa_p);
wvnresult =
(vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse, tbaa_p,
vn_reference_lookup_2,