aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-alias.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2012-08-22 13:17:26 +0000
committerRichard Guenther <rguenther@suse.de>2012-08-22 13:17:26 +0000
commit7776b8b0c8638498cdb6cc7d4b7547387ec1f3c9 (patch)
tree34c557fa3311568283166d9d30556e185c013ce5 /gcc/tree-ssa-alias.c
parent111c184af03c19530e730bd968329ff3dc475a7d (diff)
2012-08-22 Richard Guenther <rguenther@suse.de>
PR tree-optimization/46590 * tree-ssa-alias.h (get_continuation_for_phi): Add alias query counter output argument. (walk_non_aliased_vuses): Add alias query counter argument to the walker callback. * tree-ssa-alias.c (maybe_skip_until): Add alias query counter output argument and count alias queries. (get_continuation_for_phi_1): Likewise. (get_continuation_for_phi): Likewise. (walk_non_aliased_vuses): Add alias query counter argument to the walker callback and allow it to abort the walk by returning -1. * tree-ssa-pre.c (translate_vuse_through_block): Adjust. * tree-ssa-sccvn.c (vn_reference_lookup_2): Add alias query counter parmeter, abort walk if that is bigger than --param sccvn-max-alias-queries-per-access. * params.def (sccvn-max-alias-queries-per-access): New param. * doc/invoke.texi (sccvn-max-alias-queries-per-access): Document. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@190594 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r--gcc/tree-ssa-alias.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index be0aa432b4f..574f418447d 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1929,7 +1929,7 @@ stmt_kills_ref_p (gimple stmt, tree ref)
static bool
maybe_skip_until (gimple phi, tree target, ao_ref *ref,
- tree vuse, bitmap *visited)
+ tree vuse, unsigned int *cnt, bitmap *visited)
{
basic_block bb = gimple_bb (phi);
@@ -1948,15 +1948,20 @@ maybe_skip_until (gimple phi, tree target, ao_ref *ref,
/* An already visited PHI node ends the walk successfully. */
if (bitmap_bit_p (*visited, SSA_NAME_VERSION (PHI_RESULT (def_stmt))))
return true;
- vuse = get_continuation_for_phi (def_stmt, ref, visited);
+ vuse = get_continuation_for_phi (def_stmt, ref, cnt, visited);
if (!vuse)
return false;
continue;
}
- /* A clobbering statement or the end of the IL ends it failing. */
- else if (gimple_nop_p (def_stmt)
- || stmt_may_clobber_ref_p_1 (def_stmt, ref))
+ else if (gimple_nop_p (def_stmt))
return false;
+ else
+ {
+ /* A clobbering statement or the end of the IL ends it failing. */
+ ++*cnt;
+ if (stmt_may_clobber_ref_p_1 (def_stmt, ref))
+ return false;
+ }
/* If we reach a new basic-block see if we already skipped it
in a previous walk that ended successfully. */
if (gimple_bb (def_stmt) != bb)
@@ -1976,7 +1981,7 @@ maybe_skip_until (gimple phi, tree target, ao_ref *ref,
static tree
get_continuation_for_phi_1 (gimple phi, tree arg0, tree arg1,
- ao_ref *ref, bitmap *visited)
+ ao_ref *ref, unsigned int *cnt, bitmap *visited)
{
gimple def0 = SSA_NAME_DEF_STMT (arg0);
gimple def1 = SSA_NAME_DEF_STMT (arg1);
@@ -1989,14 +1994,14 @@ get_continuation_for_phi_1 (gimple phi, tree arg0, tree arg1,
&& dominated_by_p (CDI_DOMINATORS,
gimple_bb (def1), gimple_bb (def0))))
{
- if (maybe_skip_until (phi, arg0, ref, arg1, visited))
+ if (maybe_skip_until (phi, arg0, ref, arg1, cnt, visited))
return arg0;
}
else if (gimple_nop_p (def1)
|| dominated_by_p (CDI_DOMINATORS,
gimple_bb (def0), gimple_bb (def1)))
{
- if (maybe_skip_until (phi, arg1, ref, arg0, visited))
+ if (maybe_skip_until (phi, arg1, ref, arg0, cnt, visited))
return arg1;
}
/* Special case of a diamond:
@@ -2015,6 +2020,7 @@ get_continuation_for_phi_1 (gimple phi, tree arg0, tree arg1,
else if ((common_vuse = gimple_vuse (def0))
&& common_vuse == gimple_vuse (def1))
{
+ *cnt += 2;
if (!stmt_may_clobber_ref_p_1 (def0, ref)
&& !stmt_may_clobber_ref_p_1 (def1, ref))
return common_vuse;
@@ -2027,11 +2033,12 @@ get_continuation_for_phi_1 (gimple phi, tree arg0, tree arg1,
/* Starting from a PHI node for the virtual operand of the memory reference
REF find a continuation virtual operand that allows to continue walking
statements dominating PHI skipping only statements that cannot possibly
- clobber REF. Returns NULL_TREE if no suitable virtual operand can
- be found. */
+ clobber REF. Increments *CNT for each alias disambiguation done.
+ Returns NULL_TREE if no suitable virtual operand can be found. */
tree
-get_continuation_for_phi (gimple phi, ao_ref *ref, bitmap *visited)
+get_continuation_for_phi (gimple phi, ao_ref *ref,
+ unsigned int *cnt, bitmap *visited)
{
unsigned nargs = gimple_phi_num_args (phi);
@@ -2068,7 +2075,8 @@ get_continuation_for_phi (gimple phi, ao_ref *ref, bitmap *visited)
for (i = 0; i < nargs; ++i)
{
arg1 = PHI_ARG_DEF (phi, i);
- arg0 = get_continuation_for_phi_1 (phi, arg0, arg1, ref, visited);
+ arg0 = get_continuation_for_phi_1 (phi, arg0, arg1, ref,
+ cnt, visited);
if (!arg0)
return NULL_TREE;
}
@@ -2099,11 +2107,12 @@ get_continuation_for_phi (gimple phi, ao_ref *ref, bitmap *visited)
void *
walk_non_aliased_vuses (ao_ref *ref, tree vuse,
- void *(*walker)(ao_ref *, tree, void *),
+ void *(*walker)(ao_ref *, tree, unsigned int, void *),
void *(*translate)(ao_ref *, tree, void *), void *data)
{
bitmap visited = NULL;
void *res;
+ unsigned int cnt = 0;
timevar_push (TV_ALIAS_STMT_WALK);
@@ -2112,17 +2121,25 @@ walk_non_aliased_vuses (ao_ref *ref, tree vuse,
gimple def_stmt;
/* ??? Do we want to account this to TV_ALIAS_STMT_WALK? */
- res = (*walker) (ref, vuse, data);
- if (res)
+ res = (*walker) (ref, vuse, cnt, data);
+ /* Abort walk. */
+ if (res == (void *)-1)
+ {
+ res = NULL;
+ break;
+ }
+ /* Lookup succeeded. */
+ else if (res != NULL)
break;
def_stmt = SSA_NAME_DEF_STMT (vuse);
if (gimple_nop_p (def_stmt))
break;
else if (gimple_code (def_stmt) == GIMPLE_PHI)
- vuse = get_continuation_for_phi (def_stmt, ref, &visited);
+ vuse = get_continuation_for_phi (def_stmt, ref, &cnt, &visited);
else
{
+ cnt++;
if (stmt_may_clobber_ref_p_1 (def_stmt, ref))
{
if (!translate)