From f37fac2b74df114c5b3e9c8a3be2cad9acd3f4ca Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 21 Dec 2017 06:57:41 +0000 Subject: poly_int: get_inner_reference & co. This patch makes get_inner_reference and ptr_difference_const return the bit size and bit position as poly_int64s rather than HOST_WIDE_INTS. The non-mechanical changes were handled by previous patches. 2017-12-21 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree.h (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. * fold-const.h (ptr_difference_const): Return the pointer difference as a poly_int64_pod rather than a HOST_WIDE_INT. * expr.c (get_inner_reference): Return the bitsize and bitpos as poly_int64_pods rather than HOST_WIDE_INT. (expand_expr_addr_expr_1, expand_expr_real_1): Track polynomial offsets and sizes. * fold-const.c (make_bit_field_ref): Take the bitpos as a poly_int64 rather than a HOST_WIDE_INT. Update call to get_inner_reference. (optimize_bit_field_compare): Update call to get_inner_reference. (decode_field_reference): Likewise. (fold_unary_loc): Track polynomial offsets and sizes. (split_address_to_core_and_offset): Return the bitpos as a poly_int64_pod rather than a HOST_WIDE_INT. (ptr_difference_const): Likewise for the pointer difference. * asan.c (instrument_derefs): Track polynomial offsets and sizes. * config/mips/mips.c (r10k_safe_mem_expr_p): Likewise. * dbxout.c (dbxout_expand_expr): Likewise. * dwarf2out.c (loc_list_for_address_of_addr_expr_of_indirect_ref) (loc_list_from_tree_1, fortran_common): Likewise. * gimple-laddress.c (pass_laddress::execute): Likewise. * gimple-ssa-store-merging.c (find_bswap_or_nop_load): Likewise. * gimplify.c (gimplify_scan_omp_clauses): Likewise. * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise. * tree-affine.c (tree_to_aff_combination): Likewise. (get_inner_reference_aff): Likewise. * tree-data-ref.c (split_constant_offset_1): Likewise. (dr_analyze_innermost): Likewise. * tree-scalar-evolution.c (interpret_rhs_expr): Likewise. * tree-sra.c (ipa_sra_check_caller): Likewise. * tree-vect-data-refs.c (vect_check_gather_scatter): Likewise. * ubsan.c (maybe_instrument_pointer_overflow): Likewise. (instrument_bool_enum_load, instrument_object_size): Likewise. * gimple-ssa-strength-reduction.c (slsr_process_ref): Update call to get_inner_reference. * hsa-gen.c (gen_hsa_addr): Likewise. * sanopt.c (maybe_optimize_ubsan_ptr_ifn): Likewise. * tsan.c (instrument_expr): Likewise. * match.pd: Update call to ptr_difference_const. gcc/ada/ * gcc-interface/trans.c (Attribute_to_gnu): Track polynomial offsets and sizes. * gcc-interface/utils2.c (build_unary_op): Likewise. gcc/cp/ * constexpr.c (check_automatic_or_tls): Track polynomial offsets and sizes. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r255914 --- gcc/tree-vect-data-refs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'gcc/tree-vect-data-refs.c') diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 78ee673..9867077 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -3226,7 +3226,8 @@ bool vect_check_gather_scatter (gimple *stmt, loop_vec_info loop_vinfo, gather_scatter_info *info) { - HOST_WIDE_INT scale = 1, pbitpos, pbitsize; + HOST_WIDE_INT scale = 1; + poly_int64 pbitpos, pbitsize; struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo); stmt_vec_info stmt_info = vinfo_for_stmt (stmt); struct data_reference *dr = STMT_VINFO_DATA_REF (stmt_info); @@ -3267,7 +3268,8 @@ vect_check_gather_scatter (gimple *stmt, loop_vec_info loop_vinfo, that can be gimplified before the loop. */ base = get_inner_reference (base, &pbitsize, &pbitpos, &off, &pmode, &punsignedp, &reversep, &pvolatilep); - gcc_assert (base && (pbitpos % BITS_PER_UNIT) == 0 && !reversep); + gcc_assert (base && !reversep); + poly_int64 pbytepos = exact_div (pbitpos, BITS_PER_UNIT); if (TREE_CODE (base) == MEM_REF) { @@ -3300,14 +3302,14 @@ vect_check_gather_scatter (gimple *stmt, loop_vec_info loop_vinfo, if (!integer_zerop (off)) return false; off = base; - base = size_int (pbitpos / BITS_PER_UNIT); + base = size_int (pbytepos); } /* Otherwise put base + constant offset into the loop invariant BASE and continue with OFF. */ else { base = fold_convert (sizetype, base); - base = size_binop (PLUS_EXPR, base, size_int (pbitpos / BITS_PER_UNIT)); + base = size_binop (PLUS_EXPR, base, size_int (pbytepos)); } /* OFF at this point may be either a SSA_NAME or some tree expression -- cgit v1.1