Commit 75081240 by Marc Glisse Committed by Marc Glisse

tree-ssa-alias.h (ranges_overlap_p): Handle negative offsets.

2013-11-05  Marc Glisse  <marc.glisse@inria.fr>

gcc/
	* tree-ssa-alias.h (ranges_overlap_p): Handle negative offsets.
	* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Likewise.

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

From-SVN: r204388
parent 3ff2ca23
2013-11-05 Marc Glisse <marc.glisse@inria.fr>
* tree-ssa-alias.h (ranges_overlap_p): Handle negative offsets.
* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Likewise.
2013-11-05 Jakub Jelinek <jakub@redhat.com> 2013-11-05 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/58984 PR tree-optimization/58984
2013-11-05 Marc Glisse <marc.glisse@inria.fr>
* gcc.dg/tree-ssa/alias-26.c: New file.
2013-11-05 Jakub Jelinek <jakub@redhat.com> 2013-11-05 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/58984 PR tree-optimization/58984
......
/* { 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();
}
/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
...@@ -559,7 +559,7 @@ ao_ref_alias_set (ao_ref *ref) ...@@ -559,7 +559,7 @@ ao_ref_alias_set (ao_ref *ref)
} }
/* Init an alias-oracle reference representation from a gimple pointer /* Init an alias-oracle reference representation from a gimple pointer
PTR and a gimple size SIZE in bytes. If SIZE is NULL_TREE the the PTR and a gimple size SIZE in bytes. If SIZE is NULL_TREE then the
size is assumed to be unknown. The access is assumed to be only size is assumed to be unknown. The access is assumed to be only
to or after of the pointer target, not before it. */ to or after of the pointer target, not before it. */
...@@ -576,11 +576,11 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) ...@@ -576,11 +576,11 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size)
ptr = gimple_assign_rhs1 (stmt); ptr = gimple_assign_rhs1 (stmt);
else if (is_gimple_assign (stmt) else if (is_gimple_assign (stmt)
&& gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR && gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR
&& host_integerp (gimple_assign_rhs2 (stmt), 0) && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST)
&& (t1 = int_cst_value (gimple_assign_rhs2 (stmt))) >= 0)
{ {
ptr = gimple_assign_rhs1 (stmt); ptr = gimple_assign_rhs1 (stmt);
extra_offset = BITS_PER_UNIT * t1; extra_offset = BITS_PER_UNIT
* int_cst_value (gimple_assign_rhs2 (stmt));
} }
} }
......
...@@ -146,18 +146,18 @@ extern GTY(()) struct pt_solution ipa_escaped_pt; ...@@ -146,18 +146,18 @@ extern GTY(()) struct pt_solution ipa_escaped_pt;
range is open-ended. Otherwise return false. */ range is open-ended. Otherwise return false. */
static inline bool static inline bool
ranges_overlap_p (unsigned HOST_WIDE_INT pos1, ranges_overlap_p (HOST_WIDE_INT pos1,
unsigned HOST_WIDE_INT size1, unsigned HOST_WIDE_INT size1,
unsigned HOST_WIDE_INT pos2, HOST_WIDE_INT pos2,
unsigned HOST_WIDE_INT size2) unsigned HOST_WIDE_INT size2)
{ {
if (pos1 >= pos2 if (pos1 >= pos2
&& (size2 == (unsigned HOST_WIDE_INT)-1 && (size2 == (unsigned HOST_WIDE_INT)-1
|| pos1 < (pos2 + size2))) || pos1 < (pos2 + (HOST_WIDE_INT) size2)))
return true; return true;
if (pos2 >= pos1 if (pos2 >= pos1
&& (size1 == (unsigned HOST_WIDE_INT)-1 && (size1 == (unsigned HOST_WIDE_INT)-1
|| pos2 < (pos1 + size1))) || pos2 < (pos1 + (HOST_WIDE_INT) size1)))
return true; return true;
return false; return false;
......
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