diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 06515889f6a..9044a6c9058 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2013-11-05 Marc Glisse + + * 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 PR tree-optimization/58984 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d95fc2c64de..9235430b8e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-11-05 Marc Glisse + + * gcc.dg/tree-ssa/alias-26.c: New file. + 2013-11-05 Jakub Jelinek PR tree-optimization/58984 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-26.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-26.c new file mode 100644 index 00000000000..a1eb8f7d0a8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-26.c @@ -0,0 +1,13 @@ +/* { 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" } } */ + diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index efc08c20991..6f7e8534803 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -559,7 +559,7 @@ ao_ref_alias_set (ao_ref *ref) } /* 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 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) 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) + && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST) { ptr = gimple_assign_rhs1 (stmt); - extra_offset = BITS_PER_UNIT * t1; + extra_offset = BITS_PER_UNIT + * int_cst_value (gimple_assign_rhs2 (stmt)); } } diff --git a/gcc/tree-ssa-alias.h b/gcc/tree-ssa-alias.h index 831cffebecb..581cd82a5f3 100644 --- a/gcc/tree-ssa-alias.h +++ b/gcc/tree-ssa-alias.h @@ -146,18 +146,18 @@ extern GTY(()) struct pt_solution ipa_escaped_pt; range is open-ended. Otherwise return false. */ 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 pos2, + HOST_WIDE_INT pos2, unsigned HOST_WIDE_INT size2) { if (pos1 >= pos2 && (size2 == (unsigned HOST_WIDE_INT)-1 - || pos1 < (pos2 + size2))) + || pos1 < (pos2 + (HOST_WIDE_INT) size2))) return true; if (pos2 >= pos1 && (size1 == (unsigned HOST_WIDE_INT)-1 - || pos2 < (pos1 + size1))) + || pos2 < (pos1 + (HOST_WIDE_INT) size1))) return true; return false;