[V2] RISC-V: Add TARGET_MIN_VLEN > 4096 check

Message ID 20230717062828.47511-1-juzhe.zhong@rivai.ai
State Accepted
Headers
Series [V2] RISC-V: Add TARGET_MIN_VLEN > 4096 check |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

juzhe.zhong@rivai.ai July 17, 2023, 6:28 a.m. UTC
  gcc/ChangeLog:

        * config/riscv/riscv.cc (riscv_option_override): Add TARGET_MIN_VLEN < 4096 check.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/rvv/base/zvl-unimplemented.c: New test.

---
 gcc/config/riscv/riscv.cc                                 | 8 ++++++++
 .../gcc.target/riscv/rvv/base/zvl-unimplemented.c         | 4 ++++
 2 files changed, 12 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/base/zvl-unimplemented.c
  

Patch

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 6ed735d6983..432c1ce771e 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -6672,6 +6672,14 @@  riscv_option_override (void)
       riscv_stack_protector_guard_offset = offs;
     }
 
+  /* FIXME: We don't allow TARGET_MIN_VLEN > 4096 since the datatypes of
+     both GET_MODE_SIZE and GET_MODE_BITSIZE are poly_uint16.
+
+     We can only allow TARGET_MIN_VLEN * 8 (LMUL) < 65535.  */
+  if (riscv_vector_chunks.is_constant () && TARGET_MIN_VLEN > 4096)
+    sorry (
+      "Current RISC-V GCC can not support VLEN > 4096bit for 'V' Extension");
+
   /* Convert -march to a chunks count.  */
   riscv_vector_chunks = riscv_convert_vector_bits ();
 }
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvl-unimplemented.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvl-unimplemented.c
new file mode 100644
index 00000000000..d0e7c8ace3b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvl-unimplemented.c
@@ -0,0 +1,4 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=rv64gcv_zvl8192b_zvl256b_zvl512b_zvl1024b -mabi=lp64d --param riscv-autovec-preference=fixed-vlmax" } */
+
+void foo () {} // { dg-excess-errors "sorry, unimplemented: Current RISC-V GCC can not support VLEN > 4096bit for 'V' Extension" }