aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dse.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-03-08 13:30:27 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-03-08 13:30:27 +0000
commitcc788fcc70a93b25b78cb72f31da3a2159930824 (patch)
tree745b8751179efb6d63f3bad5ec9494c67ab1997d /gcc/tree-ssa-dse.c
parent69c103c7139e87cc2e7a2ff7ab1ce3c4faa227bc (diff)
downloadgcc-cc788fcc70a93b25b78cb72f31da3a2159930824.zip
gcc-cc788fcc70a93b25b78cb72f31da3a2159930824.tar.gz
gcc-cc788fcc70a93b25b78cb72f31da3a2159930824.tar.bz2
re PR tree-optimization/43269 (removing non dead store)
2010-03-08 Richard Guenther <rguenther@suse.de> PR tree-optimization/43269 * tree-ssa-dse.c (dse_possible_dead_store_p): Fix post-dom region detection. * gcc.c-torture/execute/pr43269.c: New testcase. From-SVN: r157276
Diffstat (limited to 'gcc/tree-ssa-dse.c')
-rw-r--r--gcc/tree-ssa-dse.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 37a5481..b678a8f 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -161,7 +161,7 @@ dse_possible_dead_store_p (gimple stmt, gimple *use_stmt)
temp = stmt;
do
{
- gimple prev, use_stmt;
+ gimple use_stmt;
imm_use_iterator ui;
bool fail = false;
tree defvar;
@@ -175,28 +175,33 @@ dse_possible_dead_store_p (gimple stmt, gimple *use_stmt)
defvar = PHI_RESULT (temp);
else
defvar = gimple_vdef (temp);
- prev = temp;
temp = NULL;
FOR_EACH_IMM_USE_STMT (use_stmt, ui, defvar)
{
cnt++;
+ /* If we ever reach our DSE candidate stmt again fail. We
+ cannot handle dead stores in loops. */
+ if (use_stmt == stmt)
+ {
+ fail = true;
+ BREAK_FROM_IMM_USE_STMT (ui);
+ }
/* In simple cases we can look through PHI nodes, but we
have to be careful with loops and with memory references
containing operands that are also operands of PHI nodes.
See gcc.c-torture/execute/20051110-*.c. */
- if (gimple_code (use_stmt) == GIMPLE_PHI)
+ else if (gimple_code (use_stmt) == GIMPLE_PHI)
{
if (temp
- /* We can look through PHIs to post-dominated regions
- without worrying if the use not also dominates prev
- (in which case it would be a loop PHI with the use
- in a latch block). */
- || gimple_bb (prev) == gimple_bb (use_stmt)
- || !dominated_by_p (CDI_POST_DOMINATORS,
- gimple_bb (prev), gimple_bb (use_stmt))
+ /* Make sure we are not in a loop latch block. */
+ || gimple_bb (stmt) == gimple_bb (use_stmt)
|| dominated_by_p (CDI_DOMINATORS,
- gimple_bb (prev), gimple_bb (use_stmt)))
+ gimple_bb (stmt), gimple_bb (use_stmt))
+ /* We can look through PHIs to regions post-dominating
+ the DSE candidate stmt. */
+ || !dominated_by_p (CDI_POST_DOMINATORS,
+ gimple_bb (stmt), gimple_bb (use_stmt)))
{
fail = true;
BREAK_FROM_IMM_USE_STMT (ui);