From: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
To: krebbel@linux.ibm.com, gcc-patches@gcc.gnu.org
Cc: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Subject: [PATCH 2/3] s390: Add expand_perm_reverse_elements
Date: Thu, 9 Nov 2023 09:22:10 +0100 [thread overview]
Message-ID: <20231109082211.2505-2-stefansf@linux.ibm.com> (raw)
In-Reply-To: <20231109082211.2505-1-stefansf@linux.ibm.com>
Replace expand_perm_with_rot, expand_perm_with_vster, and
expand_perm_with_vstbrq with a general implementation
expand_perm_reverse_elements.
Bootstrapped and regtested on s390. Ok for mainline?
gcc/ChangeLog:
* config/s390/s390.cc (expand_perm_with_rot): Remove.
(expand_perm_reverse_elements): New.
(expand_perm_with_vster): Remove.
(expand_perm_with_vstbrq): Remove.
(vectorize_vec_perm_const_1): Replace removed functions with new
one.
---
gcc/config/s390/s390.cc | 88 ++++++++---------------------------------
1 file changed, 16 insertions(+), 72 deletions(-)
diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index 185eb59f8b8..e36efec8ddc 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -17693,78 +17693,28 @@ is_reverse_perm_mask (const struct expand_vec_perm_d &d)
return true;
}
-/* The case of reversing a four-element vector [0, 1, 2, 3]
- can be handled by first permuting the doublewords
- [2, 3, 0, 1] and subsequently rotating them by 32 bits. */
static bool
-expand_perm_with_rot (const struct expand_vec_perm_d &d)
+expand_perm_reverse_elements (const struct expand_vec_perm_d &d)
{
- if (d.nelt != 4)
+ if (d.op0 != d.op1 || !is_reverse_perm_mask (d))
return false;
- if (d.op0 == d.op1 && is_reverse_perm_mask (d))
- {
- if (d.testing_p)
- return true;
-
- rtx tmp = gen_reg_rtx (d.vmode);
- rtx op0_reg = force_reg (GET_MODE (d.op0), d.op0);
-
- emit_insn (gen_vpdi4_2 (d.vmode, tmp, op0_reg, op0_reg));
- if (d.vmode == V4SImode)
- emit_insn (gen_rotlv4si3_di (d.target, tmp));
- else if (d.vmode == V4SFmode)
- emit_insn (gen_rotlv4sf3_di (d.target, tmp));
-
- return true;
- }
-
- return false;
-}
+ if (d.testing_p)
+ return true;
-/* If we just reverse the elements, emit an eltswap if we have
- vler/vster. */
-static bool
-expand_perm_with_vster (const struct expand_vec_perm_d &d)
-{
- if (TARGET_VXE2 && d.op0 == d.op1 && is_reverse_perm_mask (d)
- && (d.vmode == V2DImode || d.vmode == V2DFmode
- || d.vmode == V4SImode || d.vmode == V4SFmode
- || d.vmode == V8HImode))
+ switch (d.vmode)
{
- if (d.testing_p)
- return true;
-
- if (d.vmode == V2DImode)
- emit_insn (gen_eltswapv2di (d.target, d.op0));
- else if (d.vmode == V2DFmode)
- emit_insn (gen_eltswapv2df (d.target, d.op0));
- else if (d.vmode == V4SImode)
- emit_insn (gen_eltswapv4si (d.target, d.op0));
- else if (d.vmode == V4SFmode)
- emit_insn (gen_eltswapv4sf (d.target, d.op0));
- else if (d.vmode == V8HImode)
- emit_insn (gen_eltswapv8hi (d.target, d.op0));
- return true;
+ case V1TImode: emit_move_insn (d.target, d.op0); break;
+ case V2DImode: emit_insn (gen_eltswapv2di (d.target, d.op0)); break;
+ case V4SImode: emit_insn (gen_eltswapv4si (d.target, d.op0)); break;
+ case V8HImode: emit_insn (gen_eltswapv8hi (d.target, d.op0)); break;
+ case V16QImode: emit_insn (gen_eltswapv16qi (d.target, d.op0)); break;
+ case V2DFmode: emit_insn (gen_eltswapv2df (d.target, d.op0)); break;
+ case V4SFmode: emit_insn (gen_eltswapv4sf (d.target, d.op0)); break;
+ default: gcc_unreachable();
}
- return false;
-}
-/* If we reverse a byte-vector this is the same as
- byte reversing it which can be done with vstbrq. */
-static bool
-expand_perm_with_vstbrq (const struct expand_vec_perm_d &d)
-{
- if (TARGET_VXE2 && d.op0 == d.op1 && is_reverse_perm_mask (d)
- && d.vmode == V16QImode)
- {
- if (d.testing_p)
- return true;
-
- emit_insn (gen_eltswapv16qi (d.target, d.op0));
- return true;
- }
- return false;
+ return true;
}
/* Try to emit vlbr/vstbr. Note, this is only a candidate insn since
@@ -17826,21 +17776,15 @@ expand_perm_as_a_vlbr_vstbr_candidate (const struct expand_vec_perm_d &d)
static bool
vectorize_vec_perm_const_1 (const struct expand_vec_perm_d &d)
{
- if (expand_perm_with_merge (d))
- return true;
-
- if (expand_perm_with_vster (d))
+ if (expand_perm_reverse_elements (d))
return true;
- if (expand_perm_with_vstbrq (d))
+ if (expand_perm_with_merge (d))
return true;
if (expand_perm_with_vpdi (d))
return true;
- if (expand_perm_with_rot (d))
- return true;
-
if (expand_perm_as_a_vlbr_vstbr_candidate (d))
return true;
--
2.41.0
next prev parent reply other threads:[~2023-11-09 8:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 8:22 [PATCH 1/3] s390: Recognize further vpdi and vmr{l,h} pattern Stefan Schulze Frielinghaus
2023-11-09 8:22 ` Stefan Schulze Frielinghaus [this message]
2023-11-09 8:27 ` [PATCH 2/3] s390: Add expand_perm_reverse_elements Andreas Krebbel
2023-11-09 8:22 ` [PATCH 3/3] s390: Revise vector reverse elements Stefan Schulze Frielinghaus
2023-11-09 8:27 ` Andreas Krebbel
2023-11-09 8:27 ` [PATCH 1/3] s390: Recognize further vpdi and vmr{l,h} pattern Andreas Krebbel
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=20231109082211.2505-2-stefansf@linux.ibm.com \
--to=stefansf@linux.ibm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=krebbel@linux.ibm.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).