tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Look for a POINTER_PLUS_EXPR in the defining statement.

2013-10-30  Marc Glisse  <marc.glisse@inria.fr>

gcc/
	* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Look for a
	POINTER_PLUS_EXPR in the defining statement.

gcc/testsuite/
	* gcc.dg/tree-ssa/alias-24.c: New file.

From-SVN: r204213
This commit is contained in:
Marc Glisse 2013-10-30 15:33:49 +01:00 committed by Marc Glisse
parent 3b6d16993b
commit 6ecb8b21c8
4 changed files with 44 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2013-10-30 Marc Glisse <marc.glisse@inria.fr>
* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Look for a
POINTER_PLUS_EXPR in the defining statement.
2013-10-30 Vladimir Makarov <vmakarov@redhat.com>
* regmove.c: Remove.

View File

@ -1,3 +1,7 @@
2013-10-30 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/alias-24.c: New file.
2013-10-30 Vladimir Makarov <vmakarov@redhat.com>
* gcc.target/i386/fma_double_3.c: Use pattern for

View File

@ -0,0 +1,22 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
void f (const char *c, int *i)
{
*i = 42;
__builtin_memcpy (i + 1, c, sizeof (int));
if (*i != 42) __builtin_abort();
}
extern void keepit ();
void g (const char *c, int *i)
{
*i = 33;
__builtin_memcpy (i - 1, c, 3 * sizeof (int));
if (*i != 33) keepit();
}
/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */
/* { dg-final { scan-tree-dump "keepit" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View File

@ -566,7 +566,7 @@ ao_ref_alias_set (ao_ref *ref)
void
ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
{
HOST_WIDE_INT t1, t2;
HOST_WIDE_INT t1, t2, extra_offset = 0;
ref->ref = NULL_TREE;
if (TREE_CODE (ptr) == SSA_NAME)
{
@ -574,6 +574,14 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
if (gimple_assign_single_p (stmt)
&& gimple_assign_rhs_code (stmt) == ADDR_EXPR)
ptr = gimple_assign_rhs1 (stmt);
else if (is_gimple_assign (stmt)
&& gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR
&& host_integerp (gimple_assign_rhs2 (stmt), 0)
&& (t1 = int_cst_value (gimple_assign_rhs2 (stmt))) >= 0)
{
ptr = gimple_assign_rhs1 (stmt);
extra_offset = BITS_PER_UNIT * t1;
}
}
if (TREE_CODE (ptr) == ADDR_EXPR)
@ -585,10 +593,12 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
ptr, null_pointer_node);
ref->offset = 0;
}
ref->offset += extra_offset;
if (size
&& host_integerp (size, 0)
&& TREE_INT_CST_LOW (size) * 8 / 8 == TREE_INT_CST_LOW (size))
ref->max_size = ref->size = TREE_INT_CST_LOW (size) * 8;
&& TREE_INT_CST_LOW (size) * BITS_PER_UNIT / BITS_PER_UNIT
== TREE_INT_CST_LOW (size))
ref->max_size = ref->size = TREE_INT_CST_LOW (size) * BITS_PER_UNIT;
else
ref->max_size = ref->size = -1;
ref->ref_alias_set = 0;