This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [11/13] Use vec_perm_builder::series_p in shift_amt_for_vec_perm_mask
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Richard Sandiford <richard dot sandiford at linaro dot org>
- Date: Tue, 2 Jan 2018 14:08:49 +0100
- Subject: Re: [11/13] Use vec_perm_builder::series_p in shift_amt_for_vec_perm_mask
- Authentication-results: sourceware.org; auth=none
- References: <87indfmrgt.fsf@linaro.org> <877etvlc4g.fsf@linaro.org> <871sk3lc2y.fsf_-_@linaro.org>
On Sun, Dec 10, 2017 at 12:24 AM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> This patch makes shift_amt_for_vec_perm_mask use series_p to check
> for the simple case of a natural linear series before falling back
> to testing each element individually. The series_p test works with
> variable-length vectors but testing every individual element doesn't.
Ok.
Richard.
>
> 2017-12-09 Richard Sandiford <richard.sandiford@linaro.org>
>
> gcc/
> * optabs.c (shift_amt_for_vec_perm_mask): Try using series_p
> before testing each element individually.
>
> Index: gcc/optabs.c
> ===================================================================
> --- gcc/optabs.c 2017-12-09 22:48:52.266015836 +0000
> +++ gcc/optabs.c 2017-12-09 22:48:56.257154317 +0000
> @@ -5375,20 +5375,20 @@ vector_compare_rtx (machine_mode cmp_mod
> static rtx
> shift_amt_for_vec_perm_mask (machine_mode mode, const vec_perm_indices &sel)
> {
> - unsigned int i, first, nelt = GET_MODE_NUNITS (mode);
> + unsigned int nelt = GET_MODE_NUNITS (mode);
> unsigned int bitsize = GET_MODE_UNIT_BITSIZE (mode);
> -
> - first = sel[0];
> + unsigned int first = sel[0];
> if (first >= nelt)
> return NULL_RTX;
> - for (i = 1; i < nelt; i++)
> - {
> - int idx = sel[i];
> - unsigned int expected = i + first;
> - /* Indices into the second vector are all equivalent. */
> - if (idx < 0 || (MIN (nelt, (unsigned) idx) != MIN (nelt, expected)))
> - return NULL_RTX;
> - }
> +
> + if (!sel.series_p (0, 1, first, 1))
> + for (unsigned int i = 1; i < nelt; i++)
> + {
> + unsigned int expected = i + first;
> + /* Indices into the second vector are all equivalent. */
> + if (MIN (nelt, sel[i]) != MIN (nelt, expected))
> + return NULL_RTX;
> + }
>
> return GEN_INT (first * bitsize);
> }