diff options
author | Richard Guenther <rguenther@suse.de> | 2010-10-13 13:03:31 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-10-13 13:03:31 +0000 |
commit | 71d61348020eedc3d89e4c877ad714cbb2954792 (patch) | |
tree | 1fbb62b9afc53835c17dfb33351b1fa61122bfce /gcc/tree-ssa-alias.c | |
parent | 9827eb57a33462935e8d55d7e49f5ab4b16b887c (diff) | |
download | gcc-71d61348020eedc3d89e4c877ad714cbb2954792.zip gcc-71d61348020eedc3d89e4c877ad714cbb2954792.tar.gz gcc-71d61348020eedc3d89e4c877ad714cbb2954792.tar.bz2 |
re PR tree-optimization/45970 (tree DSE misses many obvious dead stores)
2010-10-13 Richard Guenther <rguenther@suse.de>
PR tree-optimization/45970
* tree-ssa-alias.h (stmt_kills_ref_p): Declare.
* tree-ssa-alias.c (stmt_kills_ref_p_1): New function.
(stmt_kills_ref_p): Likewise.
* tree-ssa-dse.c (dse_optimize_stmt): Use it.
* gcc.dg/tree-ssa/ssa-dse-13.c: New testcase.
From-SVN: r165422
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r-- | gcc/tree-ssa-alias.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index e00c50a..afd5e08 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -1522,6 +1522,45 @@ stmt_may_clobber_ref_p (gimple stmt, tree ref) return stmt_may_clobber_ref_p_1 (stmt, &r); } +/* If STMT kills the memory reference REF return true, otherwise + return false. */ + +static bool +stmt_kills_ref_p_1 (gimple stmt, ao_ref *ref) +{ + if (gimple_has_lhs (stmt) + && TREE_CODE (gimple_get_lhs (stmt)) != SSA_NAME) + { + tree base, lhs = gimple_get_lhs (stmt); + HOST_WIDE_INT size, offset, max_size; + ao_ref_base (ref); + base = get_ref_base_and_extent (lhs, &offset, &size, &max_size); + /* We can get MEM[symbol: sZ, index: D.8862_1] here, + so base == ref->base does not always hold. */ + if (base == ref->base) + { + /* For a must-alias check we need to be able to constrain + the accesses properly. */ + if (size != -1 && size == max_size + && ref->max_size != -1) + { + if (offset <= ref->offset + && offset + size >= ref->offset + ref->max_size) + return true; + } + } + } + return false; +} + +bool +stmt_kills_ref_p (gimple stmt, tree ref) +{ + ao_ref r; + ao_ref_init (&r, ref); + return stmt_kills_ref_p_1 (stmt, &r); +} + /* Walk the virtual use-def chain of VUSE until hitting the virtual operand TARGET or a statement clobbering the memory reference REF in which |