summaryrefslogtreecommitdiff
path: root/gcc/tree-ssa.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-12-21 07:02:13 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-12-21 07:02:13 +0000
commitaca52e6f8d29064f4712e5f3f4429a36f918f099 (patch)
tree45c2884952716e83f81ee8162585cbf16e06bf73 /gcc/tree-ssa.c
parent3fed2ce96f7ec8ee8603b33ba0426ac40acecf24 (diff)
poly_int: MEM_REF offsets
This patch allows MEM_REF offsets to be polynomial, with mem_ref_offset now returning a poly_offset_int instead of an offset_int. The non-mechanical changes to callers of mem_ref_offset were handled by previous patches. 2017-12-21 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * fold-const.h (mem_ref_offset): Return a poly_offset_int rather than an offset_int. * tree.c (mem_ref_offset): Likewise. (build_simple_mem_ref_loc): Treat MEM_REF offsets as poly_ints. * builtins.c (get_object_alignment_2): Likewise. * expr.c (get_inner_reference, expand_expr_real_1): Likewise. * gimple-fold.c (get_base_constructor): Likewise. * gimple-ssa-strength-reduction.c (restructure_reference): Likewise. * gimple-ssa-warn-restrict.c (builtin_memref::builtin_memref): Likewise. * ipa-polymorphic-call.c (ipa_polymorphic_call_context::ipa_polymorphic_call_context): Likewise. * ipa-prop.c (compute_complex_assign_jump_func): Likewise. (get_ancestor_addr_info): Likewise. * ipa-param-manipulation.c (ipa_get_adjustment_candidate): Likewise. * match.pd: Likewise. * tree-data-ref.c (dr_analyze_innermost): Likewise. * tree-dfa.c (get_addr_base_and_unit_offset_1): Likewise. * tree-eh.c (tree_could_trap_p): Likewise. * tree-object-size.c (addr_object_size): Likewise. * tree-ssa-address.c (copy_ref_info): Likewise. * tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Likewise. (indirect_refs_may_alias_p): Likewise. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Likewise. * tree-ssa.c (maybe_rewrite_mem_ref_base): Likewise. (non_rewritable_mem_ref_base): Likewise. * tree-vect-data-refs.c (vect_check_gather_scatter): Likewise. * tree-vrp.c (vrp_prop::check_array_ref): Likewise. * varasm.c (decode_addr_const): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r255930
Diffstat (limited to 'gcc/tree-ssa.c')
-rw-r--r--gcc/tree-ssa.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 151f544baba..c04e0cc6dbf 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1379,10 +1379,10 @@ maybe_rewrite_mem_ref_base (tree *tp, bitmap suitable_for_renaming)
}
else if (DECL_SIZE (sym)
&& TREE_CODE (DECL_SIZE (sym)) == INTEGER_CST
- && mem_ref_offset (*tp) >= 0
- && wi::leu_p (mem_ref_offset (*tp)
- + wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (*tp))),
- wi::to_offset (DECL_SIZE_UNIT (sym)))
+ && (known_subrange_p
+ (mem_ref_offset (*tp),
+ wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (*tp))),
+ 0, wi::to_offset (DECL_SIZE_UNIT (sym))))
&& (! INTEGRAL_TYPE_P (TREE_TYPE (*tp))
|| (wi::to_offset (TYPE_SIZE (TREE_TYPE (*tp)))
== TYPE_PRECISION (TREE_TYPE (*tp))))
@@ -1433,9 +1433,8 @@ non_rewritable_mem_ref_base (tree ref)
|| TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE)
&& useless_type_conversion_p (TREE_TYPE (base),
TREE_TYPE (TREE_TYPE (decl)))
- && wi::fits_uhwi_p (mem_ref_offset (base))
- && wi::gtu_p (wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (decl))),
- mem_ref_offset (base))
+ && known_gt (wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (decl))),
+ mem_ref_offset (base))
&& multiple_of_p (sizetype, TREE_OPERAND (base, 1),
TYPE_SIZE_UNIT (TREE_TYPE (base))))
return NULL_TREE;
@@ -1445,11 +1444,10 @@ non_rewritable_mem_ref_base (tree ref)
return NULL_TREE;
/* For integral typed extracts we can use a BIT_FIELD_REF. */
if (DECL_SIZE (decl)
- && TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST
- && mem_ref_offset (base) >= 0
- && wi::leu_p (mem_ref_offset (base)
- + wi::to_offset (TYPE_SIZE_UNIT (TREE_TYPE (base))),
- wi::to_offset (DECL_SIZE_UNIT (decl)))
+ && (known_subrange_p
+ (mem_ref_offset (base),
+ wi::to_poly_offset (TYPE_SIZE_UNIT (TREE_TYPE (base))),
+ 0, wi::to_poly_offset (DECL_SIZE_UNIT (decl))))
/* ??? We can't handle bitfield precision extracts without
either using an alternate type for the BIT_FIELD_REF and
then doing a conversion or possibly adjusting the offset