diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-12-20 12:55:45 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-12-20 12:55:45 +0000 |
commit | cc8bea091633989bef6d665c40193a9e255ceb81 (patch) | |
tree | 0198dc636ad0b00daedf03723bb5e7349e3373a3 /gcc/tree-ssa-loop-ivopts.c | |
parent | a90c88042b29b16ecadc2f0560f4d3581bcf9ad6 (diff) | |
download | gcc-cc8bea091633989bef6d665c40193a9e255ceb81.zip gcc-cc8bea091633989bef6d665c40193a9e255ceb81.tar.gz gcc-cc8bea091633989bef6d665c40193a9e255ceb81.tar.bz2 |
poly_int: aff_tree
This patch changes the type of aff_tree::offset from widest_int to
poly_widest_int and adjusts the function interfaces in the same way.
2017-12-20 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* tree-affine.h (aff_tree::offset): Change from widest_int
to poly_widest_int.
(wide_int_ext_for_comb): Delete.
(aff_combination_const, aff_comb_cannot_overlap_p): Take the
constants as poly_widest_int rather than widest_int.
(aff_combination_constant_multiple_p): Return the multiplier
as a poly_widest_int.
(aff_combination_zero_p, aff_combination_singleton_var_p): Handle
polynomial offsets.
* tree-affine.c (wide_int_ext_for_comb): Make original widest_int
version static and add an overload for poly_widest_int.
(aff_combination_const, aff_combination_add_cst)
(wide_int_constant_multiple_p, aff_comb_cannot_overlap_p): Take
the constants as poly_widest_int rather than widest_int.
(tree_to_aff_combination): Generalize INTEGER_CST case to
poly_int_tree_p.
(aff_combination_to_tree): Track offsets as poly_widest_ints.
(aff_combination_add_product, aff_combination_mult): Handle
polynomial offsets.
(aff_combination_constant_multiple_p): Return the multiplier
as a poly_widest_int.
* tree-predcom.c (determine_offset): Return the offset as a
poly_widest_int.
(split_data_refs_to_components, suitable_component_p): Update
accordingly.
(valid_initializer_p): Update call to
aff_combination_constant_multiple_p.
* tree-ssa-address.c (addr_to_parts): Handle polynomial offsets.
* tree-ssa-loop-ivopts.c (get_address_cost_ainc): Take the step
as a poly_int64 rather than a HOST_WIDE_INT.
(get_address_cost): Handle polynomial offsets.
(iv_elimination_compare_lt): Likewise.
(rewrite_use_nonlinear_expr): Likewise.
Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r255888
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r-- | gcc/tree-ssa-loop-ivopts.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index d5743c5..5555f46 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4229,7 +4229,7 @@ struct ainc_cost_data }; static comp_cost -get_address_cost_ainc (HOST_WIDE_INT ainc_step, HOST_WIDE_INT ainc_offset, +get_address_cost_ainc (poly_int64 ainc_step, poly_int64 ainc_offset, machine_mode addr_mode, machine_mode mem_mode, addr_space_t as, bool speed) { @@ -4303,13 +4303,13 @@ get_address_cost_ainc (HOST_WIDE_INT ainc_step, HOST_WIDE_INT ainc_offset, } HOST_WIDE_INT msize = GET_MODE_SIZE (mem_mode); - if (ainc_offset == 0 && msize == ainc_step) + if (known_eq (ainc_offset, 0) && known_eq (msize, ainc_step)) return comp_cost (data->costs[AINC_POST_INC], 0); - if (ainc_offset == 0 && msize == -ainc_step) + if (known_eq (ainc_offset, 0) && known_eq (msize, -ainc_step)) return comp_cost (data->costs[AINC_POST_DEC], 0); - if (ainc_offset == msize && msize == ainc_step) + if (known_eq (ainc_offset, msize) && known_eq (msize, ainc_step)) return comp_cost (data->costs[AINC_PRE_INC], 0); - if (ainc_offset == -msize && msize == -ainc_step) + if (known_eq (ainc_offset, -msize) && known_eq (msize, -ainc_step)) return comp_cost (data->costs[AINC_PRE_DEC], 0); return infinite_cost; @@ -4359,7 +4359,7 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, } if (ok_with_ratio_p || ok_without_ratio_p) { - if (aff_inv->offset != 0) + if (maybe_ne (aff_inv->offset, 0)) { parts.offset = wide_int_to_tree (sizetype, aff_inv->offset); /* Addressing mode "base + index [<< scale] + offset". */ @@ -4392,10 +4392,12 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, } else { - if (can_autoinc && ratio == 1 && cst_and_fits_in_hwi (cand->iv->step)) + poly_int64 ainc_step; + if (can_autoinc + && ratio == 1 + && ptrdiff_tree_p (cand->iv->step, &ainc_step)) { - HOST_WIDE_INT ainc_step = int_cst_value (cand->iv->step); - HOST_WIDE_INT ainc_offset = (aff_inv->offset).to_shwi (); + poly_int64 ainc_offset = (aff_inv->offset).force_shwi (); if (stmt_after_increment (data->current_loop, cand, use->stmt)) ainc_offset += ainc_step; @@ -4955,7 +4957,7 @@ iv_elimination_compare_lt (struct ivopts_data *data, aff_combination_scale (&tmpa, -1); aff_combination_add (&tmpb, &tmpa); aff_combination_add (&tmpb, &nit); - if (tmpb.n != 0 || tmpb.offset != 1) + if (tmpb.n != 0 || maybe_ne (tmpb.offset, 1)) return false; /* Finally, check that CAND->IV->BASE - CAND->IV->STEP * A does not @@ -6852,7 +6854,7 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data, unshare_aff_combination (&aff_var); /* Prefer CSE opportunity than loop invariant by adding offset at last so that iv_uses have different offsets can be CSEed. */ - widest_int offset = aff_inv.offset; + poly_widest_int offset = aff_inv.offset; aff_inv.offset = 0; gimple_seq stmt_list = NULL, seq = NULL; |