Commit 30acf282 by Richard Sandiford Committed by Richard Sandiford

poly_int: fold_ctor_reference

This patch changes the offset and size arguments to
fold_ctor_reference from unsigned HOST_WIDE_INT to poly_uint64.

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

gcc/
	* gimple-fold.h (fold_ctor_reference): Take the offset and size
	as poly_uint64 rather than unsigned HOST_WIDE_INT.
	* gimple-fold.c (fold_ctor_reference): Likewise.

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

From-SVN: r255869
parent 74c74aa0
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
Alan Hayward <alan.hayward@arm.com> Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com> David Sherwood <david.sherwood@arm.com>
* gimple-fold.h (fold_ctor_reference): Take the offset and size
as poly_uint64 rather than unsigned HOST_WIDE_INT.
* gimple-fold.c (fold_ctor_reference): Likewise.
2017-12-20 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
* target.def (dwarf_poly_indeterminate_value): New hook. * target.def (dwarf_poly_indeterminate_value): New hook.
* targhooks.h (default_dwarf_poly_indeterminate_value): Declare. * targhooks.h (default_dwarf_poly_indeterminate_value): Declare.
* targhooks.c (default_dwarf_poly_indeterminate_value): New function. * targhooks.c (default_dwarf_poly_indeterminate_value): New function.
...@@ -6527,20 +6527,25 @@ fold_nonarray_ctor_reference (tree type, tree ctor, ...@@ -6527,20 +6527,25 @@ fold_nonarray_ctor_reference (tree type, tree ctor,
return build_zero_cst (type); return build_zero_cst (type);
} }
/* CTOR is value initializing memory, fold reference of type TYPE and size SIZE /* CTOR is value initializing memory, fold reference of type TYPE and
to the memory at bit OFFSET. */ size POLY_SIZE to the memory at bit POLY_OFFSET. */
tree tree
fold_ctor_reference (tree type, tree ctor, unsigned HOST_WIDE_INT offset, fold_ctor_reference (tree type, tree ctor, poly_uint64 poly_offset,
unsigned HOST_WIDE_INT size, tree from_decl) poly_uint64 poly_size, tree from_decl)
{ {
tree ret; tree ret;
/* We found the field with exact match. */ /* We found the field with exact match. */
if (useless_type_conversion_p (type, TREE_TYPE (ctor)) if (useless_type_conversion_p (type, TREE_TYPE (ctor))
&& !offset) && known_eq (poly_offset, 0U))
return canonicalize_constructor_val (unshare_expr (ctor), from_decl); return canonicalize_constructor_val (unshare_expr (ctor), from_decl);
/* The remaining optimizations need a constant size and offset. */
unsigned HOST_WIDE_INT size, offset;
if (!poly_size.is_constant (&size) || !poly_offset.is_constant (&offset))
return NULL_TREE;
/* We are at the end of walk, see if we can view convert the /* We are at the end of walk, see if we can view convert the
result. */ result. */
if (!AGGREGATE_TYPE_P (TREE_TYPE (ctor)) && !offset if (!AGGREGATE_TYPE_P (TREE_TYPE (ctor)) && !offset
......
...@@ -44,8 +44,7 @@ extern tree follow_single_use_edges (tree); ...@@ -44,8 +44,7 @@ extern tree follow_single_use_edges (tree);
extern tree gimple_fold_stmt_to_constant_1 (gimple *, tree (*) (tree), extern tree gimple_fold_stmt_to_constant_1 (gimple *, tree (*) (tree),
tree (*) (tree) = no_follow_ssa_edges); tree (*) (tree) = no_follow_ssa_edges);
extern tree gimple_fold_stmt_to_constant (gimple *, tree (*) (tree)); extern tree gimple_fold_stmt_to_constant (gimple *, tree (*) (tree));
extern tree fold_ctor_reference (tree, tree, unsigned HOST_WIDE_INT, extern tree fold_ctor_reference (tree, tree, poly_uint64, poly_uint64, tree);
unsigned HOST_WIDE_INT, tree);
extern tree fold_const_aggregate_ref_1 (tree, tree (*) (tree)); extern tree fold_const_aggregate_ref_1 (tree, tree (*) (tree));
extern tree fold_const_aggregate_ref (tree); extern tree fold_const_aggregate_ref (tree);
extern tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree, extern tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT, tree,
......
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