aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-alias.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-04-14 13:38:33 +0000
committerRichard Guenther <rguenther@suse.de>2011-04-14 13:38:33 +0000
commit400b0960294d8f94b3850bd6f33880d233ca1bd3 (patch)
tree63beaf8039be953cc4acc9dc13786c2c6a7879d4 /gcc/tree-ssa-alias.c
parent329a666991d786385e50e003b854ef20e729dd51 (diff)
2011-04-14 Richard Guenther <rguenther@suse.de>
* tree-ssa-dse.c (struct dse_global_data, struct dse_block_local_data): Remove. (dse_initialize_block_local_data, dse_leave_block, record_voperand_set, get_stmt_uid): Likewise. (dse_possible_dead_store_p): Allow any kind of killing stmt. (dse_optimize_stmt): Remove voperand set handling code. Simplify and improve to handle any kind of killing stmt. (dse_record_phi): Remove. (dse_enter_block): Simplify. (tree_ssa_dse): Likewise. * tree-ssa-alias.c (stmt_kills_ref_p_1): Handle some builtins. * gcc.dg/tree-ssa/ssa-dse-14.c: New testcase. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@172431 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r--gcc/tree-ssa-alias.c51
1 files changed, 47 insertions, 4 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c
index 1e80f49c5a0..67ba8f1323c 100644
--- a/gcc/tree-ssa-alias.c
+++ b/gcc/tree-ssa-alias.c
@@ -1616,21 +1616,25 @@ stmt_may_clobber_ref_p (gimple stmt, tree ref)
static bool
stmt_kills_ref_p_1 (gimple stmt, ao_ref *ref)
{
+ /* For a must-alias check we need to be able to constrain
+ the access properly. */
+ ao_ref_base (ref);
+ if (ref->max_size == -1)
+ return false;
+
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)
+ the access properly. */
+ if (size != -1 && size == max_size)
{
if (offset <= ref->offset
&& offset + size >= ref->offset + ref->max_size)
@@ -1638,6 +1642,45 @@ stmt_kills_ref_p_1 (gimple stmt, ao_ref *ref)
}
}
}
+
+ if (is_gimple_call (stmt))
+ {
+ tree callee = gimple_call_fndecl (stmt);
+ if (callee != NULL_TREE
+ && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
+ switch (DECL_FUNCTION_CODE (callee))
+ {
+ case BUILT_IN_MEMCPY:
+ case BUILT_IN_MEMPCPY:
+ case BUILT_IN_MEMMOVE:
+ case BUILT_IN_MEMSET:
+ {
+ tree dest = gimple_call_arg (stmt, 0);
+ tree len = gimple_call_arg (stmt, 2);
+ tree base = NULL_TREE;
+ HOST_WIDE_INT offset = 0;
+ if (!host_integerp (len, 0))
+ return false;
+ if (TREE_CODE (dest) == ADDR_EXPR)
+ base = get_addr_base_and_unit_offset (TREE_OPERAND (dest, 0),
+ &offset);
+ else if (TREE_CODE (dest) == SSA_NAME)
+ base = dest;
+ if (base
+ && base == ao_ref_base (ref))
+ {
+ HOST_WIDE_INT size = TREE_INT_CST_LOW (len);
+ if (offset <= ref->offset / BITS_PER_UNIT
+ && (offset + size
+ >= ((ref->offset + ref->max_size + BITS_PER_UNIT - 1)
+ / BITS_PER_UNIT)))
+ return true;
+ }
+ }
+ default:;
+ }
+
+ }
return false;
}