public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: hongtao Liu <liuhongt@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-2754] Don't check can_vec_perm_const_p for nonlinear iv_init when it's constant.
Date: Wed, 21 Sep 2022 07:47:59 +0000 (GMT)	[thread overview]
Message-ID: <20220921074759.7DC0C3851C37@sourceware.org> (raw)

https://gcc.gnu.org/g:eddbb81f1254f025d6f1b6b8e7554aa9a3830302

commit r13-2754-geddbb81f1254f025d6f1b6b8e7554aa9a3830302
Author: liuhongt <hongtao.liu@intel.com>
Date:   Tue Sep 20 13:22:28 2022 +0800

    Don't check can_vec_perm_const_p for nonlinear iv_init when it's constant.
    
    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.
    
    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.

Diff:
---
 gcc/testsuite/gcc.target/i386/pr106963.c | 14 ++++++++++++++
 gcc/tree-vect-loop.cc                    |  5 ++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

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,

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

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220921074759.7DC0C3851C37@sourceware.org \
    --to=liuhongt@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).