aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dse.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2012-07-04 12:10:40 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2012-07-04 12:10:40 +0000
commit6c9df5a0014040115ebe576c4c0b7914a0414422 (patch)
tree5351f6868c854e291586eee626ce32773354d355 /gcc/tree-ssa-dse.c
parente1b6bbea37bb9e0dfaba80f5d7483fcd7ac9baa6 (diff)
downloadgcc-6c9df5a0014040115ebe576c4c0b7914a0414422.zip
gcc-6c9df5a0014040115ebe576c4c0b7914a0414422.tar.gz
gcc-6c9df5a0014040115ebe576c4c0b7914a0414422.tar.bz2
re PR middle-end/53844 (GCC generates suboptimal code for unused members of classes in some cases on multiple targets.)
2012-07-04 Richard Guenther <rguenther@suse.de> PR tree-optimization/53844 * tree-ssa-dse.c (dse_possible_dead_store_p): Properly handle the loop virtual PHI. * g++.dg/tree-ssa/pr53844.C: New testcase. From-SVN: r189256
Diffstat (limited to 'gcc/tree-ssa-dse.c')
-rw-r--r--gcc/tree-ssa-dse.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 5fdba8c..04cc6ad 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -94,7 +94,7 @@ dse_possible_dead_store_p (gimple stmt, gimple *use_stmt)
temp = stmt;
do
{
- gimple use_stmt;
+ gimple use_stmt, defvar_def;
imm_use_iterator ui;
bool fail = false;
tree defvar;
@@ -108,6 +108,7 @@ dse_possible_dead_store_p (gimple stmt, gimple *use_stmt)
defvar = PHI_RESULT (temp);
else
defvar = gimple_vdef (temp);
+ defvar_def = temp;
temp = NULL;
FOR_EACH_IMM_USE_STMT (use_stmt, ui, defvar)
{
@@ -139,7 +140,14 @@ dse_possible_dead_store_p (gimple stmt, gimple *use_stmt)
fail = true;
BREAK_FROM_IMM_USE_STMT (ui);
}
- temp = use_stmt;
+ /* Do not consider the PHI as use if it dominates the
+ stmt defining the virtual operand we are processing,
+ we have processed it already in this case. */
+ if (gimple_bb (defvar_def) != gimple_bb (use_stmt)
+ && !dominated_by_p (CDI_DOMINATORS,
+ gimple_bb (defvar_def),
+ gimple_bb (use_stmt)))
+ temp = use_stmt;
}
/* If the statement is a use the store is not dead. */
else if (ref_maybe_used_by_stmt_p (use_stmt,