public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Stubbs <ams@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-9008] amdgcn: Disallow unsupported permute on RDNA devices
Date: Thu, 15 Feb 2024 13:01:46 +0000 (GMT)	[thread overview]
Message-ID: <20240215130146.20F25385022E@sourceware.org> (raw)

https://gcc.gnu.org/g:84da9bca72558119974db307208eb2fa2b8ad5dd

commit r14-9008-g84da9bca72558119974db307208eb2fa2b8ad5dd
Author: Andrew Stubbs <ams@baylibre.com>
Date:   Wed Feb 14 15:12:43 2024 +0000

    amdgcn: Disallow unsupported permute on RDNA devices
    
    The RDNA architecture has limited support for permute operations.  This should
    allow use of the permutations that do work, and fall back to linear code for
    other cases.
    
    gcc/ChangeLog:
    
            * config/gcn/gcn-valu.md
            (vec_extract<V_MOV:mode><V_MOV_ALT:mode>): Add conditions for RDNA.
            * config/gcn/gcn.cc (gcn_vectorize_vec_perm_const): Check permutation
            details are supported on RDNA devices.

Diff:
---
 gcc/config/gcn/gcn-valu.md |  3 ++-
 gcc/config/gcn/gcn.cc      | 19 ++++++++++++-------
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/gcc/config/gcn/gcn-valu.md b/gcc/config/gcn/gcn-valu.md
index 23b441f8e8b6..59e27d0aed79 100644
--- a/gcc/config/gcn/gcn-valu.md
+++ b/gcc/config/gcn/gcn-valu.md
@@ -982,7 +982,8 @@
    (match_operand:V_MOV 1 "register_operand")
    (match_operand 2 "immediate_operand")]
   "MODE_VF (<V_MOV_ALT:MODE>mode) < MODE_VF (<V_MOV:MODE>mode)
-   && <V_MOV_ALT:SCALAR_MODE>mode == <V_MOV:SCALAR_MODE>mode"
+   && <V_MOV_ALT:SCALAR_MODE>mode == <V_MOV:SCALAR_MODE>mode
+   && (!TARGET_RDNA2_PLUS || MODE_VF (<V_MOV:MODE>mode) <= 32)"
   {
     int numlanes = GET_MODE_NUNITS (<V_MOV_ALT:MODE>mode);
     int firstlane = INTVAL (operands[2]) * numlanes;
diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index 20be45565462..4559d6932d4a 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -5110,19 +5110,24 @@ gcn_vectorize_vec_perm_const (machine_mode vmode, machine_mode op_mode,
   gcc_assert (nelt <= 64);
   gcc_assert (sel.length () == nelt);
 
-  if (!dst)
-    {
-      /* All vector permutations are possible on this architecture,
-         with varying degrees of efficiency depending on the permutation. */
-      return true;
-    }
-
   unsigned int perm[64];
   for (unsigned int i = 0; i < nelt; ++i)
     perm[i] = sel[i] & (2 * nelt - 1);
   for (unsigned int i = nelt; i < 64; ++i)
     perm[i] = 0;
 
+  /* RDNA devices can only do permutations within each group of 32-lanes.
+     Reject permutations that cross the boundary.  */
+  if (TARGET_RDNA2_PLUS)
+    for (unsigned int i = 0; i < nelt; i++)
+      if (i < 31 ? perm[i] > 31 : perm[i] < 32)
+	return false;
+
+  /* All vector permutations are possible on other architectures,
+     with varying degrees of efficiency depending on the permutation. */
+  if (!dst)
+    return true;
+
   src0 = force_reg (vmode, src0);
   src1 = force_reg (vmode, src1);

                 reply	other threads:[~2024-02-15 13:01 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=20240215130146.20F25385022E@sourceware.org \
    --to=ams@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).