Commit 45ce6084 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/50204 (Missed fully redundant load found in crafty (SPEC 2k))

2011-10-11  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/50204
	* tree-ssa-alias.c (get_continuation_for_phi_1): Split out
	two argument handling from ...
	(get_continuation_for_phi): ... here.  Handle arbitrary number
	of PHI args.

	* gcc.dg/tree-ssa/ssa-fre-36.c: New testcase.

From-SVN: r179799
parent 12d31b36
2011-10-11 Richard Guenther <rguenther@suse.de>
PR tree-optimization/50204
* tree-ssa-alias.c (get_continuation_for_phi_1): Split out
two argument handling from ...
(get_continuation_for_phi): ... here. Handle arbitrary number
of PHI args.
2011-10-11 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/33067
2011-10-11 Richard Guenther <rguenther@suse.de>
PR tree-optimization/50204
* gcc.dg/tree-ssa/ssa-fre-36.c: New testcase.
2011-10-11 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* gcc.target/s390/20090223-1.c: Add -Wno-attributes.
......
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-fre1-details" } */
extern int opening;
extern int middle_game;
int s;
extern int d[1];
void PreEvaluate(int wtm)
{
int i, j;
if (opening) {
d[0]=1;
}
else if (middle_game) {
d[0]=-1;
}
if (4 != opening) {
return;
}
s = 1;
}
/* We should be able to CSE the second load of opening. */
/* { dg-final { scan-tree-dump "Replaced opening" "fre1" } } */
/* { dg-final { cleanup-tree-dump "fre1" } } */
......@@ -1875,27 +1875,14 @@ maybe_skip_until (gimple phi, tree target, ao_ref *ref,
return true;
}
/* 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. */
/* For two PHI arguments ARG0 and ARG1 try to skip non-aliasing code
until we hit the phi argument definition that dominates the other one.
Return that, or NULL_TREE if there is no such definition. */
tree
get_continuation_for_phi (gimple phi, ao_ref *ref, bitmap *visited)
static tree
get_continuation_for_phi_1 (gimple phi, tree arg0, tree arg1,
ao_ref *ref, bitmap *visited)
{
unsigned nargs = gimple_phi_num_args (phi);
/* Through a single-argument PHI we can simply look through. */
if (nargs == 1)
return PHI_ARG_DEF (phi, 0);
/* For two arguments try to skip non-aliasing code until we hit
the phi argument definition that dominates the other one. */
if (nargs == 2)
{
tree arg0 = PHI_ARG_DEF (phi, 0);
tree arg1 = PHI_ARG_DEF (phi, 1);
gimple def0 = SSA_NAME_DEF_STMT (arg0);
gimple def1 = SSA_NAME_DEF_STMT (arg1);
tree common_vuse;
......@@ -1937,6 +1924,44 @@ get_continuation_for_phi (gimple phi, ao_ref *ref, bitmap *visited)
&& !stmt_may_clobber_ref_p_1 (def1, ref))
return common_vuse;
}
return NULL_TREE;
}
/* 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. */
tree
get_continuation_for_phi (gimple phi, ao_ref *ref, bitmap *visited)
{
unsigned nargs = gimple_phi_num_args (phi);
/* Through a single-argument PHI we can simply look through. */
if (nargs == 1)
return PHI_ARG_DEF (phi, 0);
/* For two or more arguments try to pairwise skip non-aliasing code
until we hit the phi argument definition that dominates the other one. */
else if (nargs >= 2)
{
tree arg0 = PHI_ARG_DEF (phi, 0);
tree arg1;
unsigned i = 1;
do
{
arg1 = PHI_ARG_DEF (phi, i);
arg0 = get_continuation_for_phi_1 (phi, arg0, arg1, ref, visited);
if (!arg0)
return NULL_TREE;
}
while (++i < nargs);
return arg0;
}
return NULL_TREE;
......
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