diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index 3247d526c0a..6091d8f281b 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -102,6 +102,23 @@ static const riscv_implied_info_t riscv_implied_info[] =
   {"zvl32768b", "zvl16384b"},
   {"zvl65536b", "zvl32768b"},
 
+  {"zvkn", "zvkned"},
+  {"zvkn", "zvknhb"},
+  {"zvkn", "zvbb"},
+  {"zvkn", "zvkt"},
+  {"zvknc", "zvkn"},
+  {"zvknc", "zvbc"},
+  {"zvkng", "zvkn"},
+  {"zvkng", "zvkg"},
+  {"zvks", "zvksed"},
+  {"zvks", "zvksh"},
+  {"zvks", "zvbb"},
+  {"zvks", "zvkt"},
+  {"zvksc", "zvks"},
+  {"zvksc", "zvbc"},
+  {"zvksg", "zvks"},
+  {"zvksg", "zvkg"},
+
   {"zfh", "zfhmin"},
   {"zfhmin", "f"},
   {"zvfhmin", "zve32f"},
@@ -204,6 +221,22 @@ static const struct riscv_ext_version riscv_ext_version_table[] =
   {"zve64f", ISA_SPEC_CLASS_NONE, 1, 0},
   {"zve64d", ISA_SPEC_CLASS_NONE, 1, 0},
 
+  {"zvbb", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvbc", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvkg", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvkned", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvknha", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvknhb", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvksed", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvksh", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvkn", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvknc", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvkng", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvks", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvksc", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvksg", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvkt", ISA_SPEC_CLASS_NONE, 1, 0},
+
   {"zvl32b", ISA_SPEC_CLASS_NONE, 1, 0},
   {"zvl64b", ISA_SPEC_CLASS_NONE, 1, 0},
   {"zvl128b", ISA_SPEC_CLASS_NONE, 1, 0},
@@ -250,6 +283,12 @@ static const struct riscv_ext_version riscv_combine_info[] =
   {"zk",  ISA_SPEC_CLASS_NONE, 1, 0},
   {"zkn",  ISA_SPEC_CLASS_NONE, 1, 0},
   {"zks",  ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvkn", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvknc", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvkng", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvks", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvksc", ISA_SPEC_CLASS_NONE, 1, 0},
+  {"zvksg", ISA_SPEC_CLASS_NONE, 1, 0},
   /* Terminate the list.  */
   {NULL, ISA_SPEC_CLASS_NONE, 0, 0}
 };
@@ -1251,6 +1290,22 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
   {"zvfhmin",  &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_FP_16},
   {"zvfh",     &gcc_options::x_riscv_vector_elen_flags, MASK_VECTOR_ELEN_FP_16},
 
+  {"zvbb",     &gcc_options::x_riscv_zvb_subext, MASK_ZVBB},
+  {"zvbc",     &gcc_options::x_riscv_zvb_subext, MASK_ZVBC},
+  {"zvkg",     &gcc_options::x_riscv_zvk_subext, MASK_ZVKG},
+  {"zvkned",   &gcc_options::x_riscv_zvk_subext, MASK_ZVKNED},
+  {"zvknha",   &gcc_options::x_riscv_zvk_subext, MASK_ZVKNHA},
+  {"zvknhb",   &gcc_options::x_riscv_zvk_subext, MASK_ZVKNHB},
+  {"zvksed",   &gcc_options::x_riscv_zvk_subext, MASK_ZVKSED},
+  {"zvksh",    &gcc_options::x_riscv_zvk_subext, MASK_ZVKSH},
+  {"zvkn",     &gcc_options::x_riscv_zvk_subext, MASK_ZVKN},
+  {"zvknc",    &gcc_options::x_riscv_zvk_subext, MASK_ZVKNC},
+  {"zvkng",    &gcc_options::x_riscv_zvk_subext, MASK_ZVKNG},
+  {"zvks",     &gcc_options::x_riscv_zvk_subext, MASK_ZVKS},
+  {"zvksc",    &gcc_options::x_riscv_zvk_subext, MASK_ZVKSC},
+  {"zvksg",    &gcc_options::x_riscv_zvk_subext, MASK_ZVKSG},
+  {"zvkt",     &gcc_options::x_riscv_zvk_subext, MASK_ZVKT},
+
   {"zvl32b",    &gcc_options::x_riscv_zvl_flags, MASK_ZVL32B},
   {"zvl64b",    &gcc_options::x_riscv_zvl_flags, MASK_ZVL64B},
   {"zvl128b",   &gcc_options::x_riscv_zvl_flags, MASK_ZVL128B},
diff --git a/gcc/config/riscv/arch-canonicalize b/gcc/config/riscv/arch-canonicalize
index 490226beb0b..bbb9261bd87 100755
--- a/gcc/config/riscv/arch-canonicalize
+++ b/gcc/config/riscv/arch-canonicalize
@@ -68,6 +68,13 @@ IMPLIED_EXT = {
   "zvl16384b" : ["zvl8192b"],
   "zvl32768b" : ["zvl16384b"],
   "zvl65536b" : ["zvl32768b"],
+
+  "zvkn" : ["zvkned", "zvknhb", "zvbb", "zvkt"],
+  "zvknc" : ["zvkn", "zvbc"],
+  "zvkng" : ["zvkn", "zvkg"],
+  "zvks" : ["zvksed", "zvksh", "zvbb", "zvkt"],
+  "zvksc" : ["zvks", "zvbc"],
+  "zvksg" : ["zvks", "zvkg"],
 }
 
 def arch_canonicalize(arch, isa_spec):
diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h
index 208a557b8ff..cfcf608ea62 100644
--- a/gcc/config/riscv/riscv-opts.h
+++ b/gcc/config/riscv/riscv-opts.h
@@ -168,6 +168,40 @@ enum riscv_entity
 #define TARGET_VECTOR_ELEN_FP_16 \
   ((riscv_vector_elen_flags & MASK_VECTOR_ELEN_FP_16) != 0)
 
+#define MASK_ZVBB      (1 << 0)
+#define MASK_ZVBC      (1 << 1)
+
+#define TARGET_ZVBB    ((riscv_zvb_subext & MASK_ZVBB) != 0)
+#define TARGET_ZVBC    ((riscv_zvb_subext & MASK_ZVBC) != 0)
+
+#define MASK_ZVKG      (1 << 0)
+#define MASK_ZVKNED    (1 << 1)
+#define MASK_ZVKNHA    (1 << 2)
+#define MASK_ZVKNHB    (1 << 3)
+#define MASK_ZVKSED    (1 << 4)
+#define MASK_ZVKSH     (1 << 5)
+#define MASK_ZVKN      (1 << 6)
+#define MASK_ZVKNC     (1 << 7)
+#define MASK_ZVKNG     (1 << 8)
+#define MASK_ZVKS      (1 << 9)
+#define MASK_ZVKSC     (1 << 10)
+#define MASK_ZVKSG     (1 << 11)
+#define MASK_ZVKT      (1 << 12)
+
+#define TARGET_ZVKG    ((riscv_zvk_subext & MASK_ZVKG) != 0)
+#define TARGET_ZVKNED  ((riscv_zvk_subext & MASK_ZVKNED) != 0)
+#define TARGET_ZVKNHA  ((riscv_zvk_subext & MASK_ZVKNHA) != 0)
+#define TARGET_ZVKNHB  ((riscv_zvk_subext & MASK_ZVKNHB) != 0)
+#define TARGET_ZVKSED  ((riscv_zvk_subext & MASK_ZVKSED) != 0)
+#define TARGET_ZVKSH   ((riscv_zvk_subext & MASK_ZVKSH) != 0)
+#define TARGET_ZVKN    ((riscv_zvk_subext & MASK_ZVKN) != 0)
+#define TARGET_ZVKNC   ((riscv_zvk_subext & MASK_ZVKNC) != 0)
+#define TARGET_ZVKNG   ((riscv_zvk_subext & MASK_ZVKNG) != 0)
+#define TARGET_ZVKS    ((riscv_zvk_subext & MASK_ZVKS) != 0)
+#define TARGET_ZVKSC   ((riscv_zvk_subext & MASK_ZVKSC) != 0)
+#define TARGET_ZVKSG   ((riscv_zvk_subext & MASK_ZVKSG) != 0)
+#define TARGET_ZVKT    ((riscv_zvk_subext & MASK_ZVKT) != 0)
+
 #define MASK_ZVL32B    (1 <<  0)
 #define MASK_ZVL64B    (1 <<  1)
 #define MASK_ZVL128B   (1 <<  2)
diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
index 63d4710cb15..dd062f1c8bd 100644
--- a/gcc/config/riscv/riscv.opt
+++ b/gcc/config/riscv/riscv.opt
@@ -223,6 +223,12 @@ int riscv_vector_elen_flags
 TargetVariable
 int riscv_zvl_flags
 
+TargetVariable
+int riscv_zvb_subext
+
+TargetVariable
+int riscv_zvk_subext
+
 TargetVariable
 int riscv_zicmo_subext
 
diff --git a/gcc/testsuite/gcc.target/riscv/zvbb.c b/gcc/testsuite/gcc.target/riscv/zvbb.c
new file mode 100644
index 00000000000..b592f56f6cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvbb.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvbb" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvbb" { target { rv32 } } } */
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvbc.c b/gcc/testsuite/gcc.target/riscv/zvbc.c
new file mode 100644
index 00000000000..37239fa91b3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvbc.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvbc" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvbc" { target { rv32 } } } */
+
+#ifndef __riscv_zvbc
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvkg.c b/gcc/testsuite/gcc.target/riscv/zvkg.c
new file mode 100644
index 00000000000..1e2a05aa1d8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvkg.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkg" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkg" { target { rv32 } } } */
+
+#ifndef __riscv_zvkg
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvkn-1.c b/gcc/testsuite/gcc.target/riscv/zvkn-1.c
new file mode 100644
index 00000000000..83935b06832
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvkn-1.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkned_zvknhb_zvbb_zvkt" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkned_zvknhb_zvbb_zvkt" { target { rv32 } } } */
+
+#ifndef __riscv_zvkn
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkned
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvknhb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvkn.c b/gcc/testsuite/gcc.target/riscv/zvkn.c
new file mode 100644
index 00000000000..af3db40c8f6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvkn.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkn" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkn" { target { rv32 } } } */
+
+#ifndef __riscv_zvkn
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkned
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvknhb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvknc-1.c b/gcc/testsuite/gcc.target/riscv/zvknc-1.c
new file mode 100644
index 00000000000..eca27670895
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvknc-1.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkned_zvknhb_zvbb_zvkt_zvbc" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkned_zvknhb_zvbb_zvkt_zvbc" { target { rv32 } } } */
+
+#ifndef __riscv_zvknc
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkn
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkned
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvknhb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbc
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvknc-2.c b/gcc/testsuite/gcc.target/riscv/zvknc-2.c
new file mode 100644
index 00000000000..e77343a27f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvknc-2.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkn_zvbc" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkn_zvbc" { target { rv32 } } } */
+
+#ifndef __riscv_zvknc
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkn
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkned
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvknhb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbc
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvknc.c b/gcc/testsuite/gcc.target/riscv/zvknc.c
new file mode 100644
index 00000000000..10bd471da45
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvknc.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvknc" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvknc" { target { rv32 } } } */
+
+#ifndef __riscv_zvknc
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkn
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkned
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvknhb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbc
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvkned.c b/gcc/testsuite/gcc.target/riscv/zvkned.c
new file mode 100644
index 00000000000..fcdc4b45761
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvkned.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkned" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkned" { target { rv32 } } } */
+
+#ifndef __riscv_zvkned
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvkng-1.c b/gcc/testsuite/gcc.target/riscv/zvkng-1.c
new file mode 100644
index 00000000000..f4f3cc8e417
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvkng-1.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkned_zvknhb_zvbb_zvkt_zvkg" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkned_zvknhb_zvbb_zvkt_zvkg" { target { rv32 } } } */
+
+#ifndef __riscv_zvkng
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkn
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkned
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvknhb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkg
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvkng-2.c b/gcc/testsuite/gcc.target/riscv/zvkng-2.c
new file mode 100644
index 00000000000..2631c1a1c25
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvkng-2.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkn_zvkg" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkn_zvkg" { target { rv32 } } } */
+
+#ifndef __riscv_zvkng
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkn
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkned
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvknhb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkg
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvkng.c b/gcc/testsuite/gcc.target/riscv/zvkng.c
new file mode 100644
index 00000000000..e6c950e9323
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvkng.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkng" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkng" { target { rv32 } } } */
+
+#ifndef __riscv_zvkng
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkn
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkned
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvknhb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkg
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvknha.c b/gcc/testsuite/gcc.target/riscv/zvknha.c
new file mode 100644
index 00000000000..1275f9d11c1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvknha.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvknha" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvknha" { target { rv32 } } } */
+
+#ifndef __riscv_zvknha
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvknhb.c b/gcc/testsuite/gcc.target/riscv/zvknhb.c
new file mode 100644
index 00000000000..669ff019149
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvknhb.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvknhb" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvknhb" { target { rv32 } } } */
+
+#ifndef __riscv_zvknhb
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvks-1.c b/gcc/testsuite/gcc.target/riscv/zvks-1.c
new file mode 100644
index 00000000000..28ad26af1c1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvks-1.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvksed_zvksh_zvbb_zvkt" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvksed_zvksh_zvbb_zvkt" { target { rv32 } } } */
+
+#ifndef __riscv_zvks
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksed
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksh
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvks.c b/gcc/testsuite/gcc.target/riscv/zvks.c
new file mode 100644
index 00000000000..a48c9186d5e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvks.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvks" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvks" { target { rv32 } } } */
+
+#ifndef __riscv_zvks
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksed
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksh
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvksc-1.c b/gcc/testsuite/gcc.target/riscv/zvksc-1.c
new file mode 100644
index 00000000000..72d9676e68c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvksc-1.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvksed_zvksh_zvbb_zvkt_zvbc" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvksed_zvksh_zvbb_zvkt_zvbc" { target { rv32 } } } */
+
+#ifndef __riscv_zvksc
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvks
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksed
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksh
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbc
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvksc-2.c b/gcc/testsuite/gcc.target/riscv/zvksc-2.c
new file mode 100644
index 00000000000..c78b4fe9077
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvksc-2.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvks_zvbc" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvks_zvbc" { target { rv32 } } } */
+
+#ifndef __riscv_zvksc
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvks
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksed
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksh
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbc
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvksc.c b/gcc/testsuite/gcc.target/riscv/zvksc.c
new file mode 100644
index 00000000000..fb61561a2af
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvksc.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvksc" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvksc" { target { rv32 } } } */
+
+#ifndef __riscv_zvksc
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvks
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksed
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksh
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbc
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvksed.c b/gcc/testsuite/gcc.target/riscv/zvksed.c
new file mode 100644
index 00000000000..439b546bb8a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvksed.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvksed" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvksed" { target { rv32 } } } */
+
+#ifndef __riscv_zvksed
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvksg-1.c b/gcc/testsuite/gcc.target/riscv/zvksg-1.c
new file mode 100644
index 00000000000..8cbd0331168
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvksg-1.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvksed_zvksh_zvbb_zvkt_zvkg" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvksed_zvksh_zvbb_zvkt_zvkg" { target { rv32 } } } */
+
+#ifndef __riscv_zvksg
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvks
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksed
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksh
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkg
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvksg-2.c b/gcc/testsuite/gcc.target/riscv/zvksg-2.c
new file mode 100644
index 00000000000..d56c47e897c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvksg-2.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvks_zvkg" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvks_zvkg" { target { rv32 } } } */
+
+#ifndef __riscv_zvksg
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvks
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksed
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksh
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkg
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvksg.c b/gcc/testsuite/gcc.target/riscv/zvksg.c
new file mode 100644
index 00000000000..44dffb41395
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvksg.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvksg" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvksg" { target { rv32 } } } */
+
+#ifndef __riscv_zvksg
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvks
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksed
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvksh
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvbb
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+#ifndef __riscv_zvkg
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvksh.c b/gcc/testsuite/gcc.target/riscv/zvksh.c
new file mode 100644
index 00000000000..5359ca50281
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvksh.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvksh" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvksh" { target { rv32 } } } */
+
+#ifndef __riscv_zvksh
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/zvkt.c b/gcc/testsuite/gcc.target/riscv/zvkt.c
new file mode 100644
index 00000000000..49822b75738
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zvkt.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zvkt" { target { rv64 } } } */
+/* { dg-options "-march=rv32gc_zvkt" { target { rv32 } } } */
+
+#ifndef __riscv_zvkt
+#error Feature macro not defined
+#endif
+
+int
+foo (int a)
+{
+  return a;
+}
