diff options
author | Jakub Jelinek <jakub@redhat.com> | 2007-12-20 15:40:33 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2007-12-20 15:40:33 +0100 |
commit | 3ec1a7379f92411a4a311aaa347dfb14d2e23815 (patch) | |
tree | 5990689e70d0a0e74d6934d8c11527dd589c94c9 /gcc/tree-ssa-dse.c | |
parent | 667e20459d82a01e61fc590781c53fd2c136ef96 (diff) | |
download | gcc-3ec1a7379f92411a4a311aaa347dfb14d2e23815.zip gcc-3ec1a7379f92411a4a311aaa347dfb14d2e23815.tar.gz gcc-3ec1a7379f92411a4a311aaa347dfb14d2e23815.tar.bz2 |
re PR c++/34459 (incorrect code when compiled with optimization (-O1))
PR c++/34459
* tree-ssa-dse.c (dse_optimize_stmt): Don't eliminate store if
USE_STMT not only stores into the same object as STMT, but might
read it too.
* gcc.c-torture/execute/20071219-1.c: New test.
From-SVN: r131101
Diffstat (limited to 'gcc/tree-ssa-dse.c')
-rw-r--r-- | gcc/tree-ssa-dse.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c index 3435fa3..3e0f04b 100644 --- a/gcc/tree-ssa-dse.c +++ b/gcc/tree-ssa-dse.c @@ -470,6 +470,26 @@ dse_optimize_stmt (struct dom_walk_data *walk_data, vuse_vec_p vv; tree stmt_lhs; + if (LOADED_SYMS (use_stmt)) + { + tree use_base + = get_base_address (GIMPLE_STMT_OPERAND (use_stmt, 0)); + /* If use_stmt is or might be a nop assignment, e.g. for + struct { ... } S a, b, *p; ... + b = a; b = b; + or + b = a; b = *p; where p might be &b, then USE_STMT + acts as a use as well as definition, so store in STMT + is not dead. */ + if (TREE_CODE (use_base) == VAR_DECL + && bitmap_bit_p (LOADED_SYMS (use_stmt), + DECL_UID (use_base))) + { + record_voperand_set (dse_gd->stores, &bd->stores, ann->uid); + return; + } + } + if (dump_file && (dump_flags & TDF_DETAILS)) { fprintf (dump_file, " Deleted dead store '"); |