This patch changes the offset parameter to build_ref_for_offset from HOST_WIDE_INT to poly_int64.
2017-10-23 Richard Sandiford <richard.sandif...@linaro.org> Alan Hayward <alan.hayw...@arm.com> David Sherwood <david.sherw...@arm.com> gcc/ * ipa-prop.h (build_ref_for_offset): Take the offset as a poly_int64 rather than a HOST_WIDE_INT. * tree-sra.c (build_ref_for_offset): Likewise. Index: gcc/ipa-prop.h =================================================================== --- gcc/ipa-prop.h 2017-10-23 17:16:58.508429306 +0100 +++ gcc/ipa-prop.h 2017-10-23 17:22:20.152210973 +0100 @@ -878,7 +878,7 @@ void ipa_release_body_info (struct ipa_f tree ipa_get_callee_param_type (struct cgraph_edge *e, int i); /* From tree-sra.c: */ -tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, bool, tree, +tree build_ref_for_offset (location_t, tree, poly_int64, bool, tree, gimple_stmt_iterator *, bool); /* In ipa-cp.c */ Index: gcc/tree-sra.c =================================================================== --- gcc/tree-sra.c 2017-10-23 17:18:47.667056920 +0100 +++ gcc/tree-sra.c 2017-10-23 17:22:20.153211173 +0100 @@ -1671,7 +1671,7 @@ make_fancy_name (tree expr) of handling bitfields. */ tree -build_ref_for_offset (location_t loc, tree base, HOST_WIDE_INT offset, +build_ref_for_offset (location_t loc, tree base, poly_int64 offset, bool reverse, tree exp_type, gimple_stmt_iterator *gsi, bool insert_after) { @@ -1689,7 +1689,7 @@ build_ref_for_offset (location_t loc, tr TYPE_QUALS (exp_type) | ENCODE_QUAL_ADDR_SPACE (as)); - gcc_checking_assert (offset % BITS_PER_UNIT == 0); + poly_int64 byte_offset = exact_div (offset, BITS_PER_UNIT); get_object_alignment_1 (base, &align, &misalign); base = get_addr_base_and_unit_offset (base, &base_offset); @@ -1711,27 +1711,26 @@ build_ref_for_offset (location_t loc, tr else gsi_insert_before (gsi, stmt, GSI_SAME_STMT); - off = build_int_cst (reference_alias_ptr_type (prev_base), - offset / BITS_PER_UNIT); + off = build_int_cst (reference_alias_ptr_type (prev_base), byte_offset); base = tmp; } else if (TREE_CODE (base) == MEM_REF) { off = build_int_cst (TREE_TYPE (TREE_OPERAND (base, 1)), - base_offset + offset / BITS_PER_UNIT); + base_offset + byte_offset); off = int_const_binop (PLUS_EXPR, TREE_OPERAND (base, 1), off); base = unshare_expr (TREE_OPERAND (base, 0)); } else { off = build_int_cst (reference_alias_ptr_type (prev_base), - base_offset + offset / BITS_PER_UNIT); + base_offset + byte_offset); base = build_fold_addr_expr (unshare_expr (base)); } - misalign = (misalign + offset) & (align - 1); - if (misalign != 0) - align = least_bit_hwi (misalign); + unsigned int align_bound = known_alignment (misalign + offset); + if (align_bound != 0) + align = MIN (align, align_bound); if (align != TYPE_ALIGN (exp_type)) exp_type = build_aligned_type (exp_type, align);