Commit b506575f by Richard Sandiford Committed by Richard Sandiford

poly_int: same_addr_size_stores_p

This patch makes tree-ssa-alias.c:same_addr_size_stores_p handle
poly_int sizes and offsets.

2017-12-20  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@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.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>

From-SVN: r255870
parent 30acf282
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* tree-ssa-alias.c (same_addr_size_stores_p): Take the offsets and
sizes as poly_int64s rather than HOST_WIDE_INTs.
2017-12-20 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* gimple-fold.h (fold_ctor_reference): Take the offset and size * gimple-fold.h (fold_ctor_reference): Take the offset and size
as poly_uint64 rather than unsigned HOST_WIDE_INT. as poly_uint64 rather than unsigned HOST_WIDE_INT.
* gimple-fold.c (fold_ctor_reference): Likewise. * gimple-fold.c (fold_ctor_reference): Likewise.
...@@ -2320,14 +2320,14 @@ stmt_may_clobber_ref_p (gimple *stmt, tree ref) ...@@ -2320,14 +2320,14 @@ stmt_may_clobber_ref_p (gimple *stmt, tree ref)
address. */ address. */
static bool static bool
same_addr_size_stores_p (tree base1, HOST_WIDE_INT offset1, HOST_WIDE_INT size1, same_addr_size_stores_p (tree base1, poly_int64 offset1, poly_int64 size1,
HOST_WIDE_INT max_size1, poly_int64 max_size1,
tree base2, HOST_WIDE_INT offset2, HOST_WIDE_INT size2, tree base2, poly_int64 offset2, poly_int64 size2,
HOST_WIDE_INT max_size2) poly_int64 max_size2)
{ {
/* Offsets need to be 0. */ /* Offsets need to be 0. */
if (offset1 != 0 if (maybe_ne (offset1, 0)
|| offset2 != 0) || maybe_ne (offset2, 0))
return false; return false;
bool base1_obj_p = SSA_VAR_P (base1); bool base1_obj_p = SSA_VAR_P (base1);
...@@ -2346,17 +2346,19 @@ same_addr_size_stores_p (tree base1, HOST_WIDE_INT offset1, HOST_WIDE_INT size1, ...@@ -2346,17 +2346,19 @@ same_addr_size_stores_p (tree base1, HOST_WIDE_INT offset1, HOST_WIDE_INT size1,
tree memref = base1_memref_p ? base1 : base2; tree memref = base1_memref_p ? base1 : base2;
/* Sizes need to be valid. */ /* Sizes need to be valid. */
if (max_size1 == -1 || max_size2 == -1 if (!known_size_p (max_size1)
|| size1 == -1 || size2 == -1) || !known_size_p (max_size2)
|| !known_size_p (size1)
|| !known_size_p (size2))
return false; return false;
/* Max_size needs to match size. */ /* Max_size needs to match size. */
if (max_size1 != size1 if (maybe_ne (max_size1, size1)
|| max_size2 != size2) || maybe_ne (max_size2, size2))
return false; return false;
/* Sizes need to match. */ /* Sizes need to match. */
if (size1 != size2) if (maybe_ne (size1, size2))
return false; return false;
...@@ -2384,10 +2386,9 @@ same_addr_size_stores_p (tree base1, HOST_WIDE_INT offset1, HOST_WIDE_INT size1, ...@@ -2384,10 +2386,9 @@ same_addr_size_stores_p (tree base1, HOST_WIDE_INT offset1, HOST_WIDE_INT size1,
/* Check that the object size is the same as the store size. That ensures us /* Check that the object size is the same as the store size. That ensures us
that ptr points to the start of obj. */ that ptr points to the start of obj. */
if (!tree_fits_shwi_p (DECL_SIZE (obj))) return (DECL_SIZE (obj)
return false; && poly_int_tree_p (DECL_SIZE (obj))
HOST_WIDE_INT obj_size = tree_to_shwi (DECL_SIZE (obj)); && known_eq (wi::to_poly_offset (DECL_SIZE (obj)), size1));
return obj_size == size1;
} }
/* If STMT kills the memory reference REF return true, otherwise /* If STMT kills the memory reference REF return true, otherwise
......
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