From 1be54209b30e4ace3ec771f2dfab687d451fbbf8 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 3 Jun 2019 10:45:38 +0000 Subject: [PATCH] tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Get original full reference tree and record in ref->ref. 2019-06-03 Richard Biener * 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. From-SVN: r271860 --- gcc/ChangeLog | 11 +++++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-1.c | 5 +++-- gcc/tree-ssa-alias.c | 6 ++++-- gcc/tree-ssa-sccvn.c | 9 +++++---- gcc/tree-ssa-sccvn.h | 2 +- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6529d0e24a0..c68c2d9a625 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2019-06-03 Richard Biener + + * 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. + 2019-06-03 Martin Liska * fold-const.c (operand_equal_p): Fix typo as compare_tree_int diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 75e38b8cf6a..0621f68cb38 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-06-03 Richard Biener + + * gcc.dg/tree-ssa/alias-access-path-1.c: Scan fre1. + 2019-06-03 Richard Biener PR tree-optimization/90716 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-1.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-1.c index 264f72aff0a..63722a5d0fd 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-1.c @@ -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"} } */ diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 429288b6ca5..dd4e3b7aaa9 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1013,7 +1013,8 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2) } 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); } @@ -1026,7 +1027,8 @@ nonoverlapping_component_refs_of_decl_p (tree ref1, tree ref2) } 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); } diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index b4f626000dd..8c0c8b2c566 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -995,7 +995,7 @@ copy_reference_ops_from_ref (tree ref, vec *result) bool ao_ref_init_from_vn_reference (ao_ref *ref, alias_set_type set, tree type, - vec ops) + vec ops, tree orig_ref) { vn_reference_op_t op; unsigned i; @@ -1149,7 +1149,7 @@ ao_ref_init_from_vn_reference (ao_ref *ref, 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 vuse, void *vr_, { 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, vn_lookup_kind kind, 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; diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h index bd661bc651c..ec32dcb4990 100644 --- a/gcc/tree-ssa-sccvn.h +++ b/gcc/tree-ssa-sccvn.h @@ -229,7 +229,7 @@ vn_nary_op_t vn_nary_op_insert (tree, tree); 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 ); + vec, tree = NULL_TREE); vec vn_reference_operands_for_lookup (tree); tree vn_reference_lookup_pieces (tree, alias_set_type, tree, vec , -- 2.30.2