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-patches@gcc.gnu.org>
Subject: Re: [PATCH] Don't check can_vec_perm_const_p for nonlinear iv_init when it's constant.
Date: Wed, 21 Sep 2022 09:41:11 +0200	[thread overview]
Message-ID: <CAFiYyc0mt4ABJ5CGJ6Z2tC00O4KWkhcoJbGozjn1M21-aoz-tw@mail.gmail.com> (raw)
In-Reply-To: <20220920233835.45071-1-hongtao.liu@intel.com>

On Wed, Sep 21, 2022 at 1:41 AM liuhongt via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> When init_expr is INTEGER_CST or REAL_CST, can_vec_perm_const_p is not
> necessary since there's no real vec_perm needed, but
> vec_gen_perm_mask_checked will gcc_assert (can_vec_perm_const_p). So
> it's better to use vec_gen_perm_mask_any in
> vect_create_nonlinear_iv_init.

and the VEC_PERM build will fold the permute away?

> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
> Ok for trunk?

OK.

Thanks,
Richard.

> gcc/ChangeLog:
>
>         PR tree-optimization/106963
>         * tree-vect-loop.cc (vect_create_nonlinear_iv_init): Use
>         vec_gen_perm_mask_any instead of vec_gen_perm_mask_check.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/i386/pr106963.c: New test.
> ---
>  gcc/testsuite/gcc.target/i386/pr106963.c | 14 ++++++++++++++
>  gcc/tree-vect-loop.cc                    |  5 ++++-
>  2 files changed, 18 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr106963.c
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr106963.c b/gcc/testsuite/gcc.target/i386/pr106963.c
> new file mode 100644
> index 00000000000..9f2d20e2523
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr106963.c
> @@ -0,0 +1,14 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -mavx -mno-avx2" } */
> +
> +void
> +foo_neg_const (int *a)
> +{
> +  int i, b = 1;
> +
> +  for (i = 0; i < 1000; i++)
> +    {
> +      a[i] = b;
> +      b = -b;
> +    }
> +}
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index 9c434b66c5b..aabdc6f2d81 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -8356,8 +8356,11 @@ vect_create_nonlinear_iv_init (gimple_seq* stmts, tree init_expr,
>             sel[2 * i + 1] = i + nunits;
>           }
>         vec_perm_indices indices (sel, 2, nunits);
> +       /* Don't use vect_gen_perm_mask_checked since can_vec_perm_const_p may
> +          fail when vec_init is const vector. In that situation vec_perm is not
> +          really needed.  */
>         tree perm_mask_even
> -         = vect_gen_perm_mask_checked (vectype, indices);
> +         = vect_gen_perm_mask_any (vectype, indices);
>         vec_init = gimple_build (stmts, VEC_PERM_EXPR,
>                                  vectype,
>                                  vec_init, vec_neg,
> --
> 2.18.1
>

  reply	other threads:[~2022-09-21  7:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20 23:38 liuhongt
2022-09-21  7:41 ` Richard Biener [this message]
2022-09-21  7:45   ` Hongtao Liu

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=CAFiYyc0mt4ABJ5CGJ6Z2tC00O4KWkhcoJbGozjn1M21-aoz-tw@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).