* [PATCH] Improve alias during VN
@ 2019-06-03 10:43 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2019-06-03 10:43 UTC (permalink / raw)
To: gcc-patches
As Honza noticed using a valueized ref makes us no longer to path
based disambiguation. There's not a reason to not use the
non-valueized ref there though so the following does that.
I had to fixup nonoverlapping_component_refs_of_decl_p
because while ->base may be valuezied to a decl ->ref
may still be indirect.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2019-06-03 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Get original
full reference tree and record in ref->ref.
(vn_reference_lookup_3): Pass in original ref to
ao_ref_init_from_vn_reference.
(vn_reference_lookup): Likewise.
* tree-ssa-sccvn.h (ao_ref_init_from_vn_reference): Adjust prototype.
* tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p):
Handle non-decl bases in the original reference.
* gcc.dg/tree-ssa/alias-access-path-1.c: Scan fre1.
Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c (revision 271803)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -995,7 +995,7 @@ copy_reference_ops_from_ref (tree ref, v
bool
ao_ref_init_from_vn_reference (ao_ref *ref,
alias_set_type set, tree type,
- vec<vn_reference_op_s> ops)
+ vec<vn_reference_op_s> ops, tree orig_ref)
{
vn_reference_op_t op;
unsigned i;
@@ -1149,7 +1149,7 @@ ao_ref_init_from_vn_reference (ao_ref *r
if (base == NULL_TREE)
return false;
- ref->ref = NULL_TREE;
+ ref->ref = orig_ref;
ref->base = base;
ref->ref_alias_set = set;
if (base_alias_set != -1)
@@ -1976,7 +1976,8 @@ vn_reference_lookup_3 (ao_ref *ref, tree
{
lhs_ref_ok = ao_ref_init_from_vn_reference (&lhs_ref,
get_alias_set (lhs),
- TREE_TYPE (lhs), lhs_ops);
+ TREE_TYPE (lhs), lhs_ops,
+ lhs);
if (lhs_ref_ok
&& !refs_may_alias_p_1 (ref, &lhs_ref, true))
{
@@ -2718,7 +2719,7 @@ vn_reference_lookup (tree op, tree vuse,
Otherwise preserve the full reference for advanced TBAA. */
if (!valuezied_anything
|| !ao_ref_init_from_vn_reference (&r, vr1.set, vr1.type,
- vr1.operands))
+ vr1.operands, op))
ao_ref_init (&r, op);
if (! tbaa_p)
r.ref_alias_set = r.base_alias_set = 0;
Index: gcc/tree-ssa-sccvn.h
===================================================================
--- gcc/tree-ssa-sccvn.h (revision 271803)
+++ gcc/tree-ssa-sccvn.h (working copy)
@@ -229,7 +229,7 @@ vn_nary_op_t vn_nary_op_insert (tree, tr
vn_nary_op_t vn_nary_op_insert_pieces (unsigned int, enum tree_code,
tree, tree *, tree, unsigned int);
bool ao_ref_init_from_vn_reference (ao_ref *, alias_set_type, tree,
- vec<vn_reference_op_s> );
+ vec<vn_reference_op_s>, tree = NULL_TREE);
vec<vn_reference_op_s> vn_reference_operands_for_lookup (tree);
tree vn_reference_lookup_pieces (tree, alias_set_type, tree,
vec<vn_reference_op_s> ,
Index: gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-1.c
===================================================================
--- gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-1.c (revision 271803)
+++ gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-1.c (working copy)
@@ -1,5 +1,6 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-fre3 -fno-tree-sra" } */
+/* { dg-options "-O2 -fdump-tree-fre1 -fno-tree-sra" } */
+
struct foo
{
int val;
@@ -18,4 +19,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"} } */
Index: gcc/tree-ssa-alias.c
===================================================================
--- gcc/tree-ssa-alias.c (revision 271809)
+++ gcc/tree-ssa-alias.c (working copy)
@@ -1001,7 +1001,8 @@ nonoverlapping_component_refs_of_decl_p
}
if (TREE_CODE (ref1) == MEM_REF)
{
- if (!integer_zerop (TREE_OPERAND (ref1, 1)))
+ if (!integer_zerop (TREE_OPERAND (ref1, 1))
+ || TREE_CODE (TREE_OPERAND (ref1, 0)) != ADDR_EXPR)
return false;
ref1 = TREE_OPERAND (TREE_OPERAND (ref1, 0), 0);
}
@@ -1014,7 +1015,8 @@ nonoverlapping_component_refs_of_decl_p
}
if (TREE_CODE (ref2) == MEM_REF)
{
- if (!integer_zerop (TREE_OPERAND (ref2, 1)))
+ if (!integer_zerop (TREE_OPERAND (ref2, 1))
+ || TREE_CODE (TREE_OPERAND (ref2, 0)) != ADDR_EXPR)
return false;
ref2 = TREE_OPERAND (TREE_OPERAND (ref2, 0), 0);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-06-03 10:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-03 10:43 [PATCH] Improve alias during VN Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).