summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dse.c
diff options
context:
space:
mode:
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-09 20:05:08 +0000
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2007-03-09 20:05:08 +0000
commit161fe168cd083534da50aa1d414d24794a5d8164 (patch)
treec9430a0a92da8d81b5ec3f994b8012825972f9ba /gcc/tree-ssa-dse.c
parentef005ed0ac0f0d8429d6aaa8768bf726369be3ab (diff)
downloadgcc-161fe168cd083534da50aa1d414d24794a5d8164.tar.gz
PR tree-optimization/30375
* tree-ssa-dse.c (dse_possible_dead_store_p): Do not eliminate if LHS of statements is not the same. * testsuite/gcc.dg/tree-ssa/ssa-dse-10.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122758 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-dse.c')
-rw-r--r--gcc/tree-ssa-dse.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index ed1a5b2a381..bb5d14d78f9 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -283,6 +283,32 @@ dse_possible_dead_store_p (tree stmt,
gcc_assert (*use_p != NULL_USE_OPERAND_P);
*first_use_p = *use_p;
+ /* In the case of memory partitions, we may get:
+
+ # MPT.764_162 = VDEF <MPT.764_161(D)>
+ x = {};
+ # MPT.764_167 = VDEF <MPT.764_162>
+ y = {};
+
+ So we must make sure we're talking about the same LHS.
+ */
+ if (TREE_CODE (temp) == GIMPLE_MODIFY_STMT)
+ {
+ tree base1 = get_base_address (GIMPLE_STMT_OPERAND (stmt, 0));
+ tree base2 = get_base_address (GIMPLE_STMT_OPERAND (temp, 0));
+
+ while (base1 && INDIRECT_REF_P (base1))
+ base1 = TREE_OPERAND (base1, 0);
+ while (base2 && INDIRECT_REF_P (base2))
+ base2 = TREE_OPERAND (base2, 0);
+
+ if (base1 != base2)
+ {
+ fail = true;
+ break;
+ }
+ }
+
/* If the immediate use of DEF_VAR is not the same as the
previously find immediate uses, then we will not be able
to eliminate STMT. */