summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-dse.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-03-05 16:13:04 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2008-03-05 16:13:04 +0000
commit7cf3d2829371ab6a0a98f7c504942d290ab81c79 (patch)
treef34248a3bddd1b90c01b24609c94f0ff59cae43d /gcc/tree-ssa-dse.c
parent2349cd3e43379cd107ab0248ed10ff5c3352e0eb (diff)
downloadgcc-7cf3d2829371ab6a0a98f7c504942d290ab81c79.tar.gz
2008-03-05 Richard Guenther <rguenther@suse.de>
PR tree-optimization/35472 * tree-ssa-dse.c (dse_optimize_stmt): Do not delete a store whose single use_stmt has a overlapping set of loaded and stored symbols as that use_stmt might be a noop assignment then. * gcc.c-torture/execute/pr35472.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132899 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-dse.c')
-rw-r--r--gcc/tree-ssa-dse.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 3e0f04be124..f2ec9a505c7 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -470,24 +470,23 @@ dse_optimize_stmt (struct dom_walk_data *walk_data,
vuse_vec_p vv;
tree stmt_lhs;
- if (LOADED_SYMS (use_stmt))
+ /* 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,
+ or
+ *p = a; *p = b; where p might be &b,
+ or
+ *p = *u; *p = *v; where p might be v, then USE_STMT
+ acts as a use as well as definition, so store in STMT
+ is not dead. */
+ if (LOADED_SYMS (use_stmt)
+ && bitmap_intersect_p (LOADED_SYMS (use_stmt),
+ STORED_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;
- }
+ record_voperand_set (dse_gd->stores, &bd->stores, ann->uid);
+ return;
}
if (dump_file && (dump_flags & TDF_DETAILS))