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

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

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

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

From-SVN: r204065
This commit is contained in:
Marc Glisse 2013-10-25 14:35:51 +02:00 committed by Marc Glisse
parent 447f322380
commit bb362135e2
4 changed files with 35 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2013-10-25 Marc Glisse <marc.glisse@inria.fr>
* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Look for an
ADDR_EXPR in the defining statement.
2013-10-25 Richard Biener <rguenther@suse.de>
PR tree-optimization/58626

View File

@ -1,3 +1,7 @@
2013-10-25 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/alias-23.c: New file.
2013-10-25 Richard Biener <rguenther@suse.de>
PR tree-optimization/58626

View File

@ -0,0 +1,18 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
typedef struct A { int i; double d; } A;
void f1 (const char *c)
{
A *s = (A*) __builtin_malloc (sizeof (A));
double *p = &s->d;
s->i = 42;
__builtin_memcpy (p, c, sizeof (double));
int j = s->i;
if (j != 42) __builtin_abort();
}
/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */

View File

@ -568,6 +568,14 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
{
HOST_WIDE_INT t1, t2;
ref->ref = NULL_TREE;
if (TREE_CODE (ptr) == SSA_NAME)
{
gimple stmt = SSA_NAME_DEF_STMT (ptr);
if (gimple_assign_single_p (stmt)
&& gimple_assign_rhs_code (stmt) == ADDR_EXPR)
ptr = gimple_assign_rhs1 (stmt);
}
if (TREE_CODE (ptr) == ADDR_EXPR)
ref->base = get_ref_base_and_extent (TREE_OPERAND (ptr, 0),
&ref->offset, &t1, &t2);