This patch makes tree-ssa-alias.c:same_addr_size_stores_p handle poly_int sizes and offsets.
2017-10-23 Richard Sandiford <richard.sandif...@linaro.org> Alan Hayward <alan.hayw...@arm.com> David Sherwood <david.sherw...@arm.com> gcc/ * tree-ssa-alias.c (same_addr_size_stores_p): Take the offsets and sizes as poly_int64s rather than HOST_WIDE_INTs. Index: gcc/tree-ssa-alias.c =================================================================== --- gcc/tree-ssa-alias.c 2017-10-23 16:52:20.150440950 +0100 +++ gcc/tree-ssa-alias.c 2017-10-23 17:01:49.579064221 +0100 @@ -2322,14 +2322,14 @@ stmt_may_clobber_ref_p (gimple *stmt, tr address. */ static bool -same_addr_size_stores_p (tree base1, HOST_WIDE_INT offset1, HOST_WIDE_INT size1, - HOST_WIDE_INT max_size1, - tree base2, HOST_WIDE_INT offset2, HOST_WIDE_INT size2, - HOST_WIDE_INT max_size2) +same_addr_size_stores_p (tree base1, poly_int64 offset1, poly_int64 size1, + poly_int64 max_size1, + tree base2, poly_int64 offset2, poly_int64 size2, + poly_int64 max_size2) { /* Offsets need to be 0. */ - if (offset1 != 0 - || offset2 != 0) + if (maybe_nonzero (offset1) + || maybe_nonzero (offset2)) return false; bool base1_obj_p = SSA_VAR_P (base1); @@ -2348,17 +2348,19 @@ same_addr_size_stores_p (tree base1, HOS tree memref = base1_memref_p ? base1 : base2; /* Sizes need to be valid. */ - if (max_size1 == -1 || max_size2 == -1 - || size1 == -1 || size2 == -1) + if (!known_size_p (max_size1) + || !known_size_p (max_size2) + || !known_size_p (size1) + || !known_size_p (size2)) return false; /* Max_size needs to match size. */ - if (max_size1 != size1 - || max_size2 != size2) + if (may_ne (max_size1, size1) + || may_ne (max_size2, size2)) return false; /* Sizes need to match. */ - if (size1 != size2) + if (may_ne (size1, size2)) return false; @@ -2386,10 +2388,9 @@ same_addr_size_stores_p (tree base1, HOS /* Check that the object size is the same as the store size. That ensures us that ptr points to the start of obj. */ - if (!tree_fits_shwi_p (DECL_SIZE (obj))) - return false; - HOST_WIDE_INT obj_size = tree_to_shwi (DECL_SIZE (obj)); - return obj_size == size1; + return (DECL_SIZE (obj) + && poly_int_tree_p (DECL_SIZE (obj)) + && must_eq (wi::to_poly_offset (DECL_SIZE (obj)), size1)); } /* If STMT kills the memory reference REF return true, otherwise