diff options
author | Aldy Hernandez <aldyh@redhat.com> | 2007-03-09 20:05:08 +0000 |
---|---|---|
committer | Aldy Hernandez <aldyh@gcc.gnu.org> | 2007-03-09 20:05:08 +0000 |
commit | 0f84b066791763e603fa12330f381bef3353d4e8 (patch) | |
tree | c9430a0a92da8d81b5ec3f994b8012825972f9ba /gcc/tree-ssa-dse.c | |
parent | 3f868e1cefd522190eeac6c6ad662bfd3a277d21 (diff) | |
download | gcc-0f84b066791763e603fa12330f381bef3353d4e8.zip gcc-0f84b066791763e603fa12330f381bef3353d4e8.tar.gz gcc-0f84b066791763e603fa12330f381bef3353d4e8.tar.bz2 |
re PR tree-optimization/30375 (tree-ssa-dse incorrectly removes struct initialization)
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.
From-SVN: r122758
Diffstat (limited to 'gcc/tree-ssa-dse.c')
-rw-r--r-- | gcc/tree-ssa-dse.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index ed1a5b2..bb5d14d 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. */ |