Commit bb362135 by Marc Glisse Committed by Marc Glisse

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
parent 447f3223
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
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
......
/* { 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" } } */
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment