Commit 0ea48022 by Richard Biener Committed by Richard Biener

re PR tree-optimization/60098 (DSE fails to DSE errno settings)

2014-06-04  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/60098
	* tree-ssa-dse.c (dse_possible_dead_store_p): Walk until
	we hit a kill.
	(dse_optimize_stmt): Simplify, now that we found a kill
	earlier.

	* gcc.dg/tree-ssa/ssa-dse-15.c: New testcase.

From-SVN: r211224
parent b1259d34
2014-06-04 Richard Biener <rguenther@suse.de> 2014-06-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/60098
* tree-ssa-dse.c (dse_possible_dead_store_p): Walk until
we hit a kill.
(dse_optimize_stmt): Simplify, now that we found a kill
earlier.
2014-06-04 Richard Biener <rguenther@suse.de>
* tree-ssa-alias.c (stmt_may_clobber_ref_p): Improve handling * tree-ssa-alias.c (stmt_may_clobber_ref_p): Improve handling
of accesses with non-invariant address. of accesses with non-invariant address.
......
2014-06-04 Richard Biener <rguenther@suse.de> 2014-06-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/60098
* gcc.dg/tree-ssa/ssa-dse-15.c: New testcase.
2014-06-04 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/ssa-dse-16.c: New testcase. * gcc.dg/tree-ssa/ssa-dse-16.c: New testcase.
2014-06-04 Igor Zamyatin <igor.zamyatin@intel.com> 2014-06-04 Igor Zamyatin <igor.zamyatin@intel.com>
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dse1-details" } */
void *foo (int *p)
{
void *q;
/* We should be able to DSE this store (p may point to errno). */
*p = 0;
q = __builtin_malloc (4);
*p = 0;
return q;
}
int j;
void bar (int *i)
{
/* This store is dead as well. */
j = 1;
*i = 0;
j = 2;
}
/* { dg-final { scan-tree-dump-times "Deleted dead store" 2 "dse1" } } */
/* { dg-final { cleanup-tree-dump "dse1" } } */
...@@ -198,10 +198,8 @@ dse_possible_dead_store_p (gimple stmt, gimple *use_stmt) ...@@ -198,10 +198,8 @@ dse_possible_dead_store_p (gimple stmt, gimple *use_stmt)
break; break;
} }
} }
/* We deliberately stop on clobbering statements and not only on /* Continue walking until we reach a kill. */
killing ones to make walking cheaper. Otherwise we can just while (!stmt_kills_ref_p (temp, gimple_assign_lhs (stmt)));
continue walking until both stores have equal reference trees. */
while (!stmt_may_clobber_ref_p (temp, gimple_assign_lhs (stmt)));
*use_stmt = temp; *use_stmt = temp;
...@@ -248,21 +246,14 @@ dse_optimize_stmt (gimple_stmt_iterator *gsi) ...@@ -248,21 +246,14 @@ dse_optimize_stmt (gimple_stmt_iterator *gsi)
if (!dse_possible_dead_store_p (stmt, &use_stmt)) if (!dse_possible_dead_store_p (stmt, &use_stmt))
return; return;
/* Now we know that use_stmt kills the LHS of stmt. */
/* But only remove *this_2(D) ={v} {CLOBBER} if killed by /* But only remove *this_2(D) ={v} {CLOBBER} if killed by
another clobber stmt. */ another clobber stmt. */
if (gimple_clobber_p (stmt) if (gimple_clobber_p (stmt)
&& !gimple_clobber_p (use_stmt)) && !gimple_clobber_p (use_stmt))
return; return;
/* If we have precisely one immediate use at this point and the
stores are to the same memory location or there is a chain of
virtual uses from stmt and the stmt which stores to that same
memory location, then we may have found redundant store. */
if ((gimple_has_lhs (use_stmt)
&& (operand_equal_p (gimple_assign_lhs (stmt),
gimple_get_lhs (use_stmt), 0)))
|| stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt)))
{
basic_block bb; basic_block bb;
/* If use_stmt is or might be a nop assignment, e.g. for /* If use_stmt is or might be a nop assignment, e.g. for
...@@ -299,7 +290,6 @@ dse_optimize_stmt (gimple_stmt_iterator *gsi) ...@@ -299,7 +290,6 @@ dse_optimize_stmt (gimple_stmt_iterator *gsi)
SSA_NAME manager. */ SSA_NAME manager. */
release_defs (stmt); release_defs (stmt);
} }
}
} }
class dse_dom_walker : public dom_walker class dse_dom_walker : public dom_walker
......
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