Commit ee7904e9 by Richard Biener Committed by Richard Biener

tree-ssa-sccvn.h (vn_reference_lookup): Add last_vuse_ptr argument.

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

	* tree-ssa-sccvn.h (vn_reference_lookup): Add last_vuse_ptr
	argument.
	* tree-ssa-sccvn.c (last_vuse_ptr, vn_walk_kind): Move
	globals into...
	(struct vn_walk_cb_data): New callback data struct.
	(vn_reference_lookup_2): Adjust.
	(vn_reference_lookup_3): Likewise.
	(vn_reference_lookup_pieces): Likewise.
	(vn_reference_lookup): Likewise, get last_vuse_ptr argument.
	(visit_reference_op_load): Adjust.

From-SVN: r273042
parent 6f01ad76
2019-07-04 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.h (vn_reference_lookup): Add last_vuse_ptr
argument.
* tree-ssa-sccvn.c (last_vuse_ptr, vn_walk_kind): Move
globals into...
(struct vn_walk_cb_data): New callback data struct.
(vn_reference_lookup_2): Adjust.
(vn_reference_lookup_3): Likewise.
(vn_reference_lookup_pieces): Likewise.
(vn_reference_lookup): Likewise, get last_vuse_ptr argument.
(visit_reference_op_load): Adjust.
2019-07-04 Jakub Jelinek <jakub@redhat.com> 2019-07-04 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/91063 PR tree-optimization/91063
......
...@@ -131,8 +131,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -131,8 +131,6 @@ along with GCC; see the file COPYING3. If not see
/* There's no BB_EXECUTABLE but we can use BB_VISITED. */ /* There's no BB_EXECUTABLE but we can use BB_VISITED. */
#define BB_EXECUTABLE BB_VISITED #define BB_EXECUTABLE BB_VISITED
static tree *last_vuse_ptr;
static vn_lookup_kind vn_walk_kind;
static vn_lookup_kind default_vn_walk_kind; static vn_lookup_kind default_vn_walk_kind;
/* vn_nary_op hashtable helpers. */ /* vn_nary_op hashtable helpers. */
...@@ -1648,18 +1646,26 @@ vn_reference_lookup_1 (vn_reference_t vr, vn_reference_t *vnresult) ...@@ -1648,18 +1646,26 @@ vn_reference_lookup_1 (vn_reference_t vr, vn_reference_t *vnresult)
return NULL_TREE; return NULL_TREE;
} }
struct vn_walk_cb_data
{
vn_reference_t vr;
tree *last_vuse_ptr;
vn_lookup_kind vn_walk_kind;
};
/* Callback for walk_non_aliased_vuses. Adjusts the vn_reference_t VR_ /* Callback for walk_non_aliased_vuses. Adjusts the vn_reference_t VR_
with the current VUSE and performs the expression lookup. */ with the current VUSE and performs the expression lookup. */
static void * static void *
vn_reference_lookup_2 (ao_ref *op ATTRIBUTE_UNUSED, tree vuse, void *vr_) vn_reference_lookup_2 (ao_ref *op ATTRIBUTE_UNUSED, tree vuse, void *data_)
{ {
vn_reference_t vr = (vn_reference_t)vr_; vn_walk_cb_data *data = (vn_walk_cb_data *)data_;
vn_reference_t vr = data->vr;
vn_reference_s **slot; vn_reference_s **slot;
hashval_t hash; hashval_t hash;
if (last_vuse_ptr) if (data->last_vuse_ptr)
*last_vuse_ptr = vuse; *data->last_vuse_ptr = vuse;
/* Fixup vuse and hash. */ /* Fixup vuse and hash. */
if (vr->vuse) if (vr->vuse)
...@@ -1929,10 +1935,11 @@ basic_block vn_context_bb; ...@@ -1929,10 +1935,11 @@ basic_block vn_context_bb;
*DISAMBIGUATE_ONLY is set to true. */ *DISAMBIGUATE_ONLY is set to true. */
static void * static void *
vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
bool *disambiguate_only) bool *disambiguate_only)
{ {
vn_reference_t vr = (vn_reference_t)vr_; vn_walk_cb_data *data = (vn_walk_cb_data *)data_;
vn_reference_t vr = data->vr;
gimple *def_stmt = SSA_NAME_DEF_STMT (vuse); gimple *def_stmt = SSA_NAME_DEF_STMT (vuse);
tree base = ao_ref_base (ref); tree base = ao_ref_base (ref);
HOST_WIDE_INT offseti, maxsizei; HOST_WIDE_INT offseti, maxsizei;
...@@ -1979,7 +1986,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, ...@@ -1979,7 +1986,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
accesses as we then can use TBAA to disambiguate against the accesses as we then can use TBAA to disambiguate against the
clobbering statement when looking up a load (thus the clobbering statement when looking up a load (thus the
VN_WALKREWRITE guard). */ VN_WALKREWRITE guard). */
if (vn_walk_kind == VN_WALKREWRITE if (data->vn_walk_kind == VN_WALKREWRITE
&& is_gimple_reg_type (TREE_TYPE (lhs)) && is_gimple_reg_type (TREE_TYPE (lhs))
&& types_compatible_p (TREE_TYPE (lhs), vr->type) && types_compatible_p (TREE_TYPE (lhs), vr->type)
/* The overlap restriction breaks down when either access /* The overlap restriction breaks down when either access
...@@ -1992,16 +1999,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, ...@@ -1992,16 +1999,16 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
|| (get_alias_set (lhs) != 0 || (get_alias_set (lhs) != 0
&& ao_ref_alias_set (ref) != 0))) && ao_ref_alias_set (ref) != 0)))
{ {
tree *saved_last_vuse_ptr = last_vuse_ptr; tree *saved_last_vuse_ptr = data->last_vuse_ptr;
/* Do not update last_vuse_ptr in vn_reference_lookup_2. */ /* Do not update last_vuse_ptr in vn_reference_lookup_2. */
last_vuse_ptr = NULL; data->last_vuse_ptr = NULL;
tree saved_vuse = vr->vuse; tree saved_vuse = vr->vuse;
hashval_t saved_hashcode = vr->hashcode; hashval_t saved_hashcode = vr->hashcode;
void *res = vn_reference_lookup_2 (ref, gimple_vuse (def_stmt), vr); void *res = vn_reference_lookup_2 (ref, gimple_vuse (def_stmt), data);
/* Need to restore vr->vuse and vr->hashcode. */ /* Need to restore vr->vuse and vr->hashcode. */
vr->vuse = saved_vuse; vr->vuse = saved_vuse;
vr->hashcode = saved_hashcode; vr->hashcode = saved_hashcode;
last_vuse_ptr = saved_last_vuse_ptr; data->last_vuse_ptr = saved_last_vuse_ptr;
if (res && res != (void *)-1) if (res && res != (void *)-1)
{ {
vn_reference_t vnresult = (vn_reference_t) res; vn_reference_t vnresult = (vn_reference_t) res;
...@@ -2306,7 +2313,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, ...@@ -2306,7 +2313,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
/* 5) For aggregate copies translate the reference through them if /* 5) For aggregate copies translate the reference through them if
the copy kills ref. */ the copy kills ref. */
else if (vn_walk_kind == VN_WALKREWRITE else if (data->vn_walk_kind == VN_WALKREWRITE
&& gimple_assign_single_p (def_stmt) && gimple_assign_single_p (def_stmt)
&& (DECL_P (gimple_assign_rhs1 (def_stmt)) && (DECL_P (gimple_assign_rhs1 (def_stmt))
|| TREE_CODE (gimple_assign_rhs1 (def_stmt)) == MEM_REF || TREE_CODE (gimple_assign_rhs1 (def_stmt)) == MEM_REF
...@@ -2426,7 +2433,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, ...@@ -2426,7 +2433,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
*ref = r; *ref = r;
/* Do not update last seen VUSE after translating. */ /* Do not update last seen VUSE after translating. */
last_vuse_ptr = NULL; data->last_vuse_ptr = NULL;
/* Keep looking for the adjusted *REF / VR pair. */ /* Keep looking for the adjusted *REF / VR pair. */
return NULL; return NULL;
...@@ -2434,7 +2441,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, ...@@ -2434,7 +2441,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
/* 6) For memcpy copies translate the reference through them if /* 6) For memcpy copies translate the reference through them if
the copy kills ref. */ the copy kills ref. */
else if (vn_walk_kind == VN_WALKREWRITE else if (data->vn_walk_kind == VN_WALKREWRITE
&& is_gimple_reg_type (vr->type) && is_gimple_reg_type (vr->type)
/* ??? Handle BCOPY as well. */ /* ??? Handle BCOPY as well. */
&& (gimple_call_builtin_p (def_stmt, BUILT_IN_MEMCPY) && (gimple_call_builtin_p (def_stmt, BUILT_IN_MEMCPY)
...@@ -2584,7 +2591,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, ...@@ -2584,7 +2591,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
*ref = r; *ref = r;
/* Do not update last seen VUSE after translating. */ /* Do not update last seen VUSE after translating. */
last_vuse_ptr = NULL; data->last_vuse_ptr = NULL;
/* Keep looking for the adjusted *REF / VR pair. */ /* Keep looking for the adjusted *REF / VR pair. */
return NULL; return NULL;
...@@ -2645,13 +2652,13 @@ vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type, ...@@ -2645,13 +2652,13 @@ vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type,
{ {
ao_ref r; ao_ref r;
unsigned limit = PARAM_VALUE (PARAM_SCCVN_MAX_ALIAS_QUERIES_PER_ACCESS); unsigned limit = PARAM_VALUE (PARAM_SCCVN_MAX_ALIAS_QUERIES_PER_ACCESS);
vn_walk_kind = kind; vn_walk_cb_data data = { &vr1, NULL, kind };
if (ao_ref_init_from_vn_reference (&r, set, type, vr1.operands)) if (ao_ref_init_from_vn_reference (&r, set, type, vr1.operands))
*vnresult = *vnresult =
(vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse, (vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse,
vn_reference_lookup_2, vn_reference_lookup_2,
vn_reference_lookup_3, vn_reference_lookup_3,
vuse_valueize, limit, &vr1); vuse_valueize, limit, &data);
gcc_checking_assert (vr1.operands == shared_lookup_references); gcc_checking_assert (vr1.operands == shared_lookup_references);
} }
...@@ -2666,11 +2673,12 @@ vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type, ...@@ -2666,11 +2673,12 @@ vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type,
not exist in the hash table or if the result field of the structure not exist in the hash table or if the result field of the structure
was NULL.. VNRESULT will be filled in with the vn_reference_t was NULL.. VNRESULT will be filled in with the vn_reference_t
stored in the hashtable if one exists. When TBAA_P is false assume stored in the hashtable if one exists. When TBAA_P is false assume
we are looking up a store and treat it as having alias-set zero. */ we are looking up a store and treat it as having alias-set zero.
*LAST_VUSE_PTR will be updated with the VUSE the value lookup succeeded. */
tree tree
vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind, vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind,
vn_reference_t *vnresult, bool tbaa_p) vn_reference_t *vnresult, bool tbaa_p, tree *last_vuse_ptr)
{ {
vec<vn_reference_op_s> operands; vec<vn_reference_op_s> operands;
struct vn_reference_s vr1; struct vn_reference_s vr1;
...@@ -2703,12 +2711,12 @@ vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind, ...@@ -2703,12 +2711,12 @@ vn_reference_lookup (tree op, tree vuse, vn_lookup_kind kind,
ao_ref_init (&r, op); ao_ref_init (&r, op);
if (! tbaa_p) if (! tbaa_p)
r.ref_alias_set = r.base_alias_set = 0; r.ref_alias_set = r.base_alias_set = 0;
vn_walk_kind = kind; vn_walk_cb_data data = { &vr1, last_vuse_ptr, kind };
wvnresult = wvnresult =
(vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse, (vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse,
vn_reference_lookup_2, vn_reference_lookup_2,
vn_reference_lookup_3, vn_reference_lookup_3,
vuse_valueize, limit, &vr1); vuse_valueize, limit, &data);
gcc_checking_assert (vr1.operands == shared_lookup_references); gcc_checking_assert (vr1.operands == shared_lookup_references);
if (wvnresult) if (wvnresult)
{ {
...@@ -4063,10 +4071,8 @@ visit_reference_op_load (tree lhs, tree op, gimple *stmt) ...@@ -4063,10 +4071,8 @@ visit_reference_op_load (tree lhs, tree op, gimple *stmt)
tree result; tree result;
last_vuse = gimple_vuse (stmt); last_vuse = gimple_vuse (stmt);
last_vuse_ptr = &last_vuse;
result = vn_reference_lookup (op, gimple_vuse (stmt), result = vn_reference_lookup (op, gimple_vuse (stmt),
default_vn_walk_kind, NULL, true); default_vn_walk_kind, NULL, true, &last_vuse);
last_vuse_ptr = NULL;
/* We handle type-punning through unions by value-numbering based /* We handle type-punning through unions by value-numbering based
on offset and size of the access. Be prepared to handle a on offset and size of the access. Be prepared to handle a
......
...@@ -234,7 +234,8 @@ vec<vn_reference_op_s> vn_reference_operands_for_lookup (tree); ...@@ -234,7 +234,8 @@ vec<vn_reference_op_s> vn_reference_operands_for_lookup (tree);
tree vn_reference_lookup_pieces (tree, alias_set_type, tree, tree vn_reference_lookup_pieces (tree, alias_set_type, tree,
vec<vn_reference_op_s> , vec<vn_reference_op_s> ,
vn_reference_t *, vn_lookup_kind); vn_reference_t *, vn_lookup_kind);
tree vn_reference_lookup (tree, tree, vn_lookup_kind, vn_reference_t *, bool); tree vn_reference_lookup (tree, tree, vn_lookup_kind, vn_reference_t *, bool,
tree * = NULL);
void vn_reference_lookup_call (gcall *, vn_reference_t *, vn_reference_t); void vn_reference_lookup_call (gcall *, vn_reference_t *, vn_reference_t);
vn_reference_t vn_reference_insert_pieces (tree, alias_set_type, tree, vn_reference_t vn_reference_insert_pieces (tree, alias_set_type, tree,
vec<vn_reference_op_s> , vec<vn_reference_op_s> ,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment