The current GCC can produce an ICE when compiling FP16 intrinsics that
require Zvfh in machine description patterns with only zvfhmin.  This
patch fixes this by requiring Zvfh before expansion.  This issue was
found during LLM review of the XT patch by Sashiko deployed locally.

Assisted-by: Sashiko (codex)

gcc/ChangeLog:

        * config/riscv/riscv-vector-builtins-types.def (DEF_RVV_F_ARITH_OPS):
        Define.  Add floating-point arithmetic types.
        Require Zvfh for FP16 arithmetic and integer conversions.
        * config/riscv/riscv-vector-builtins.cc (f_arith_ops): New.
        (f_vvvv_ops): Use f_arith_ops.
        (f_vvfv_ops): Ditto.
        (f_vvfm_ops): Ditto.
        (f_mvv_ops): Ditto.
        (f_mvf_ops): Ditto.
        (f_vvv_ops): Ditto.
        (f_vvf_ops): Ditto.
        (f_f_s_ops): Ditto.
        (f_vs_ops): Ditto.
        (f_v_ops): Ditto.
        (f_to_ni_f_w_ops): Ditto.
        (f_to_nu_f_w_ops): Ditto.
        (i_to_f_x_v_ops): Ditto.
        (u_to_f_xu_v_ops): Ditto.
        (i_to_wf_x_v_ops): Ditto.
        (u_to_wf_xu_v_ops): Ditto.
        (f_f_ops): Ditto.
        (f_s_f_ops): Ditto.
        (validate_instance_type_required_extensions): Check RVV_REQUIRE_ZVFH.
        * config/riscv/riscv-vector-builtins.h (RVV_REQUIRE_ZVFH): Define.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/rvv/base/bug-9.c: Update expected diagnostic.
        * gcc.target/riscv/rvv/base/pr114988-1.c: Ditto.
        * gcc.target/riscv/rvv/base/pr114988-2.c: Ditto.
        * gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-19.c: 
Ditto.
        * gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-22.c: 
Ditto.
        * gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-25.c: 
Ditto.
        * gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-28.c: 
Ditto.
        * gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-29.c: 
Ditto.
        * gcc.target/riscv/rvv/base/zvfhmin-arith-error.c: New test.
---
 .../riscv/riscv-vector-builtins-types.def     | 97 ++++++++++++-------
 gcc/config/riscv/riscv-vector-builtins.cc     | 52 +++++-----
 gcc/config/riscv/riscv-vector-builtins.h      |  1 +
 .../gcc.target/riscv/rvv/base/bug-9.c         |  2 +-
 .../gcc.target/riscv/rvv/base/pr114988-1.c    |  2 +-
 .../gcc.target/riscv/rvv/base/pr114988-2.c    |  2 +-
 .../target_attribute_v_with_intrinsic-19.c    |  2 +-
 .../target_attribute_v_with_intrinsic-22.c    |  2 +-
 .../target_attribute_v_with_intrinsic-25.c    |  2 +-
 .../target_attribute_v_with_intrinsic-28.c    |  2 +-
 .../target_attribute_v_with_intrinsic-29.c    |  2 +-
 .../riscv/rvv/base/zvfhmin-arith-error.c      | 23 +++++
 12 files changed, 126 insertions(+), 63 deletions(-)
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/base/zvfhmin-arith-error.c

diff --git a/gcc/config/riscv/riscv-vector-builtins-types.def 
b/gcc/config/riscv/riscv-vector-builtins-types.def
index 9ea89b870bb..98c638bfa50 100644
--- a/gcc/config/riscv/riscv-vector-builtins-types.def
+++ b/gcc/config/riscv/riscv-vector-builtins-types.def
@@ -36,6 +36,12 @@ along with GCC; see the file COPYING3.  If not see
 #define DEF_RVV_F_OPS(TYPE, REQUIRE)
 #endif
 
+/* Use "DEF_RVV_F_ARITH_OPS" macro include all floating-point arithmetic types
+   which will be iterated and registered as intrinsic functions.  */
+#ifndef DEF_RVV_F_ARITH_OPS
+#define DEF_RVV_F_ARITH_OPS(TYPE, REQUIRE)
+#endif
+
 /* Use "DEF_RVV_B_OPS" macro include all bool value which will be
    iterated and registered as intrinsic functions.  */
 #ifndef DEF_RVV_B_OPS
@@ -487,6 +493,30 @@ DEF_RVV_F_OPS (vfloat64m2_t, RVV_REQUIRE_ELEN_FP_64)
 DEF_RVV_F_OPS (vfloat64m4_t, RVV_REQUIRE_ELEN_FP_64)
 DEF_RVV_F_OPS (vfloat64m8_t, RVV_REQUIRE_ELEN_FP_64)
 
+DEF_RVV_F_ARITH_OPS (vbfloat16mf4_t, RVV_REQUIRE_ELEN_BF_16 | 
RVV_REQUIRE_ELEN_64)
+DEF_RVV_F_ARITH_OPS (vbfloat16mf2_t, RVV_REQUIRE_ELEN_BF_16)
+DEF_RVV_F_ARITH_OPS (vbfloat16m1_t,  RVV_REQUIRE_ELEN_BF_16)
+DEF_RVV_F_ARITH_OPS (vbfloat16m2_t,  RVV_REQUIRE_ELEN_BF_16)
+DEF_RVV_F_ARITH_OPS (vbfloat16m4_t,  RVV_REQUIRE_ELEN_BF_16)
+DEF_RVV_F_ARITH_OPS (vbfloat16m8_t,  RVV_REQUIRE_ELEN_BF_16)
+
+DEF_RVV_F_ARITH_OPS (vfloat16mf4_t, RVV_REQUIRE_ELEN_FP_16 | 
RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_ZVFH)
+DEF_RVV_F_ARITH_OPS (vfloat16mf2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_F_ARITH_OPS (vfloat16m1_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_F_ARITH_OPS (vfloat16m2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_F_ARITH_OPS (vfloat16m4_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_F_ARITH_OPS (vfloat16m8_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+
+DEF_RVV_F_ARITH_OPS (vfloat32mf2_t, RVV_REQUIRE_ELEN_FP_32 | 
RVV_REQUIRE_ELEN_64)
+DEF_RVV_F_ARITH_OPS (vfloat32m1_t, RVV_REQUIRE_ELEN_FP_32)
+DEF_RVV_F_ARITH_OPS (vfloat32m2_t, RVV_REQUIRE_ELEN_FP_32)
+DEF_RVV_F_ARITH_OPS (vfloat32m4_t, RVV_REQUIRE_ELEN_FP_32)
+DEF_RVV_F_ARITH_OPS (vfloat32m8_t, RVV_REQUIRE_ELEN_FP_32)
+DEF_RVV_F_ARITH_OPS (vfloat64m1_t, RVV_REQUIRE_ELEN_FP_64)
+DEF_RVV_F_ARITH_OPS (vfloat64m2_t, RVV_REQUIRE_ELEN_FP_64)
+DEF_RVV_F_ARITH_OPS (vfloat64m4_t, RVV_REQUIRE_ELEN_FP_64)
+DEF_RVV_F_ARITH_OPS (vfloat64m8_t, RVV_REQUIRE_ELEN_FP_64)
+
 DEF_RVV_B_OPS (vbool64_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_B_OPS (vbool32_t, 0)
 DEF_RVV_B_OPS (vbool16_t, 0)
@@ -603,23 +633,23 @@ DEF_RVV_FULL_V_U_OPS (vuint64m2_t, RVV_REQUIRE_FULL_V)
 DEF_RVV_FULL_V_U_OPS (vuint64m4_t, RVV_REQUIRE_FULL_V)
 DEF_RVV_FULL_V_U_OPS (vuint64m8_t, RVV_REQUIRE_FULL_V)
 
-DEF_RVV_WEXTF_OPS (vfloat32mf2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ELEN_64)
-DEF_RVV_WEXTF_OPS (vfloat32m1_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WEXTF_OPS (vfloat32m2_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WEXTF_OPS (vfloat32m4_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WEXTF_OPS (vfloat32m8_t, RVV_REQUIRE_ELEN_FP_16)
+DEF_RVV_WEXTF_OPS (vfloat32mf2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ELEN_64 
| RVV_REQUIRE_ZVFH)
+DEF_RVV_WEXTF_OPS (vfloat32m1_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WEXTF_OPS (vfloat32m2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WEXTF_OPS (vfloat32m4_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WEXTF_OPS (vfloat32m8_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
 
 DEF_RVV_WEXTF_OPS (vfloat64m1_t, RVV_REQUIRE_ELEN_FP_64)
 DEF_RVV_WEXTF_OPS (vfloat64m2_t, RVV_REQUIRE_ELEN_FP_64)
 DEF_RVV_WEXTF_OPS (vfloat64m4_t, RVV_REQUIRE_ELEN_FP_64)
 DEF_RVV_WEXTF_OPS (vfloat64m8_t, RVV_REQUIRE_ELEN_FP_64)
 
-DEF_RVV_CONVERT_I_OPS (vint16mf4_t, RVV_REQUIRE_ELEN_FP_16 | 
RVV_REQUIRE_ELEN_64)
-DEF_RVV_CONVERT_I_OPS (vint16mf2_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_CONVERT_I_OPS (vint16m1_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_CONVERT_I_OPS (vint16m2_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_CONVERT_I_OPS (vint16m4_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_CONVERT_I_OPS (vint16m8_t, RVV_REQUIRE_ELEN_FP_16)
+DEF_RVV_CONVERT_I_OPS (vint16mf4_t, RVV_REQUIRE_ELEN_FP_16 | 
RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_I_OPS (vint16mf2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_I_OPS (vint16m1_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_I_OPS (vint16m2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_I_OPS (vint16m4_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_I_OPS (vint16m8_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
 
 DEF_RVV_CONVERT_I_OPS (vint32mf2_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_CONVERT_I_OPS (vint32m1_t, 0)
@@ -631,12 +661,12 @@ DEF_RVV_CONVERT_I_OPS (vint64m2_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_CONVERT_I_OPS (vint64m4_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_CONVERT_I_OPS (vint64m8_t, RVV_REQUIRE_ELEN_64)
 
-DEF_RVV_CONVERT_U_OPS (vuint16mf4_t, RVV_REQUIRE_ELEN_FP_16 | 
RVV_REQUIRE_ELEN_64)
-DEF_RVV_CONVERT_U_OPS (vuint16mf2_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_CONVERT_U_OPS (vuint16m1_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_CONVERT_U_OPS (vuint16m2_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_CONVERT_U_OPS (vuint16m4_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_CONVERT_U_OPS (vuint16m8_t, RVV_REQUIRE_ELEN_FP_16)
+DEF_RVV_CONVERT_U_OPS (vuint16mf4_t, RVV_REQUIRE_ELEN_FP_16 | 
RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_U_OPS (vuint16mf2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_U_OPS (vuint16m1_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_U_OPS (vuint16m2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_U_OPS (vuint16m4_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_CONVERT_U_OPS (vuint16m8_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
 
 DEF_RVV_CONVERT_U_OPS (vuint32mf2_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_CONVERT_U_OPS (vuint32m1_t, 0)
@@ -648,22 +678,22 @@ DEF_RVV_CONVERT_U_OPS (vuint64m2_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_CONVERT_U_OPS (vuint64m4_t, RVV_REQUIRE_ELEN_64)
 DEF_RVV_CONVERT_U_OPS (vuint64m8_t, RVV_REQUIRE_ELEN_64)
 
-DEF_RVV_WCONVERT_I_OPS (vint32mf2_t, RVV_REQUIRE_ELEN_FP_16 | 
RVV_REQUIRE_ELEN_64)
-DEF_RVV_WCONVERT_I_OPS (vint32m1_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WCONVERT_I_OPS (vint32m2_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WCONVERT_I_OPS (vint32m4_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WCONVERT_I_OPS (vint32m8_t, RVV_REQUIRE_ELEN_FP_16)
+DEF_RVV_WCONVERT_I_OPS (vint32mf2_t, RVV_REQUIRE_ELEN_FP_16 | 
RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WCONVERT_I_OPS (vint32m1_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WCONVERT_I_OPS (vint32m2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WCONVERT_I_OPS (vint32m4_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WCONVERT_I_OPS (vint32m8_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
 
 DEF_RVV_WCONVERT_I_OPS (vint64m1_t, RVV_REQUIRE_ELEN_FP_32 | 
RVV_REQUIRE_ELEN_64)
 DEF_RVV_WCONVERT_I_OPS (vint64m2_t, RVV_REQUIRE_ELEN_FP_32 | 
RVV_REQUIRE_ELEN_64)
 DEF_RVV_WCONVERT_I_OPS (vint64m4_t, RVV_REQUIRE_ELEN_FP_32 | 
RVV_REQUIRE_ELEN_64)
 DEF_RVV_WCONVERT_I_OPS (vint64m8_t, RVV_REQUIRE_ELEN_FP_32 | 
RVV_REQUIRE_ELEN_64)
 
-DEF_RVV_WCONVERT_U_OPS (vuint32mf2_t, RVV_REQUIRE_ELEN_FP_16 | 
RVV_REQUIRE_ELEN_64)
-DEF_RVV_WCONVERT_U_OPS (vuint32m1_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WCONVERT_U_OPS (vuint32m2_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WCONVERT_U_OPS (vuint32m4_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WCONVERT_U_OPS (vuint32m8_t, RVV_REQUIRE_ELEN_FP_16)
+DEF_RVV_WCONVERT_U_OPS (vuint32mf2_t, RVV_REQUIRE_ELEN_FP_16 | 
RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WCONVERT_U_OPS (vuint32m1_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WCONVERT_U_OPS (vuint32m2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WCONVERT_U_OPS (vuint32m4_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WCONVERT_U_OPS (vuint32m8_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
 
 DEF_RVV_WCONVERT_U_OPS (vuint64m1_t, RVV_REQUIRE_ELEN_FP_32 | 
RVV_REQUIRE_ELEN_64)
 DEF_RVV_WCONVERT_U_OPS (vuint64m2_t, RVV_REQUIRE_ELEN_FP_32 | 
RVV_REQUIRE_ELEN_64)
@@ -725,12 +755,12 @@ DEF_RVV_WU_OPS (vuint32m2_t, 0)
 DEF_RVV_WU_OPS (vuint32m4_t, 0)
 DEF_RVV_WU_OPS (vuint32m8_t, 0)
 
-DEF_RVV_WF_OPS (vfloat16mf4_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ELEN_64)
-DEF_RVV_WF_OPS (vfloat16mf2_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WF_OPS (vfloat16m1_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WF_OPS (vfloat16m2_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WF_OPS (vfloat16m4_t, RVV_REQUIRE_ELEN_FP_16)
-DEF_RVV_WF_OPS (vfloat16m8_t, RVV_REQUIRE_ELEN_FP_16)
+DEF_RVV_WF_OPS (vfloat16mf4_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ELEN_64 | 
RVV_REQUIRE_ZVFH)
+DEF_RVV_WF_OPS (vfloat16mf2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WF_OPS (vfloat16m1_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WF_OPS (vfloat16m2_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WF_OPS (vfloat16m4_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
+DEF_RVV_WF_OPS (vfloat16m8_t, RVV_REQUIRE_ELEN_FP_16 | RVV_REQUIRE_ZVFH)
 
 DEF_RVV_WF_OPS (vfloat32mf2_t, RVV_REQUIRE_ELEN_FP_32 | RVV_REQUIRE_ELEN_64)
 DEF_RVV_WF_OPS (vfloat32m1_t, RVV_REQUIRE_ELEN_FP_32)
@@ -1598,6 +1628,7 @@ DEF_RVV_DIU_OPS (vuint64m8_t, RVV_REQUIRE_ELEN_64)
 #undef DEF_RVV_I_OPS
 #undef DEF_RVV_U_OPS
 #undef DEF_RVV_F_OPS
+#undef DEF_RVV_F_ARITH_OPS
 #undef DEF_RVV_B_OPS
 #undef DEF_RVV_WEXTI_OPS
 #undef DEF_RVV_QEXTI_OPS
diff --git a/gcc/config/riscv/riscv-vector-builtins.cc 
b/gcc/config/riscv/riscv-vector-builtins.cc
index 4e526ccdc1e..1f4f3eb86c5 100644
--- a/gcc/config/riscv/riscv-vector-builtins.cc
+++ b/gcc/config/riscv/riscv-vector-builtins.cc
@@ -284,6 +284,13 @@ static const rvv_type_info f_ops[] = {
 #include "riscv-vector-builtins-types.def"
   {NUM_VECTOR_TYPES, 0}};
 
+/* A list of all float for arithmetic will be registered for intrinsic
+   functions.  */
+static const rvv_type_info f_arith_ops[] = {
+#define DEF_RVV_F_ARITH_OPS(TYPE, REQUIRE) {VECTOR_TYPE_##TYPE, REQUIRE},
+#include "riscv-vector-builtins-types.def"
+  {NUM_VECTOR_TYPES, 0}};
+
 /* A list of Double-Widening signed integer will be registered for intrinsic
  * functions.  */
 static const rvv_type_info wexti_ops[] = {
@@ -1560,7 +1567,7 @@ static constexpr const rvv_op_info iu_vvxv_ops
 /* A static operand information for vector_type func (vector_type, vector_type,
  * vector_type) function registration. */
 static constexpr const rvv_op_info f_vvvv_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_vv,                         /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      vvv_args /* Args */};
@@ -1568,7 +1575,7 @@ static constexpr const rvv_op_info f_vvvv_ops
 /* A static operand information for vector_type func (vector_type, scalar_type,
  * vector_type) function registration. */
 static constexpr const rvv_op_info f_vvfv_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_vf,                         /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      vxv_args /* Args */};
@@ -1608,7 +1615,7 @@ static constexpr const rvv_op_info iu_vvxm_ops
 /* A static operand information for vector_type func (vector_type, scalar_type,
  * mask_type) function registration. */
 static constexpr const rvv_op_info f_vvfm_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_vfm,                        /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      vxm_args /* Args */};
@@ -1656,7 +1663,7 @@ static constexpr const rvv_op_info u_mvv_ops
 /* A static operand information for mask_type func (vector_type, vector_type)
  * function registration. */
 static constexpr const rvv_op_info f_mvv_ops
-  = {f_ops,                            /* Types */
+  = {f_arith_ops,                       /* Types */
      OP_TYPE_vv,                       /* Suffix */
      rvv_arg_type_info (RVV_BASE_mask), /* Return type */
      vv_args /* Args */};
@@ -1688,7 +1695,7 @@ static constexpr const rvv_op_info u_mvx_ops
 /* A static operand information for mask_type func (vector_type, scalar_type)
  * function registration. */
 static constexpr const rvv_op_info f_mvf_ops
-  = {f_ops,                            /* Types */
+  = {f_arith_ops,                       /* Types */
      OP_TYPE_vf,                       /* Suffix */
      rvv_arg_type_info (RVV_BASE_mask), /* Return type */
      vx_args /* Args */};
@@ -1712,7 +1719,7 @@ static constexpr const rvv_op_info u_vvv_ops
 /* A static operand information for vector_type func (vector_type, vector_type)
  * function registration. */
 static constexpr const rvv_op_info f_vvv_ops
-  = {f_ops,                            /* Types */
+  = {f_arith_ops,                       /* Types */
      OP_TYPE_vv,                       /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      vv_args /* Args */};
@@ -1720,7 +1727,7 @@ static constexpr const rvv_op_info f_vvv_ops
 /* A static operand information for vector_type func (vector_type, vector_type)
  * function registration. */
 static constexpr const rvv_op_info f_vvf_ops
-  = {f_ops,                            /* Types */
+  = {f_arith_ops,                       /* Types */
      OP_TYPE_vf,                       /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      vx_args /* Args */};
@@ -1913,7 +1920,7 @@ static constexpr const rvv_op_info iu_x_s_ops
 /* A static operand information for scalar_type func (vector_type)
  * function registration. */
 static constexpr const rvv_op_info f_f_s_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_s,                                  /* Suffix */
      rvv_arg_type_info (RVV_BASE_scalar), /* Return type */
      v_args /* Args */};
@@ -1929,7 +1936,7 @@ static constexpr const rvv_op_info iu_vs_ops
 /* A static operand information for vector_type func (vector_type)
  * function registration. */
 static constexpr const rvv_op_info f_vs_ops
-  = {f_ops,                                    /* Types */
+  = {f_arith_ops,                               /* Types */
      OP_TYPE_vs,                               /* Suffix */
      rvv_arg_type_info (RVV_BASE_lmul1_vector), /* Return type */
      vs_args /* Args */};
@@ -1961,7 +1968,7 @@ static constexpr const rvv_op_info wf_vs_ops
 /* A static operand information for vector_type func (vector_type)
  * function registration. */
 static constexpr const rvv_op_info f_v_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_v,                                  /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      v_args /* Args */};
@@ -1993,7 +2000,7 @@ static constexpr const rvv_op_info f_to_wi_f_v_ops
 /* A static operand information for vector_type func (vector_type)
  * function registration. */
 static constexpr const rvv_op_info f_to_ni_f_w_ops
-  = {f_ops,                                                  /* Types */
+  = {f_arith_ops,                                             /* Types */
      OP_TYPE_f_w,                                            /* Suffix */
      rvv_arg_type_info (RVV_BASE_double_trunc_signed_vector), /* Return type */
      v_args /* Args */};
@@ -2001,7 +2008,7 @@ static constexpr const rvv_op_info f_to_ni_f_w_ops
 /* A static operand information for vector_type func (vector_type)
  * function registration. */
 static constexpr const rvv_op_info f_to_nu_f_w_ops
-  = {f_ops,      /* Types */
+  = {f_arith_ops, /* Types */
      OP_TYPE_f_w, /* Suffix */
      rvv_arg_type_info (
        RVV_BASE_double_trunc_unsigned_vector), /* Return type */
@@ -2010,7 +2017,7 @@ static constexpr const rvv_op_info f_to_nu_f_w_ops
 /* A static operand information for vector_type func (vector_type)
  * function registration. */
 static constexpr const rvv_op_info i_to_f_x_v_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_x_v,                        /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      x_v_args /* Args */};
@@ -2018,7 +2025,7 @@ static constexpr const rvv_op_info i_to_f_x_v_ops
 /* A static operand information for vector_type func (vector_type)
  * function registration. */
 static constexpr const rvv_op_info u_to_f_xu_v_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_xu_v,                       /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      xu_v_args /* Args */};
@@ -2026,7 +2033,7 @@ static constexpr const rvv_op_info u_to_f_xu_v_ops
 /* A static operand information for vector_type func (vector_type)
  * function registration. */
 static constexpr const rvv_op_info i_to_wf_x_v_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_x_v,                        /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      w_x_v_args /* Args */};
@@ -2034,7 +2041,7 @@ static constexpr const rvv_op_info i_to_wf_x_v_ops
 /* A static operand information for vector_type func (vector_type)
  * function registration. */
 static constexpr const rvv_op_info u_to_wf_xu_v_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_xu_v,                       /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      w_xu_v_args /* Args */};
@@ -2442,7 +2449,7 @@ static constexpr const rvv_op_info iu_s_x_ops
 /* A static operand information for vector_type func (scalar_type)
  * function registration. */
 static constexpr const rvv_op_info f_f_ops
-  = {f_ops,                    /* Types */
+  = {f_arith_ops,               /* Types */
      OP_TYPE_f,                        /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      x_args /* Args */};
@@ -2450,7 +2457,7 @@ static constexpr const rvv_op_info f_f_ops
 /* A static operand information for vector_type func (scalar_type)
  * function registration. */
 static constexpr const rvv_op_info f_s_f_ops
-  = {f_ops,                              /* Types */
+  = {f_arith_ops,                         /* Types */
      OP_TYPE_f,                                  /* Suffix */
      rvv_arg_type_info (RVV_BASE_vector), /* Return type */
      x_args /* Args */};
@@ -5763,12 +5770,13 @@ validate_instance_type_required_extensions (const 
rvv_type_info type,
     }
 
   if ((exts & RVV_REQUIRE_ELEN_FP_16)
-    && !TARGET_VECTOR_ELEN_FP_16_P (riscv_vector_elen_flags))
+      && (!TARGET_VECTOR_ELEN_FP_16_P (riscv_vector_elen_flags)
+         || ((exts & RVV_REQUIRE_ZVFH) && !TARGET_ZVFH)))
     {
       error_at (location,
-               "built-in function %qE requires the "
-               "zvfhmin or zvfh ISA extension",
-               fndecl);
+               "built-in function %qE requires the %s ISA extension",
+               fndecl, exts & RVV_REQUIRE_ZVFH ? "zvfh"
+                                             : "zvfhmin or zvfh");
       return false;
     }
 
diff --git a/gcc/config/riscv/riscv-vector-builtins.h 
b/gcc/config/riscv/riscv-vector-builtins.h
index 3cd60cff4f2..3ec2b1a3889 100644
--- a/gcc/config/riscv/riscv-vector-builtins.h
+++ b/gcc/config/riscv/riscv-vector-builtins.h
@@ -111,6 +111,7 @@ static const unsigned int CP_WRITE_CSR = 1U << 5;
 #define RVV_REQUIRE_ELEN_FP_16 (1 << 6) /* Require FP ELEN >= 32.  */
 #define RVV_REQUIRE_ELEN_BF_16 (1 << 7) /* Require BF16.  */
 #define RVV_REQUIRE_ZVFOFP8MIN (1 << 8) /* Require ZVFOFP8MIN extension.  */
+#define RVV_REQUIRE_ZVFH (1 << 9) /* Require ZVFH extension.  */
 
 /* Enumerates the required extensions.  */
 enum required_ext
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/bug-9.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/bug-9.c
index b3d27010966..9de917a5435 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/base/bug-9.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/bug-9.c
@@ -7,7 +7,7 @@
 
 vfloat16m1_t f0 (vfloat16m1_t vs2, vfloat16m1_t vs1, size_t vl)
 {
-  return __riscv_vfadd_vv_f16m1_rm (vs2, vs1, 0, vl); /* { dg-error "built-in 
function '__riscv_vfadd_vv_f16m1_rm' requires the zvfhmin or zvfh ISA 
extension" } */
+  return __riscv_vfadd_vv_f16m1_rm (vs2, vs1, 0, vl); /* { dg-error "built-in 
function '__riscv_vfadd_vv_f16m1_rm' requires the zvfh ISA extension" } */
 }
 
 /* { dg-error "return type 'vfloat16m1_t' requires the zvfhmin or zvfh ISA 
extension" "" { target { "riscv*-*-*" } } 0 } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr114988-1.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/pr114988-1.c
index b797d5996b7..3d83f707439 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/base/pr114988-1.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr114988-1.c
@@ -5,5 +5,5 @@
 
 vfloat32mf2_t test_vfwsub_wf_f32mf2(vfloat32mf2_t vs2, _Float16 rs1, size_t vl)
 {
-  return __riscv_vfwsub_wf_f32mf2(vs2, rs1, vl); /* { dg-error {built-in 
function '__riscv_vfwsub_wf_f32mf2' requires the zvfhmin or zvfh ISA extension} 
} */
+  return __riscv_vfwsub_wf_f32mf2(vs2, rs1, vl); /* { dg-error {built-in 
function '__riscv_vfwsub_wf_f32mf2' requires the zvfh ISA extension} } */
 }
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/pr114988-2.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/pr114988-2.c
index 7491359c011..9b68a7227dd 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/base/pr114988-2.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/pr114988-2.c
@@ -5,5 +5,5 @@
 
 vfloat32mf2_t test_vfwadd_wf_f32mf2(vfloat32mf2_t vs2, _Float16 rs1, size_t vl)
 {
-  return __riscv_vfwadd_wf_f32mf2(vs2, rs1, vl); /* { dg-error {built-in 
function '__riscv_vfwadd_wf_f32mf2' requires the zvfhmin or zvfh ISA extension} 
} */
+  return __riscv_vfwadd_wf_f32mf2(vs2, rs1, vl); /* { dg-error {built-in 
function '__riscv_vfwadd_wf_f32mf2' requires the zvfh ISA extension} } */
 }
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-19.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-19.c
index 63b350f5ecc..bee66788a71 100644
--- 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-19.c
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-19.c
@@ -7,7 +7,7 @@ vfloat16m1_t
 __attribute__((target("arch=+zve32x")))
 test_1 (vfloat16m1_t a, vfloat16m1_t b, size_t vl)
 {
-  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfhmin or zvfh ISA extension" } */
+  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfh ISA extension" } */
 }
 
 /* { dg-error "return type 'vfloat16m1_t' requires the zvfhmin or zvfh ISA 
extension" "" { target { "riscv*-*-*" } } 0 } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-22.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-22.c
index bdd80cb731d..7b76eb93900 100644
--- 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-22.c
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-22.c
@@ -7,7 +7,7 @@ vfloat16m1_t
 __attribute__((target("arch=+zve32f")))
 test_1 (vfloat16m1_t a, vfloat16m1_t b, size_t vl)
 {
-  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfhmin or zvfh ISA extension" } */
+  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfh ISA extension" } */
 }
 
 /* { dg-error "return type 'vfloat16m1_t' requires the zvfhmin or zvfh ISA 
extension" "" { target { "riscv*-*-*" } } 0 } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-25.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-25.c
index 217bf37626c..e460f0418a8 100644
--- 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-25.c
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-25.c
@@ -7,7 +7,7 @@ vfloat16m1_t
 __attribute__((target("arch=+zve64x")))
 test_1 (vfloat16m1_t a, vfloat16m1_t b, size_t vl)
 {
-  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfhmin or zvfh ISA extension" } */
+  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfh ISA extension" } */
 }
 
 /* { dg-error "return type 'vfloat16m1_t' requires the zvfhmin or zvfh ISA 
extension" "" { target { "riscv*-*-*" } } 0 } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-28.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-28.c
index 5b5bff594a8..e5e1bafa9f2 100644
--- 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-28.c
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-28.c
@@ -7,7 +7,7 @@ vfloat16m1_t
 __attribute__((target("arch=+zve64f")))
 test_1 (vfloat16m1_t a, vfloat16m1_t b, size_t vl)
 {
-  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfhmin or zvfh ISA extension" } */
+  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfh ISA extension" } */
 }
 
 /* { dg-error "return type 'vfloat16m1_t' requires the zvfhmin or zvfh ISA 
extension" "" { target { "riscv*-*-*" } } 0 } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-29.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-29.c
index 32233876a2d..7da23e8e9b9 100644
--- 
a/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-29.c
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-29.c
@@ -7,7 +7,7 @@ vfloat16m1_t
 __attribute__((target("arch=+zve64d")))
 test_1 (vfloat16m1_t a, vfloat16m1_t b, size_t vl)
 {
-  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfhmin or zvfh ISA extension" } */
+  return __riscv_vfadd_vv_f16m1 (a, b, vl); /* { dg-error "built-in function 
'__riscv_vfadd_vv_f16m1' requires the zvfh ISA extension" } */
 }
 
 /* { dg-error "return type 'vfloat16m1_t' requires the zvfhmin or zvfh ISA 
extension" "" { target { "riscv*-*-*" } } 0 } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvfhmin-arith-error.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/zvfhmin-arith-error.c
new file mode 100644
index 00000000000..08da51bb491
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvfhmin-arith-error.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv_zvfhmin -mabi=ilp32d" { target { rv32 } } } */
+/* { dg-options "-march=rv64gcv_zvfhmin -mabi=lp64d" { target { rv64 } } } */
+
+#include <riscv_vector.h>
+
+vfloat16m1_t
+test_add (vfloat16m1_t a, vfloat16m1_t b, size_t vl)
+{
+  return __riscv_vfadd (a, b, vl); /* { dg-error "requires the zvfh ISA 
extension" } */
+}
+
+vfloat32m2_t
+test_widen_add (vfloat16m1_t a, vfloat16m1_t b, size_t vl)
+{
+  return __riscv_vfwadd_vv_f32m2 (a, b, vl); /* { dg-error "requires the zvfh 
ISA extension" } */
+}
+
+vfloat16m1_t
+test_narrow_convert (vint32m2_t a, size_t vl)
+{
+  return __riscv_vfncvt_f (a, vl); /* { dg-error "requires the zvfh ISA 
extension" } */
+}
-- 
2.47.1

Reply via email to