public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: juzhe.zhong@rivai.ai
To: gcc-patches@gcc.gnu.org
Cc: kito.cheng@gmail.com, palmer@dabbelt.com, jeffreyalaw@gmail.com,
	Juzhe-Zhong <juzhe.zhong@rivai.ai>
Subject: [PATCH] RISC-V: Allow LMUL = 2 auto-vectorization for zve32*
Date: Mon, 10 Apr 2023 11:39:38 +0800	[thread overview]
Message-ID: <20230410033938.130469-1-juzhe.zhong@rivai.ai> (raw)

From: Juzhe-Zhong <juzhe.zhong@rivai.ai>

Since VNx1SI mode is nunits = [1,1] which will create ICE in
Loop vectorizer of GCC. We disabled it. The current condition
allows VNx4SI which LMUL = 4. We should be able to enable VNx2SI too.
This patch is to enable auto-vectorization for VNx2SImode.

gcc/ChangeLog:

        * config/riscv/riscv-v.cc (preferred_simd_mode): Enable LMUL = 2 auto-vectorization for TARGET_MIN_VLEN < 128.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/rvv/autovec/zve32f-3.c: Adapt testcase.
        * gcc.target/riscv/rvv/autovec/zve32x-3.c: Ditto.

---
 gcc/config/riscv/riscv-v.cc                           | 2 +-
 gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32f-3.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32x-3.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc
index 84d33fcdd14..801a4e26b67 100644
--- a/gcc/config/riscv/riscv-v.cc
+++ b/gcc/config/riscv/riscv-v.cc
@@ -761,7 +761,7 @@ preferred_simd_mode (scalar_mode mode)
 	 auto-vectorization since Loop Vectorizer may use VNx1SImode or
 	 VNx1DImode to vectorize which will create ICE in the
 	 'can_duplicate_and_interleave_p' of tree-vect-slp.cc.  */
-      if (TARGET_MIN_VLEN * riscv_autovec_lmul < 128)
+      if (TARGET_MIN_VLEN < 128 && riscv_autovec_lmul < RVV_M2)
 	return word_mode;
       /* We use LMUL = 1 as base bytesize which is BYTES_PER_RISCV_VECTOR and
 	 riscv_autovec_lmul as multiply factor to calculate the the NUNITS to
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32f-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32f-3.c
index 0c1aee23d25..8e68b9932b4 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32f-3.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32f-3.c
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv32gc_zve32f -mabi=ilp32d --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m4 -O3 -ftree-vectorize -fdump-tree-vect-details -save-temps" } */
+/* { dg-options "-march=rv32gc_zve32f -mabi=ilp32d --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m2 -O3 -ftree-vectorize -fdump-tree-vect-details -save-temps" } */
 
 #include "template-1.h"
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 3 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 4 "vect" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32x-3.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32x-3.c
index 94593f43a62..c26c2c95afb 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32x-3.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/zve32x-3.c
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv32gc_zve32x -mabi=ilp32d --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m4 -O3 -ftree-vectorize -fdump-tree-vect-details -save-temps" } */
+/* { dg-options "-march=rv32gc_zve32x -mabi=ilp32d --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m2 -O3 -ftree-vectorize -fdump-tree-vect-details -save-temps" } */
 
 #include "template-1.h"
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 2 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 3 "vect" } } */
-- 
2.36.1


                 reply	other threads:[~2023-04-10  3:39 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=20230410033938.130469-1-juzhe.zhong@rivai.ai \
    --to=juzhe.zhong@rivai.ai \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=kito.cheng@gmail.com \
    --cc=palmer@dabbelt.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).