Richard Biener <[email protected]> writes:
> This fixes VECTOR_CST element access with POLY_INT elements and
> allows to produce dump files of the PR98726 testcase without
> ICEing.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, OK?
>
> Thanks,
> Richard.
>
> 2021-01-26 Richard Biener <[email protected]>
>
> PR middle-end/98726
> * tree.h (vector_cst_int_elt): Remove.
> * tree.c (vector_cst_int_elt): Use poly_wide_int for computations,
> make static.
Is it OK to backport this to GCC 10, along with the follow-on rtl patch?
(1b5f74e8be4dd7abe5624ff60adceff19ca71bda)?
Richard
> ---
> gcc/tree.c | 10 +++++-----
> gcc/tree.h | 1 -
> 2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/tree.c b/gcc/tree.c
> index 287e5001dc3..f9d57e6d409 100644
> --- a/gcc/tree.c
> +++ b/gcc/tree.c
> @@ -11079,13 +11079,13 @@ build_opaque_vector_type (tree innertype,
> poly_int64 nunits)
>
> /* Return the value of element I of VECTOR_CST T as a wide_int. */
>
> -wide_int
> +static poly_wide_int
> vector_cst_int_elt (const_tree t, unsigned int i)
> {
> /* First handle elements that are directly encoded. */
> unsigned int encoded_nelts = vector_cst_encoded_nelts (t);
> if (i < encoded_nelts)
> - return wi::to_wide (VECTOR_CST_ENCODED_ELT (t, i));
> + return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, i));
>
> /* Identify the pattern that contains element I and work out the index of
> the last encoded element for that pattern. */
> @@ -11096,13 +11096,13 @@ vector_cst_int_elt (const_tree t, unsigned int i)
>
> /* If there are no steps, the final encoded value is the right one. */
> if (!VECTOR_CST_STEPPED_P (t))
> - return wi::to_wide (VECTOR_CST_ENCODED_ELT (t, final_i));
> + return wi::to_poly_wide (VECTOR_CST_ENCODED_ELT (t, final_i));
>
> /* Otherwise work out the value from the last two encoded elements. */
> tree v1 = VECTOR_CST_ENCODED_ELT (t, final_i - npatterns);
> tree v2 = VECTOR_CST_ENCODED_ELT (t, final_i);
> - wide_int diff = wi::to_wide (v2) - wi::to_wide (v1);
> - return wi::to_wide (v2) + (count - 2) * diff;
> + poly_wide_int diff = wi::to_poly_wide (v2) - wi::to_poly_wide (v1);
> + return wi::to_poly_wide (v2) + (count - 2) * diff;
> }
>
> /* Return the value of element I of VECTOR_CST T. */
> diff --git a/gcc/tree.h b/gcc/tree.h
> index 02b03d1f68e..17a811c02e8 100644
> --- a/gcc/tree.h
> +++ b/gcc/tree.h
> @@ -4762,7 +4762,6 @@ extern tree last_field (const_tree) ATTRIBUTE_NONNULL
> (1);
> extern bool initializer_zerop (const_tree, bool * = NULL);
> extern bool initializer_each_zero_or_onep (const_tree);
>
> -extern wide_int vector_cst_int_elt (const_tree, unsigned int);
> extern tree vector_cst_elt (const_tree, unsigned int);
>
> /* Given a vector VEC, return its first element if all elements are