public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: liuhongt <hongtao.liu@intel.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] [ICE] Check another epilog variable peeling case in vectorizable_nonlinear_induction.
Date: Wed, 14 Sep 2022 08:11:51 +0200	[thread overview]
Message-ID: <CAFiYyc1c_E8nKPkP1PtVTey=Zh01ibzQYHQThYyK4wfh4ORM3A@mail.gmail.com> (raw)
In-Reply-To: <20220914012511.1012154-1-hongtao.liu@intel.com>

On Wed, Sep 14, 2022 at 3:25 AM liuhongt via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> In vectorizable_nonlinear_induction, r13-2503-gc13223b790bbc5 prevent variable peeling by
> only checking LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo). But when
> "!vect_use_loop_mask_for_alignment_p (loop_vinfo) &&
> LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0", vectorizer will
> still do variable peeling for epilog, and it hits gcc_assert in
> vect_peel_nonlinear_iv_init.
>
>
> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
> The patch also fix ICE of the testcase in the PR for ia64-linux-gnu(verified by cross-compile).
>
> Ok for trunk?

OK.

Thanks,
Richard.

> gcc/ChangeLog:
>
>         PR tree-optimization/106905
>         * tree-vect-loop.cc (vectorizable_nonlinear_induction): Return
>         false when !vect_use_loop_mask_for_alignment_p (loop_vinfo) &&
>         LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/i386/pr106905.c: New test.
>         * gcc.target/ia64/pr106905.c: New test.
> ---
>  gcc/testsuite/gcc.target/i386/pr106905.c | 14 ++++++++++++++
>  gcc/testsuite/gcc.target/ia64/pr106905.c | 20 ++++++++++++++++++++
>  gcc/tree-vect-loop.cc                    |  6 ++++--
>  3 files changed, 38 insertions(+), 2 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr106905.c
>  create mode 100644 gcc/testsuite/gcc.target/ia64/pr106905.c
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr106905.c b/gcc/testsuite/gcc.target/i386/pr106905.c
> new file mode 100644
> index 00000000000..a190a1c84e6
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr106905.c
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=silvermont -O2 -fvect-cost-model=dynamic" } */
> +
> +void
> +foo_mul_peel (int *a, int b)
> +{
> +  int i;
> +
> +  for (i = 0; i < 7; ++i)
> +    {
> +      b *= 2;
> +      a[i] = b;
> +    }
> +}
> diff --git a/gcc/testsuite/gcc.target/ia64/pr106905.c b/gcc/testsuite/gcc.target/ia64/pr106905.c
> new file mode 100644
> index 00000000000..1b9656e1203
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/ia64/pr106905.c
> @@ -0,0 +1,20 @@
> +/* { dg-do compile } */
> +/* { dg-options "-std=c99 -O3 -fPIC" } */
> +long ZDICT_fillNoise_p, ZDICT_trainFromBuffer_legacy_result;
> +unsigned ZDICT_fillNoise_acc;
> +int ZDICT_totalSampleSize_nbFiles;
> +static void ZDICT_fillNoise(void *buffer, long length) {
> +  unsigned prime2 = 9;
> +  for (ZDICT_fillNoise_p = 0; ZDICT_fillNoise_p < length; ZDICT_fillNoise_p++)
> +    ZDICT_fillNoise_acc *= ((char *)buffer)[ZDICT_fillNoise_p] = prime2;
> +}
> +long ZDICT_trainFromBuffer_legacy() {
> +  void *newBuff;
> +  long total = 0;
> +  for (; ZDICT_totalSampleSize_nbFiles;)
> +    total += 0;
> +  long sBuffSize = total;
> +  newBuff = 0;
> +  ZDICT_fillNoise(newBuff + sBuffSize, 32);
> +  return ZDICT_trainFromBuffer_legacy_result;
> +}
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index 8f88f1755be..9c434b66c5b 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -8646,8 +8646,10 @@ vectorizable_nonlinear_induction (loop_vec_info loop_vinfo,
>    /* Also doens't support peel for neg when niter is variable.
>       ??? generate something like niter_expr & 1 ? init_expr : -init_expr?  */
>    niters_skip = LOOP_VINFO_MASK_SKIP_NITERS (loop_vinfo);
> -  if (niters_skip != NULL_TREE
> -      && TREE_CODE (niters_skip) != INTEGER_CST)
> +  if ((niters_skip != NULL_TREE
> +       && TREE_CODE (niters_skip) != INTEGER_CST)
> +      || (!vect_use_loop_mask_for_alignment_p (loop_vinfo)
> +         && LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0))
>      {
>        if (dump_enabled_p ())
>         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> --
> 2.27.0
>

      reply	other threads:[~2022-09-14  6:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14  1:25 liuhongt
2022-09-14  6:11 ` Richard Biener [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc1c_E8nKPkP1PtVTey=Zh01ibzQYHQThYyK4wfh4ORM3A@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hongtao.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).