From: Andrew Stubbs <ams@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Subject: [committed 3/6] amdgcn: Add vec_extract for partial vectors
Date: Tue, 11 Oct 2022 12:02:05 +0100 [thread overview]
Message-ID: <5cfe08555034b29f301dcfb99a3691c81b2e2def.1665485382.git.ams@codesourcery.com> (raw)
In-Reply-To: <cover.1665485382.git.ams@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 539 bytes --]
Add vec_extract expanders for all valid pairs of vector types.
gcc/ChangeLog:
* config/gcn/gcn-protos.h (get_exec): Add prototypes for two variants.
* config/gcn/gcn-valu.md
(vec_extract<V_ALL:mode><V_ALL_ALT:mode>): New define_expand.
* config/gcn/gcn.cc (get_exec): Export the existing function. Add a
new overload variant.
---
gcc/config/gcn/gcn-protos.h | 2 ++
gcc/config/gcn/gcn-valu.md | 34 ++++++++++++++++++++++++++++++++++
gcc/config/gcn/gcn.cc | 9 ++++++++-
3 files changed, 44 insertions(+), 1 deletion(-)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-amdgcn-Add-vec_extract-for-partial-vectors.patch --]
[-- Type: text/x-patch; name="0003-amdgcn-Add-vec_extract-for-partial-vectors.patch", Size: 2900 bytes --]
diff --git a/gcc/config/gcn/gcn-protos.h b/gcc/config/gcn/gcn-protos.h
index 6300c1cbd36..f9a1fc00b4f 100644
--- a/gcc/config/gcn/gcn-protos.h
+++ b/gcc/config/gcn/gcn-protos.h
@@ -24,6 +24,8 @@ extern bool gcn_constant64_p (rtx);
extern bool gcn_constant_p (rtx);
extern rtx gcn_convert_mask_mode (rtx reg);
extern unsigned int gcn_dwarf_register_number (unsigned int regno);
+extern rtx get_exec (int64_t);
+extern rtx get_exec (machine_mode mode);
extern char * gcn_expand_dpp_shr_insn (machine_mode, const char *, int, int);
extern void gcn_expand_epilogue ();
extern rtx gcn_expand_scaled_offsets (addr_space_t as, rtx base, rtx offsets,
diff --git a/gcc/config/gcn/gcn-valu.md b/gcc/config/gcn/gcn-valu.md
index c7be2361164..9ea60e1174f 100644
--- a/gcc/config/gcn/gcn-valu.md
+++ b/gcc/config/gcn/gcn-valu.md
@@ -808,6 +808,40 @@ (define_insn "vec_extract<mode><scalar_mode>"
(set_attr "exec" "none")
(set_attr "laneselect" "yes")])
+(define_expand "vec_extract<V_ALL:mode><V_ALL_ALT:mode>"
+ [(set (match_operand:V_ALL_ALT 0 "register_operand")
+ (vec_select:V_ALL_ALT
+ (match_operand:V_ALL 1 "register_operand")
+ (parallel [(match_operand 2 "immediate_operand")])))]
+ "MODE_VF (<V_ALL_ALT:MODE>mode) < MODE_VF (<V_ALL:MODE>mode)
+ && <V_ALL_ALT:SCALAR_MODE>mode == <V_ALL:SCALAR_MODE>mode"
+ {
+ int numlanes = GET_MODE_NUNITS (<V_ALL_ALT:MODE>mode);
+ int firstlane = INTVAL (operands[2]) * numlanes;
+ rtx tmp;
+
+ if (firstlane == 0)
+ {
+ /* A plain move will do. */
+ tmp = operands[1];
+ } else {
+ /* FIXME: optimize this by using DPP where available. */
+
+ rtx permutation = gen_reg_rtx (<V_ALL:VnSI>mode);
+ emit_insn (gen_vec_series<V_ALL:vnsi> (permutation,
+ GEN_INT (firstlane*4),
+ GEN_INT (4)));
+
+ tmp = gen_reg_rtx (<V_ALL:MODE>mode);
+ emit_insn (gen_ds_bpermute<V_ALL:mode> (tmp, permutation, operands[1],
+ get_exec (<V_ALL:MODE>mode)));
+ }
+
+ emit_move_insn (operands[0],
+ gen_rtx_SUBREG (<V_ALL_ALT:MODE>mode, tmp, 0));
+ DONE;
+ })
+
(define_expand "extract_last_<mode>"
[(match_operand:<SCALAR_MODE> 0 "register_operand")
(match_operand:DI 1 "gcn_alu_operand")
diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index e1636f6ddd6..fdcf290ef8b 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -846,7 +846,7 @@ gcn_ira_change_pseudo_allocno_class (int regno, reg_class_t cl,
/* Create a new DImode pseudo reg and emit an instruction to initialize
it to VAL. */
-static rtx
+rtx
get_exec (int64_t val)
{
rtx reg = gen_reg_rtx (DImode);
@@ -854,6 +854,13 @@ get_exec (int64_t val)
return reg;
}
+rtx
+get_exec (machine_mode mode)
+{
+ int vf = (VECTOR_MODE_P (mode) ? GET_MODE_NUNITS (mode) : 1);
+ return get_exec (0xffffffffffffffffUL >> (64-vf));
+}
+
/* }}} */
/* {{{ Immediate constants. */
next prev parent reply other threads:[~2022-10-11 11:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-11 11:02 [committed 0/6] amdgcn: Add V32, V16, V8, V4, and V2 vectors Andrew Stubbs
2022-10-11 11:02 ` [committed 1/6] amdgcn: add multiple vector sizes Andrew Stubbs
2022-10-17 12:26 ` GCN: Restore build with GCC 4.8 (was: [committed 1/6] amdgcn: add multiple vector sizes) Thomas Schwinge
2022-10-11 11:02 ` [committed 2/6] amdgcn: Resolve insn conditions at compile time Andrew Stubbs
2022-10-11 11:02 ` Andrew Stubbs [this message]
2022-10-11 11:02 ` [committed 4/6] amdgcn: vec_init for multiple vector sizes Andrew Stubbs
2022-10-11 11:02 ` [committed 5/6] amdgcn: Add vector integer negate insn Andrew Stubbs
2022-10-11 11:02 ` [committed 6/6] amdgcn: vector testsuite tweaks Andrew Stubbs
2022-10-28 7:46 ` Thomas Schwinge
2022-10-28 8:38 ` Stubbs, Andrew
2022-10-28 9:00 ` Thomas Schwinge
2022-10-11 11:29 ` [committed 0/6] amdgcn: Add V32, V16, V8, V4, and V2 vectors Richard Biener
2022-10-11 11:53 ` Andrew Stubbs
2022-10-11 11:58 ` Richard Biener
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=5cfe08555034b29f301dcfb99a3691c81b2e2def.1665485382.git.ams@codesourcery.com \
--to=ams@codesourcery.com \
--cc=gcc-patches@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).