From: Kevin Lee <kevinl@rivosinc.com>
To: gcc-patches@gcc.gnu.org
Cc: gnu-toolchain@rivosinc.com, Kevin Lee <kevinl@rivosinc.com>
Subject: [RFC][Patch] vect: verify that nelt is greater than one
Date: Wed, 22 Mar 2023 22:11:51 -0700 [thread overview]
Message-ID: <20230323051151.2982138-1-kevinl@rivosinc.com> (raw)
This is a patch related to https://gcc.gnu.org/pipermail/gcc-patches/2023-March/613977.html,
aiming for gcc14. Since the RISC-V target has vector modes (e.g. VNx1DImode)
with nelt smaller than 2, npat has to match with the nelt to create proper
vec_perm_indices.
I tested on x86_64-linux-gnu and didn't cause more failures, but wasn't sure if
total_elem would be used in the rest of the function. Should there be additional
changes in the vect_grouped_store_supported? Thank you!
gcc/ChangeLog:
Kevin Lee <kevinl@rivosinc.com>
* tree-vect-data-refs.cc (vect_grouped_store_supported): Check
if the nelt is greater than one.
---
gcc/tree-vect-data-refs.cc | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index 8daf7bd7dd3..9c09cc973d0 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -5399,17 +5399,20 @@ vect_grouped_store_supported (tree vectype, unsigned HOST_WIDE_INT count)
poly_uint64 nelt = GET_MODE_NUNITS (mode);
/* The encoding has 2 interleaved stepped patterns. */
- vec_perm_builder sel (nelt, 2, 3);
- sel.quick_grow (6);
+
+ unsigned int npat = known_gt(nelt, (unsigned int) 1) ? 2 : 1;
+ unsigned int total_elem = npat * 3;
+ vec_perm_builder sel (nelt, npat, 3);
+ sel.quick_grow (total_elem);
for (i = 0; i < 3; i++)
{
- sel[i * 2] = i;
- sel[i * 2 + 1] = i + nelt;
+ sel[i * npat] = i;
+ sel[i * npat + 1] = i + nelt;
}
vec_perm_indices indices (sel, 2, nelt);
if (can_vec_perm_const_p (mode, mode, indices))
{
- for (i = 0; i < 6; i++)
+ for (i = 0; i < total_elem; i++)
sel[i] += exact_div (nelt, 2);
indices.new_vector (sel, 2, nelt);
if (can_vec_perm_const_p (mode, mode, indices))
--
2.25.1
reply other threads:[~2023-03-23 5:11 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=20230323051151.2982138-1-kevinl@rivosinc.com \
--to=kevinl@rivosinc.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gnu-toolchain@rivosinc.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).