public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pan Li <panli@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-5479] RISC-V: Disallow RVV mode address for any load/store[PR112535]
Date: Wed, 15 Nov 2023 07:41:08 +0000 (GMT)	[thread overview]
Message-ID: <20231115074108.16F773858CD1@sourceware.org> (raw)

https://gcc.gnu.org/g:d85161a73b9bdd382e62ca1ba3f9f962971a9695

commit r14-5479-gd85161a73b9bdd382e62ca1ba3f9f962971a9695
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date:   Wed Nov 15 15:15:08 2023 +0800

    RISC-V: Disallow RVV mode address for any load/store[PR112535]
    
    This patch is quite obvious patch which disallow for load/store address register
    with RVV mode.
    
            PR target/112535
    
    gcc/ChangeLog:
    
            * config/riscv/riscv.cc (riscv_legitimate_address_p): Disallow RVV modes base address.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/riscv/rvv/autovec/pr112535.c: New test.

Diff:
---
 gcc/config/riscv/riscv.cc                             |  4 ++++
 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr112535.c | 17 +++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index ecee7eb4727..e919850fc6c 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -1427,6 +1427,10 @@ static bool
 riscv_legitimate_address_p (machine_mode mode, rtx x, bool strict_p,
 			    code_helper = ERROR_MARK)
 {
+  /* Disallow RVV modes base address.
+     E.g. (mem:SI (subreg:DI (reg:V1DI 155) 0).  */
+  if (SUBREG_P (x) && riscv_v_ext_mode_p (GET_MODE (SUBREG_REG (x))))
+    return false;
   struct riscv_address_info addr;
 
   return riscv_classify_address (&addr, x, mode, strict_p);
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr112535.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr112535.c
new file mode 100644
index 00000000000..95799aab8d2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr112535.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3" } */
+
+int *a, *f;
+char b, c;
+int ***d;
+static int ****e = &d;
+void g() {
+  c = 3;
+  for (; c; c--)
+    if (c < 8) {
+      f = 0;
+      ***e = a;
+    }
+  if (b)
+    ***d = 0;
+}

                 reply	other threads:[~2023-11-15  7:41 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=20231115074108.16F773858CD1@sourceware.org \
    --to=panli@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).