Commit 1415abc0 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/42142 (DCE miscompiles a certain quicksort…

re PR tree-optimization/42142 (DCE miscompiles a certain quicksort implementation when optimizing with -O1 or higher)

2009-11-24  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42142
	* tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1):
	Handle iv-dependent (non-)kills properly.
	(mark_aliased_reaching_defs_necessary): Pass the basic-block
	of the reference statement to mark_aliased_reaching_defs_necessary_1.

	* gcc.c-torture/execute/pr42142.c: New testcase.

From-SVN: r154494
parent 09f0dc45
2009-11-24 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42142
* tree-ssa-dce.c (mark_aliased_reaching_defs_necessary_1):
Handle iv-dependent (non-)kills properly.
(mark_aliased_reaching_defs_necessary): Pass the basic-block
of the reference statement to mark_aliased_reaching_defs_necessary_1.
2009-11-24 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/42154
2009-11-24 Richard Guenther <rguenther@suse.de>
PR tree-optimization/42142
* gcc.c-torture/execute/pr42142.c: New testcase.
2009-11-24 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/42154
......
int __attribute__((noinline,noclone))
sort(int L)
{
int end[2] = { 10, 10, }, i=0, R;
while (i<2)
{
R = end[i];
if (L<R)
{
end[i+1] = 1;
end[i] = 10;
++i;
}
else
break;
}
return i;
}
extern void abort (void);
int main()
{
if (sort (5) != 1)
abort ();
return 0;
}
......@@ -495,11 +495,11 @@ static bool chain_ovfl = false;
which is based on a non-aliased decl, necessary. It returns
true whenever the defining statement of the current VDEF is
a kill for REF, as no dominating may-defs are necessary for REF
anymore. DATA points to cached get_ref_base_and_extent data for REF. */
anymore. DATA points to the basic-block that contains the
stmt that refers to REF. */
static bool
mark_aliased_reaching_defs_necessary_1 (ao_ref *ref, tree vdef,
void *data ATTRIBUTE_UNUSED)
mark_aliased_reaching_defs_necessary_1 (ao_ref *ref, tree vdef, void *data)
{
gimple def_stmt = SSA_NAME_DEF_STMT (vdef);
......@@ -529,6 +529,12 @@ mark_aliased_reaching_defs_necessary_1 (ao_ref *ref, tree vdef,
}
/* Or they need to be exactly the same. */
else if (ref->ref
/* Make sure there is no induction variable involved
in the references (gcc.c-torture/execute/pr42142.c).
The simplest way is to check if the kill dominates
the use. */
&& dominated_by_p (CDI_DOMINATORS, (basic_block) data,
gimple_bb (def_stmt))
&& operand_equal_p (ref->ref, lhs, 0))
return true;
}
......@@ -547,7 +553,7 @@ mark_aliased_reaching_defs_necessary (gimple stmt, tree ref)
ao_ref_init (&refd, ref);
chain = walk_aliased_vdefs (&refd, gimple_vuse (stmt),
mark_aliased_reaching_defs_necessary_1,
NULL, NULL);
gimple_bb (stmt), NULL);
if (chain > longest_chain)
longest_chain = chain;
total_chain += chain;
......
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