public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2754] Don't check can_vec_perm_const_p for nonlinear iv_init when it's constant.
@ 2022-09-21 7:47 hongtao Liu
0 siblings, 0 replies; only message in thread
From: hongtao Liu @ 2022-09-21 7:47 UTC (permalink / raw)
To: gcc-cvs
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,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-21 7:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-21 7:47 [gcc r13-2754] Don't check can_vec_perm_const_p for nonlinear iv_init when it's constant hongtao Liu
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).