From: Pan Li <pan2...@intel.com>

This patch would like to support the FP below API auto vectorization
with different type size

+---------+-----------+----------+
| API     | RV64      | RV32     |
+---------+-----------+----------+
| irint   | DF => SI  | DF => SI |
| irintf  | -         | -        |
| lrint   | -         | DF => SI |
| lrintf  | SF => DI  | -        |
| llrint  | -         | -        |
| llrintf | SF => DI  | SF => DI |
+---------+-----------+----------+

Given below code:
void
test_lrintf (long *out, float *in, unsigned count)
{
  for (unsigned i = 0; i < count; i++)
    out[i] = __builtin_lrintf (in[i]);
}

Before this patch:
test_lrintf:
  beq     a2,zero,.L8
  slli    a5,a2,32
  srli    a2,a5,30
  add     a4,a1,a2
.L3:
  flw     fa5,0(a1)
  addi    a1,a1,4
  addi    a0,a0,8
  fcvt.l.s a5,fa5,dyn
  sd      a5,-8(a0)
  bne     a1,a4,.L3

After this patch:
test_lrintf:
  beq     a2,zero,.L8
  slli    a2,a2,32
  srli    a2,a2,32
.L3:
  vsetvli a5,a2,e32,mf2,ta,ma
  vle32.v v2,0(a1)
  slli    a3,a5,2
  slli    a4,a5,3
  vfwcvt.x.f.v    v1,v2
  sub     a2,a2,a5
  vse64.v v1,0(a0)
  add     a1,a1,a3
  add     a0,a0,a4
  bne     a2,zero,.L3

Unfortunately, the HF mode is not include due to it requires
additional middle-end support from internal-fun.def.

gcc/ChangeLog:

        * config/riscv/autovec.md: Remove the size check of lrint.
        * config/riscv/riscv-v.cc (emit_vec_narrow_cvt_x_f): New help
        emit func impl.
        (emit_vec_widden_cvt_x_f): New help emit func impl.
        (emit_vec_rounding_to_integer): New func impl to emit the
        rounding from FP to integer.
        (expand_vec_lrint): Leverage emit_vec_rounding_to_integer.
        * config/riscv/vector.md: Take V_VLSF for vfncvt.

gcc/testsuite/ChangeLog:

        * gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c:
        * gcc.target/riscv/rvv/autovec/unop/math-irint-1.c: New test.
        * gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c: New test.
        * gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c: New test.
        * gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c: New test.
        * gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c: New test.
        * gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c: New test.
        * gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c: New test.
        * gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c: New test.
        * gcc.target/riscv/rvv/autovec/vls/math-irint-1.c: New test.
        * gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c: New test.
        * gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c: New test.
        * gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c: New test.

Signed-off-by: Pan Li <pan2...@intel.com>
---
 gcc/config/riscv/autovec.md                   |  6 +-
 gcc/config/riscv/riscv-v.cc                   | 46 +++++++++-
 gcc/config/riscv/vector.md                    |  2 +-
 .../riscv/rvv/autovec/unop/math-irint-1.c     | 13 +++
 .../riscv/rvv/autovec/unop/math-irint-run-0.c | 92 +++++++++----------
 .../rvv/autovec/unop/math-irintf-run-0.c      | 63 +++++++++++++
 .../riscv/rvv/autovec/unop/math-llrintf-0.c   | 13 +++
 .../rvv/autovec/unop/math-llrintf-run-0.c     | 63 +++++++++++++
 .../rvv/autovec/unop/math-lrint-rv32-0.c      | 13 +++
 .../rvv/autovec/unop/math-lrint-rv32-run-0.c  | 63 +++++++++++++
 .../rvv/autovec/unop/math-lrintf-rv64-0.c     | 13 +++
 .../rvv/autovec/unop/math-lrintf-rv64-run-0.c | 63 +++++++++++++
 .../riscv/rvv/autovec/vls/math-irint-1.c      | 30 ++++++
 .../riscv/rvv/autovec/vls/math-llrintf-0.c    | 30 ++++++
 .../riscv/rvv/autovec/vls/math-lrint-rv32-0.c | 30 ++++++
 .../rvv/autovec/vls/math-lrintf-rv64-0.c      | 30 ++++++
 16 files changed, 514 insertions(+), 56 deletions(-)
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-1.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-irint-1.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c
 create mode 100644 
gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c

diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md
index cc4c9596bbf..f1f0523d1de 100644
--- a/gcc/config/riscv/autovec.md
+++ b/gcc/config/riscv/autovec.md
@@ -2400,8 +2400,7 @@ (define_expand "roundeven<mode>2"
 (define_expand "lrint<mode><v_f2si_convert>2"
   [(match_operand:<V_F2SI_CONVERT>   0 "register_operand")
    (match_operand:V_VLS_F_CONVERT_SI 1 "register_operand")]
-  "TARGET_VECTOR && !flag_trapping_math && !flag_rounding_math
-    && known_eq (GET_MODE_SIZE (<MODE>mode), GET_MODE_SIZE 
(<V_F2SI_CONVERT>mode))"
+  "TARGET_VECTOR && !flag_trapping_math && !flag_rounding_math"
   {
     riscv_vector::expand_vec_lrint (operands[0], operands[1], <MODE>mode, 
<V_F2SI_CONVERT>mode);
     DONE;
@@ -2411,8 +2410,7 @@ (define_expand "lrint<mode><v_f2si_convert>2"
 (define_expand "lrint<mode><v_f2di_convert>2"
   [(match_operand:<V_F2DI_CONVERT>   0 "register_operand")
    (match_operand:V_VLS_F_CONVERT_DI 1 "register_operand")]
-  "TARGET_VECTOR && !flag_trapping_math && !flag_rounding_math
-    && known_eq (GET_MODE_SIZE (<MODE>mode), GET_MODE_SIZE 
(<V_F2DI_CONVERT>mode))"
+  "TARGET_VECTOR && !flag_trapping_math && !flag_rounding_math"
   {
     riscv_vector::expand_vec_lrint (operands[0], operands[1], <MODE>mode, 
<V_F2DI_CONVERT>mode);
     DONE;
diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc
index b489ce08775..52eb2aca279 100644
--- a/gcc/config/riscv/riscv-v.cc
+++ b/gcc/config/riscv/riscv-v.cc
@@ -3927,6 +3927,26 @@ emit_vec_cvt_x_f (rtx op_dest, rtx op_src, insn_type 
type,
   emit_vlmax_insn (icode, type, ops);
 }
 
+static void
+emit_vec_narrow_cvt_x_f (rtx op_dest, rtx op_src, insn_type type,
+                        machine_mode vec_mode)
+{
+  rtx ops[] = {op_dest, op_src};
+  insn_code icode = code_for_pred_narrow_fcvt_x_f (UNSPEC_VFCVT, vec_mode);
+
+  emit_vlmax_insn (icode, type, ops);
+}
+
+static void
+emit_vec_widden_cvt_x_f (rtx op_dest, rtx op_src, insn_type type,
+                        machine_mode vec_mode)
+{
+  rtx ops[] = {op_dest, op_src};
+  insn_code icode = code_for_pred_widen_fcvt_x_f (UNSPEC_VFCVT, vec_mode);
+
+  emit_vlmax_insn (icode, type, ops);
+}
+
 static void
 emit_vec_cvt_f_x (rtx op_dest, rtx op_src, rtx mask,
                  insn_type type, machine_mode vec_mode)
@@ -4119,14 +4139,30 @@ expand_vec_roundeven (rtx op_0, rtx op_1, machine_mode 
vec_fp_mode,
   emit_vec_copysign (op_0, op_0, op_1, vec_fp_mode);
 }
 
+/* Handling the rounding from floating-point to int/long/long long.  */
+static void
+emit_vec_rounding_to_integer (rtx op_0, rtx op_1, machine_mode vec_fp_mode,
+                             machine_mode vec_int_mode, insn_type type)
+{
+  poly_uint16 vec_fp_size = GET_MODE_SIZE (vec_fp_mode);
+  poly_uint16 vec_int_size = GET_MODE_SIZE (vec_int_mode);
+
+  if (known_eq (vec_fp_size, vec_int_size)) /* SF => SI, DF => DI.  */
+    emit_vec_cvt_x_f (op_0, op_1, type, vec_fp_mode);
+  else if (maybe_eq (vec_fp_size, vec_int_size * 2)) /* DF => SI.  */
+    emit_vec_narrow_cvt_x_f (op_0, op_1, type, vec_fp_mode);
+  else if (maybe_eq (vec_fp_size * 2, vec_int_size)) /* SF => DI.  */
+    emit_vec_widden_cvt_x_f (op_0, op_1, type, vec_int_mode);
+  else /* HF requires additional middle-end support.  */
+    gcc_unreachable ();
+}
+
 void
 expand_vec_lrint (rtx op_0, rtx op_1, machine_mode vec_fp_mode,
-                 machine_mode vec_long_mode)
+                 machine_mode vec_int_mode)
 {
-  gcc_assert (known_eq (GET_MODE_SIZE (vec_fp_mode),
-                       GET_MODE_SIZE (vec_long_mode)));
-
-  emit_vec_cvt_x_f (op_0, op_1, UNARY_OP_FRM_DYN, vec_fp_mode);
+  emit_vec_rounding_to_integer (op_0, op_1, vec_fp_mode, vec_int_mode,
+                               UNARY_OP_FRM_DYN);
 }
 
 void
diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md
index ce5c5be8e42..88f2ef0566c 100644
--- a/gcc/config/riscv/vector.md
+++ b/gcc/config/riscv/vector.md
@@ -7661,7 +7661,7 @@ (define_insn "@pred_narrow_fcvt_x<v_su>_f<mode>"
             (reg:SI VTYPE_REGNUM)
             (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
          (unspec:<VNCONVERT>
-            [(match_operand:VF 3 "register_operand"           "  0,  0,  0,  
0,   vr,   vr")] VFCVTS)
+            [(match_operand:V_VLSF 3 "register_operand"       "  0,  0,  0,  
0,   vr,   vr")] VFCVTS)
          (match_operand:<VNCONVERT> 2 "vector_merge_operand"  " vu,  0, vu,  
0,   vu,    0")))]
   "TARGET_VECTOR"
   "vfncvt.x<v_su>.f.w\t%0,%3%p1"
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-1.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-1.c
new file mode 100644
index 00000000000..0dab456c3ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize 
-fno-vect-cost-model -ffast-math -fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include "test-math.h"
+
+/*
+** test_double_int___builtin_irint:
+**   ...
+**   vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+
+**   ...
+*/
+TEST_UNARY_CALL_CVT (double, int, __builtin_irint)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c
index 0be38528d0b..43bc0849695 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irint-run-0.c
@@ -6,58 +6,58 @@
 #define ARRAY_SIZE 128
 
 float in[ARRAY_SIZE];
-int out[ARRAY_SIZE];
-int ref[ARRAY_SIZE];
+long out[ARRAY_SIZE];
+long ref[ARRAY_SIZE];
 
-TEST_UNARY_CALL_CVT (float, int, __builtin_irintf)
-TEST_ASSERT (int)
+TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf)
+TEST_ASSERT (long)
 
-TEST_INIT_CVT (float, 1.2, int, __builtin_irintf (1.2), 1)
-TEST_INIT_CVT (float, -1.2, int, __builtin_irintf (-1.2), 2)
-TEST_INIT_CVT (float, 0.5, int, __builtin_irintf (0.5), 3)
-TEST_INIT_CVT (float, -0.5, int, __builtin_irintf (-0.5), 4)
-TEST_INIT_CVT (float, 0.1, int, __builtin_irintf (0.1), 5)
-TEST_INIT_CVT (float, -0.1, int, __builtin_irintf (-0.1), 6)
-TEST_INIT_CVT (float, 3.0, int, __builtin_irintf (3.0), 7)
-TEST_INIT_CVT (float, -3.0, int, __builtin_irintf (-3.0), 8)
-TEST_INIT_CVT (float, 8388607.5, int, __builtin_irintf (8388607.5), 9)
-TEST_INIT_CVT (float, 8388609.0, int, __builtin_irintf (8388609.0), 10)
-TEST_INIT_CVT (float, -8388607.5, int, __builtin_irintf (-8388607.5), 11)
-TEST_INIT_CVT (float, -8388609.0, int, __builtin_irintf (-8388609.0), 12)
-TEST_INIT_CVT (float, 0.0, int, __builtin_irintf (-0.0), 13)
-TEST_INIT_CVT (float, -0.0, int, __builtin_irintf (-0.0), 14)
-TEST_INIT_CVT (float, 2147483520.0, int, __builtin_irintf (2147483520.0), 15)
-TEST_INIT_CVT (float, 2147483648.0, int, __builtin_irintf (2147483648.0), 16)
-TEST_INIT_CVT (float, -2147483648.0, int, __builtin_irintf (-2147483648.0), 17)
-TEST_INIT_CVT (float, -2147483904.0, int, __builtin_irintf (-2147483904.0), 18)
-TEST_INIT_CVT (float, __builtin_inf (), int, __builtin_irintf (__builtin_inff 
()), 19)
-TEST_INIT_CVT (float, -__builtin_inf (), int, __builtin_irintf 
(-__builtin_inff ()), 20)
-TEST_INIT_CVT (float, __builtin_nanf (""), int, 0x7fffffff, 21)
+TEST_INIT_CVT (float, 1.2, long, __builtin_lrintf (1.2), 1)
+TEST_INIT_CVT (float, -1.2, long, __builtin_lrintf (-1.2), 2)
+TEST_INIT_CVT (float, 0.5, long, __builtin_lrintf (0.5), 3)
+TEST_INIT_CVT (float, -0.5, long, __builtin_lrintf (-0.5), 4)
+TEST_INIT_CVT (float, 0.1, long, __builtin_lrintf (0.1), 5)
+TEST_INIT_CVT (float, -0.1, long, __builtin_lrintf (-0.1), 6)
+TEST_INIT_CVT (float, 3.0, long, __builtin_lrintf (3.0), 7)
+TEST_INIT_CVT (float, -3.0, long, __builtin_lrintf (-3.0), 8)
+TEST_INIT_CVT (float, 4503599627370495.5, long, __builtin_lrintf 
(4503599627370495.5), 9)
+TEST_INIT_CVT (float, 4503599627370497.0, long, __builtin_lrintf 
(4503599627370497.0), 10)
+TEST_INIT_CVT (float, -4503599627370495.5, long, __builtin_lrintf 
(-4503599627370495.5), 11)
+TEST_INIT_CVT (float, -4503599627370496.0, long, __builtin_lrintf 
(-4503599627370496.0), 12)
+TEST_INIT_CVT (float, 0.0, long, __builtin_lrintf (-0.0), 13)
+TEST_INIT_CVT (float, -0.0, long, __builtin_lrintf (-0.0), 14)
+TEST_INIT_CVT (float, 9223372036854774784.0, long, __builtin_lrintf 
(9223372036854774784.0), 15)
+TEST_INIT_CVT (float, 9223372036854775808.0, long, __builtin_lrintf 
(9223372036854775808.0), 16)
+TEST_INIT_CVT (float, -9223372036854775808.0, long, __builtin_lrintf 
(-9223372036854775808.0), 17)
+TEST_INIT_CVT (float, -9223372036854777856.0, long, __builtin_lrintf 
(-9223372036854777856.0), 18)
+TEST_INIT_CVT (float, __builtin_inf (), long, __builtin_lrintf (__builtin_inf 
()), 19)
+TEST_INIT_CVT (float, -__builtin_inf (), long, __builtin_lrintf 
(-__builtin_inf ()), 20)
+TEST_INIT_CVT (float, __builtin_nan (""), long, 0x7fffffffffffffff, 21)
 
 int
 main ()
 {
-  RUN_TEST_CVT (float, int, 1, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 2, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 3, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 4, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 5, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 6, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 7, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 8, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 9, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 10, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 11, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 12, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 13, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 14, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 15, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 16, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 17, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 18, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 19, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 20, __builtin_irintf, in, out, ref, ARRAY_SIZE);
-  RUN_TEST_CVT (float, int, 21, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 1, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 2, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 3, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 4, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 5, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 6, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 7, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 8, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 9, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 10, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 11, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 12, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 13, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 14, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 15, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 16, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 17, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 18, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 19, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 20, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 21, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
 
   return 0;
 }
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c
new file mode 100644
index 00000000000..0be38528d0b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-irintf-run-0.c
@@ -0,0 +1,63 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model 
-ffast-math" } */
+
+#include "test-math.h"
+
+#define ARRAY_SIZE 128
+
+float in[ARRAY_SIZE];
+int out[ARRAY_SIZE];
+int ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (float, int, __builtin_irintf)
+TEST_ASSERT (int)
+
+TEST_INIT_CVT (float, 1.2, int, __builtin_irintf (1.2), 1)
+TEST_INIT_CVT (float, -1.2, int, __builtin_irintf (-1.2), 2)
+TEST_INIT_CVT (float, 0.5, int, __builtin_irintf (0.5), 3)
+TEST_INIT_CVT (float, -0.5, int, __builtin_irintf (-0.5), 4)
+TEST_INIT_CVT (float, 0.1, int, __builtin_irintf (0.1), 5)
+TEST_INIT_CVT (float, -0.1, int, __builtin_irintf (-0.1), 6)
+TEST_INIT_CVT (float, 3.0, int, __builtin_irintf (3.0), 7)
+TEST_INIT_CVT (float, -3.0, int, __builtin_irintf (-3.0), 8)
+TEST_INIT_CVT (float, 8388607.5, int, __builtin_irintf (8388607.5), 9)
+TEST_INIT_CVT (float, 8388609.0, int, __builtin_irintf (8388609.0), 10)
+TEST_INIT_CVT (float, -8388607.5, int, __builtin_irintf (-8388607.5), 11)
+TEST_INIT_CVT (float, -8388609.0, int, __builtin_irintf (-8388609.0), 12)
+TEST_INIT_CVT (float, 0.0, int, __builtin_irintf (-0.0), 13)
+TEST_INIT_CVT (float, -0.0, int, __builtin_irintf (-0.0), 14)
+TEST_INIT_CVT (float, 2147483520.0, int, __builtin_irintf (2147483520.0), 15)
+TEST_INIT_CVT (float, 2147483648.0, int, __builtin_irintf (2147483648.0), 16)
+TEST_INIT_CVT (float, -2147483648.0, int, __builtin_irintf (-2147483648.0), 17)
+TEST_INIT_CVT (float, -2147483904.0, int, __builtin_irintf (-2147483904.0), 18)
+TEST_INIT_CVT (float, __builtin_inf (), int, __builtin_irintf (__builtin_inff 
()), 19)
+TEST_INIT_CVT (float, -__builtin_inf (), int, __builtin_irintf 
(-__builtin_inff ()), 20)
+TEST_INIT_CVT (float, __builtin_nanf (""), int, 0x7fffffff, 21)
+
+int
+main ()
+{
+  RUN_TEST_CVT (float, int, 1, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 2, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 3, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 4, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 5, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 6, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 7, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 8, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 9, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 10, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 11, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 12, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 13, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 14, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 15, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 16, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 17, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 18, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 19, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 20, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int, 21, __builtin_irintf, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c
new file mode 100644
index 00000000000..113fffb47ff
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-0.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize 
-fno-vect-cost-model -ffast-math -fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include "test-math.h"
+
+/*
+** test_float_long___builtin_llrintf:
+**   ...
+**   vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+
+**   ...
+*/
+TEST_UNARY_CALL_CVT (float, long, __builtin_llrintf)
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c
new file mode 100644
index 00000000000..43bc0849695
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llrintf-run-0.c
@@ -0,0 +1,63 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model 
-ffast-math" } */
+
+#include "test-math.h"
+
+#define ARRAY_SIZE 128
+
+float in[ARRAY_SIZE];
+long out[ARRAY_SIZE];
+long ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf)
+TEST_ASSERT (long)
+
+TEST_INIT_CVT (float, 1.2, long, __builtin_lrintf (1.2), 1)
+TEST_INIT_CVT (float, -1.2, long, __builtin_lrintf (-1.2), 2)
+TEST_INIT_CVT (float, 0.5, long, __builtin_lrintf (0.5), 3)
+TEST_INIT_CVT (float, -0.5, long, __builtin_lrintf (-0.5), 4)
+TEST_INIT_CVT (float, 0.1, long, __builtin_lrintf (0.1), 5)
+TEST_INIT_CVT (float, -0.1, long, __builtin_lrintf (-0.1), 6)
+TEST_INIT_CVT (float, 3.0, long, __builtin_lrintf (3.0), 7)
+TEST_INIT_CVT (float, -3.0, long, __builtin_lrintf (-3.0), 8)
+TEST_INIT_CVT (float, 4503599627370495.5, long, __builtin_lrintf 
(4503599627370495.5), 9)
+TEST_INIT_CVT (float, 4503599627370497.0, long, __builtin_lrintf 
(4503599627370497.0), 10)
+TEST_INIT_CVT (float, -4503599627370495.5, long, __builtin_lrintf 
(-4503599627370495.5), 11)
+TEST_INIT_CVT (float, -4503599627370496.0, long, __builtin_lrintf 
(-4503599627370496.0), 12)
+TEST_INIT_CVT (float, 0.0, long, __builtin_lrintf (-0.0), 13)
+TEST_INIT_CVT (float, -0.0, long, __builtin_lrintf (-0.0), 14)
+TEST_INIT_CVT (float, 9223372036854774784.0, long, __builtin_lrintf 
(9223372036854774784.0), 15)
+TEST_INIT_CVT (float, 9223372036854775808.0, long, __builtin_lrintf 
(9223372036854775808.0), 16)
+TEST_INIT_CVT (float, -9223372036854775808.0, long, __builtin_lrintf 
(-9223372036854775808.0), 17)
+TEST_INIT_CVT (float, -9223372036854777856.0, long, __builtin_lrintf 
(-9223372036854777856.0), 18)
+TEST_INIT_CVT (float, __builtin_inf (), long, __builtin_lrintf (__builtin_inf 
()), 19)
+TEST_INIT_CVT (float, -__builtin_inf (), long, __builtin_lrintf 
(-__builtin_inf ()), 20)
+TEST_INIT_CVT (float, __builtin_nan (""), long, 0x7fffffffffffffff, 21)
+
+int
+main ()
+{
+  RUN_TEST_CVT (float, long, 1, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 2, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 3, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 4, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 5, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 6, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 7, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 8, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 9, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 10, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 11, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 12, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 13, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 14, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 15, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 16, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 17, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 18, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 19, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 20, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 21, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c
new file mode 100644
index 00000000000..cac57877876
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-0.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32d -O3 -ftree-vectorize 
-fno-vect-cost-model -ffast-math -fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include "test-math.h"
+
+/*
+** test_double_long___builtin_lrint:
+**   ...
+**   vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+
+**   ...
+*/
+TEST_UNARY_CALL_CVT (double, long, __builtin_lrint)
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c
new file mode 100644
index 00000000000..c1c8cc32588
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrint-rv32-run-0.c
@@ -0,0 +1,63 @@
+/* { dg-do run { target { riscv_v && rv32 } } } */
+/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model 
-ffast-math" } */
+
+#include "test-math.h"
+
+#define ARRAY_SIZE 128
+
+float in[ARRAY_SIZE];
+long out[ARRAY_SIZE];
+long ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf)
+TEST_ASSERT (long)
+
+TEST_INIT_CVT (float, 1.2, long, __builtin_lrintf (1.2), 1)
+TEST_INIT_CVT (float, -1.2, long, __builtin_lrintf (-1.2), 2)
+TEST_INIT_CVT (float, 0.5, long, __builtin_lrintf (0.5), 3)
+TEST_INIT_CVT (float, -0.5, long, __builtin_lrintf (-0.5), 4)
+TEST_INIT_CVT (float, 0.1, long, __builtin_lrintf (0.1), 5)
+TEST_INIT_CVT (float, -0.1, long, __builtin_lrintf (-0.1), 6)
+TEST_INIT_CVT (float, 3.0, long, __builtin_lrintf (3.0), 7)
+TEST_INIT_CVT (float, -3.0, long, __builtin_lrintf (-3.0), 8)
+TEST_INIT_CVT (float, 4503599627370495.5, long, __builtin_lrintf 
(4503599627370495.5), 9)
+TEST_INIT_CVT (float, 4503599627370497.0, long, __builtin_lrintf 
(4503599627370497.0), 10)
+TEST_INIT_CVT (float, -4503599627370495.5, long, __builtin_lrintf 
(-4503599627370495.5), 11)
+TEST_INIT_CVT (float, -4503599627370496.0, long, __builtin_lrintf 
(-4503599627370496.0), 12)
+TEST_INIT_CVT (float, 0.0, long, __builtin_lrintf (-0.0), 13)
+TEST_INIT_CVT (float, -0.0, long, __builtin_lrintf (-0.0), 14)
+TEST_INIT_CVT (float, 9223372036854774784.0, long, __builtin_lrintf 
(9223372036854774784.0), 15)
+TEST_INIT_CVT (float, 9223372036854775808.0, long, __builtin_lrintf 
(9223372036854775808.0), 16)
+TEST_INIT_CVT (float, -9223372036854775808.0, long, __builtin_lrintf 
(-9223372036854775808.0), 17)
+TEST_INIT_CVT (float, -9223372036854777856.0, long, __builtin_lrintf 
(-9223372036854777856.0), 18)
+TEST_INIT_CVT (float, __builtin_inf (), long, __builtin_lrintf (__builtin_inf 
()), 19)
+TEST_INIT_CVT (float, -__builtin_inf (), long, __builtin_lrintf 
(-__builtin_inf ()), 20)
+TEST_INIT_CVT (float, __builtin_nan (""), long, 0x7fffffffffffffff, 21)
+
+int
+main ()
+{
+  RUN_TEST_CVT (float, long, 1, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 2, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 3, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 4, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 5, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 6, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 7, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 8, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 9, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 10, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 11, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 12, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 13, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 14, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 15, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 16, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 17, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 18, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 19, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 20, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 21, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c
new file mode 100644
index 00000000000..6e09472ebe7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-0.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize 
-fno-vect-cost-model -ffast-math -fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include "test-math.h"
+
+/*
+** test_float_long___builtin_lrintf:
+**   ...
+**   vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+
+**   ...
+*/
+TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf)
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c
new file mode 100644
index 00000000000..f5a9e01d0e8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lrintf-rv64-run-0.c
@@ -0,0 +1,63 @@
+/* { dg-do run { target { riscv_v && rv64 } } } */
+/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model 
-ffast-math" } */
+
+#include "test-math.h"
+
+#define ARRAY_SIZE 128
+
+float in[ARRAY_SIZE];
+long out[ARRAY_SIZE];
+long ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (float, long, __builtin_lrintf)
+TEST_ASSERT (long)
+
+TEST_INIT_CVT (float, 1.2, long, __builtin_lrintf (1.2), 1)
+TEST_INIT_CVT (float, -1.2, long, __builtin_lrintf (-1.2), 2)
+TEST_INIT_CVT (float, 0.5, long, __builtin_lrintf (0.5), 3)
+TEST_INIT_CVT (float, -0.5, long, __builtin_lrintf (-0.5), 4)
+TEST_INIT_CVT (float, 0.1, long, __builtin_lrintf (0.1), 5)
+TEST_INIT_CVT (float, -0.1, long, __builtin_lrintf (-0.1), 6)
+TEST_INIT_CVT (float, 3.0, long, __builtin_lrintf (3.0), 7)
+TEST_INIT_CVT (float, -3.0, long, __builtin_lrintf (-3.0), 8)
+TEST_INIT_CVT (float, 4503599627370495.5, long, __builtin_lrintf 
(4503599627370495.5), 9)
+TEST_INIT_CVT (float, 4503599627370497.0, long, __builtin_lrintf 
(4503599627370497.0), 10)
+TEST_INIT_CVT (float, -4503599627370495.5, long, __builtin_lrintf 
(-4503599627370495.5), 11)
+TEST_INIT_CVT (float, -4503599627370496.0, long, __builtin_lrintf 
(-4503599627370496.0), 12)
+TEST_INIT_CVT (float, 0.0, long, __builtin_lrintf (-0.0), 13)
+TEST_INIT_CVT (float, -0.0, long, __builtin_lrintf (-0.0), 14)
+TEST_INIT_CVT (float, 9223372036854774784.0, long, __builtin_lrintf 
(9223372036854774784.0), 15)
+TEST_INIT_CVT (float, 9223372036854775808.0, long, __builtin_lrintf 
(9223372036854775808.0), 16)
+TEST_INIT_CVT (float, -9223372036854775808.0, long, __builtin_lrintf 
(-9223372036854775808.0), 17)
+TEST_INIT_CVT (float, -9223372036854777856.0, long, __builtin_lrintf 
(-9223372036854777856.0), 18)
+TEST_INIT_CVT (float, __builtin_inf (), long, __builtin_lrintf (__builtin_inf 
()), 19)
+TEST_INIT_CVT (float, -__builtin_inf (), long, __builtin_lrintf 
(-__builtin_inf ()), 20)
+TEST_INIT_CVT (float, __builtin_nan (""), long, 0x7fffffffffffffff, 21)
+
+int
+main ()
+{
+  RUN_TEST_CVT (float, long, 1, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 2, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 3, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 4, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 5, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 6, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 7, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 8, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 9, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 10, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 11, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 12, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 13, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 14, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 15, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 16, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 17, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 18, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 19, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 20, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, long, 21, __builtin_lrintf, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-irint-1.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-irint-1.c
new file mode 100644
index 00000000000..5447326b997
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-irint-1.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 
--param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (irint, 1, double, int, __builtin_irint)
+DEF_OP_V_CVT (irint, 2, double, int, __builtin_irint)
+DEF_OP_V_CVT (irint, 4, double, int, __builtin_irint)
+DEF_OP_V_CVT (irint, 8, double, int, __builtin_irint)
+DEF_OP_V_CVT (irint, 16, double, int, __builtin_irint)
+DEF_OP_V_CVT (irint, 32, double, int, __builtin_irint)
+DEF_OP_V_CVT (irint, 64, double, int, __builtin_irint)
+DEF_OP_V_CVT (irint, 128, double, int, __builtin_irint)
+DEF_OP_V_CVT (irint, 256, double, int, __builtin_irint)
+DEF_OP_V_CVT (irint, 512, double, int, __builtin_irint)
+
+/* { dg-final { scan-assembler-not {csrr} } } */
+/* { dg-final { scan-tree-dump-not "1,1" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2,2" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4,4" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "16,16" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "32,32" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "64,64" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "128,128" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "256,256" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "512,512" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "1024,1024" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2048,2048" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4096,4096" "optimized" } } */
+/* { dg-final { scan-assembler-times {vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+} 9 
} } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c
new file mode 100644
index 00000000000..9445f5df60e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llrintf-0.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 
--param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (llrintf, 1, float, long, __builtin_llrintf)
+DEF_OP_V_CVT (llrintf, 2, float, long, __builtin_llrintf)
+DEF_OP_V_CVT (llrintf, 4, float, long, __builtin_llrintf)
+DEF_OP_V_CVT (llrintf, 8, float, long, __builtin_llrintf)
+DEF_OP_V_CVT (llrintf, 16, float, long, __builtin_llrintf)
+DEF_OP_V_CVT (llrintf, 32, float, long, __builtin_llrintf)
+DEF_OP_V_CVT (llrintf, 64, float, long, __builtin_llrintf)
+DEF_OP_V_CVT (llrintf, 128, float, long, __builtin_llrintf)
+DEF_OP_V_CVT (llrintf, 256, float, long, __builtin_llrintf)
+DEF_OP_V_CVT (llrintf, 512, float, long, __builtin_llrintf)
+
+/* { dg-final { scan-assembler-not {csrr} } } */
+/* { dg-final { scan-tree-dump-not "1,1" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2,2" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4,4" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "16,16" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "32,32" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "64,64" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "128,128" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "256,256" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "512,512" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "1024,1024" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2048,2048" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4096,4096" "optimized" } } */
+/* { dg-final { scan-assembler-times {vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 9 
} } */
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c
new file mode 100644
index 00000000000..61563e47aa0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrint-rv32-0.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv_zvfh_zvl4096b -mabi=ilp32d -O3 
--param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (lrint, 1, double, long, __builtin_lrint)
+DEF_OP_V_CVT (lrint, 2, double, long, __builtin_lrint)
+DEF_OP_V_CVT (lrint, 4, double, long, __builtin_lrint)
+DEF_OP_V_CVT (lrint, 8, double, long, __builtin_lrint)
+DEF_OP_V_CVT (lrint, 16, double, long, __builtin_lrint)
+DEF_OP_V_CVT (lrint, 32, double, long, __builtin_lrint)
+DEF_OP_V_CVT (lrint, 64, double, long, __builtin_lrint)
+DEF_OP_V_CVT (lrint, 128, double, long, __builtin_lrint)
+DEF_OP_V_CVT (lrint, 256, double, long, __builtin_lrint)
+DEF_OP_V_CVT (lrint, 512, double, long, __builtin_lrint)
+
+/* { dg-final { scan-assembler-not {csrr} } } */
+/* { dg-final { scan-tree-dump-not "1,1" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2,2" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4,4" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "16,16" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "32,32" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "64,64" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "128,128" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "256,256" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "512,512" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "1024,1024" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2048,2048" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4096,4096" "optimized" } } */
+/* { dg-final { scan-assembler-times {vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+} 9 
} } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c
new file mode 100644
index 00000000000..b095ff280ad
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lrintf-rv64-0.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvfh_zvl4096b -mabi=lp64d -O3 
--param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (lrintf, 1, float, long, __builtin_lrintf)
+DEF_OP_V_CVT (lrintf, 2, float, long, __builtin_lrintf)
+DEF_OP_V_CVT (lrintf, 4, float, long, __builtin_lrintf)
+DEF_OP_V_CVT (lrintf, 8, float, long, __builtin_lrintf)
+DEF_OP_V_CVT (lrintf, 16, float, long, __builtin_lrintf)
+DEF_OP_V_CVT (lrintf, 32, float, long, __builtin_lrintf)
+DEF_OP_V_CVT (lrintf, 64, float, long, __builtin_lrintf)
+DEF_OP_V_CVT (lrintf, 128, float, long, __builtin_lrintf)
+DEF_OP_V_CVT (lrintf, 256, float, long, __builtin_lrintf)
+DEF_OP_V_CVT (lrintf, 512, float, long, __builtin_lrintf)
+
+/* { dg-final { scan-assembler-not {csrr} } } */
+/* { dg-final { scan-tree-dump-not "1,1" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2,2" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4,4" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "16,16" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "32,32" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "64,64" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "128,128" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "256,256" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "512,512" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "1024,1024" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "2048,2048" "optimized" } } */
+/* { dg-final { scan-tree-dump-not "4096,4096" "optimized" } } */
+/* { dg-final { scan-assembler-times {vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 9 
} } */
-- 
2.34.1


Reply via email to