public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jeff Law <law@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] RISC-V: Fix VSETVL PASS AVL/VL fetch bug[111295]
Date: Mon, 11 Sep 2023 13:37:59 +0000 (GMT)	[thread overview]
Message-ID: <20230911133759.A4BED3857736@sourceware.org> (raw)

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

commit caa739709fb48f140fe6cab1c178ef956dbc7cc3
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date:   Wed Sep 6 20:47:24 2023 +0800

    RISC-V: Fix VSETVL PASS AVL/VL fetch bug[111295]
    
    Fix bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111295
    
    gcc/ChangeLog:
    
            PR target/111295
            * config/riscv/riscv-vsetvl.cc (insert_vsetvl): Bug fix.
    
    gcc/testsuite/ChangeLog:
    
            PR target/111295
            * gcc.target/riscv/rvv/autovec/pr111295.c: New test.
    
    (cherry picked from commit 1b4c70d4271a00514ae20970d483c3b78d9d66ef)

Diff:
---
 gcc/config/riscv/riscv-vsetvl.cc                   |  3 +-
 .../gcc.target/riscv/rvv/autovec/pr111295.c        | 36 ++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index e7e5c14617ee..dd9aeb32b563 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -721,8 +721,7 @@ insert_vsetvl (enum emit_type emit_type, rtx_insn *rinsn,
       gcc_assert (has_vtype_op (rinsn) || vsetvl_insn_p (rinsn));
       /* For user vsetvli a5, zero, we should use get_vl to get the VL
 	 operand "a5".  */
-      rtx vl_op
-	= vsetvl_insn_p (rinsn) ? get_vl (rinsn) : info.get_avl_reg_rtx ();
+      rtx vl_op = info.get_avl_or_vl_reg ();
       gcc_assert (!vlmax_avl_p (vl_op));
       emit_vsetvl_insn (VSETVL_NORMAL, emit_type, info, vl_op, rinsn);
       return VSETVL_NORMAL;
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr111295.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr111295.c
new file mode 100644
index 000000000000..fa20a21338a3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr111295.c
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -Ofast -ftree-vectorize --param=riscv-autovec-preference=scalable -Wno-implicit-function-declaration" } */
+
+#include <stdbool.h>
+int a, b, c, e, f, g, h, i, j, k;
+long l;
+int q ()
+{
+  int r ();
+  char *o, *d;
+  _Bool p = f;
+  while (g)
+    {
+      int m, n;
+      for (; m <= n; m++)
+	*d++ = m;
+      k = 1;
+      if (e)
+	break;
+      switch (*o)
+	{
+	case 'N':
+	  o++;
+	  if (c)
+	    if (h)
+	      while (i)
+		{
+		  s (-l, ~0);
+		  t (j);
+		  d = d + (a & 10000000 ? u (r, 2) : b);
+		}
+	}
+      if (*o)
+	p ? s () : 0;
+    }
+}

                 reply	other threads:[~2023-09-11 13:37 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=20230911133759.A4BED3857736@sourceware.org \
    --to=law@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).