diff mbox series

[v1] RISC-V: Support FP rint to i/l/ll diff size autovec

Message ID 20231105093011.2038618-1-pan2.li@intel.com
State New
Headers show
Series [v1] RISC-V: Support FP rint to i/l/ll diff size autovec | expand

Commit Message

Li, Pan2 Nov. 5, 2023, 9:30 a.m. UTC
From: Pan Li <pan2.li@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.li@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

Comments

Li, Pan2 Nov. 5, 2023, 9:43 a.m. UTC | #1
Committed, thanks Juzhe.

Pan

From: juzhe.zhong <juzhe.zhong@rivai.ai>
Sent: Sunday, November 5, 2023 5:40 PM
To: Li, Pan2 <pan2.li@intel.com>
Cc: gcc-patches@gcc.gnu.org; Li, Pan2 <pan2.li@intel.com>; Wang, Yanzhang <yanzhang.wang@intel.com>; kito.cheng@gmail.com
Subject: Re: [PATCH v1] RISC-V: Support FP rint to i/l/ll diff size autovec

lgtm
---- Replied Message ----
From
pan2.li@intel.com<pan2.li@intel.com><mailto:pan2.li@intel.com>
Date
11/05/2023 17:30
To
gcc-patches@gcc.gnu.org<gcc-patches@gcc.gnu.org><mailto:gcc-patches@gcc.gnu.org>
Cc
juzhe.zhong@rivai.ai<juzhe.zhong@rivai.ai><mailto:juzhe.zhong@rivai.ai>,
pan2.li@intel.com<pan2.li@intel.com><mailto:pan2.li@intel.com>,
yanzhang.wang@intel.com<yanzhang.wang@intel.com><mailto:yanzhang.wang@intel.com>,
kito.cheng@gmail.com<kito.cheng@gmail.com><mailto:kito.cheng@gmail.com>
Subject
[PATCH v1] RISC-V: Support FP rint to i/l/ll diff size autovec
Patrick O'Neill Nov. 7, 2023, 7:17 p.m. UTC | #2
Hi Pan,

This patch (9acea4376fd98696ba51e59f417c94911a4d8248) causes|||cond_widen_reduc-2.c to start failing on: linux/newlib: rv32/64gc ||linux/newlib: ||rv32gcv ||linux/newlib: ||rv32/64gc|_zba_zbb_zbc_zbs|||FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
scan-assembler-times \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 
2 FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
scan-assembler-times \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3 
FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
scan-assembler-times \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 
3 Debug log output: spawn -ignore SIGHUP 
/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/xgcc 
-B/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/ 
/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
-march=rv32gcv -mabi=ilp32d -mcmodel=medlow -fdiagnostics-plain-output 
-ftree-vectorize -O2 --param riscv-autovec-lmul=dynamic 
-march=rv64gcv_zvfh_zvl128b -mabi=lp64d --param 
riscv-autovec-preference=scalable --param riscv-autovec-lmul=m2 
-fno-vect-cost-model -ffast-math -ffat-lto-objects -fno-ident -S -o 
cond_widen_reduc-2.s PASS: 
gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c (test for excess 
errors) gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: 
\\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times FAIL: 
gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
scan-assembler-times \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 
2 gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: 
\\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times FAIL: 
gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
scan-assembler-times \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3 
gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: 
\\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times FAIL: 
gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
scan-assembler-times \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 
3 Executing on host: 
/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/xgcc 
-B/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/ 
/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc_run-1.c 
-march=rv32gcv -mabi=ilp32d -mcmodel=medlow -fdiagnostics-plain-output 
-ftree-vectorize -O2 --param riscv-autovec-lmul=dynamic --param 
riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m2 
-fno-vect-cost-model -ffast-math -lm -o ./cond_widen_reduc_run-1.exe 
(timeout = 600) These failures are still on trunk 
(b7d05f13e86bf49bfb78c9876deba388efc6082e). Thanks, Patrick Postcommit 
CI bisection: https://github.com/patrick-rivos/gcc-postcommit-ci/issues/130 |

On 11/5/23 01:30,pan2.li@intel.com  wrote:

> From: Pan Li<pan2.li@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.li@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 } } */
Patrick O'Neill Nov. 7, 2023, 7:21 p.m. UTC | #3
Ah sorry for the noise - I just saw that this was resolved with a 
subsequent patch:

Precommit run: 
https://github.com/ewlu/gcc-precommit-ci/issues/608#issuecomment-1798058721

Patrick

On 11/7/23 11:17, Patrick O'Neill wrote:
> Hi Pan,
>
> This patch (9acea4376fd98696ba51e59f417c94911a4d8248) causes|||cond_widen_reduc-2.c to start failing on: linux/newlib: rv32/64gc ||linux/newlib: ||rv32gcv ||linux/newlib: ||rv32/64gc|_zba_zbb_zbc_zbs|||FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
> scan-assembler-times 
> \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 2 FAIL: 
> gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
> scan-assembler-times \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 
> 3 FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
> scan-assembler-times 
> \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3 Debug log output: 
> spawn -ignore SIGHUP 
> /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/xgcc 
> -B/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/ 
> /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
> -march=rv32gcv -mabi=ilp32d -mcmodel=medlow -fdiagnostics-plain-output 
> -ftree-vectorize -O2 --param riscv-autovec-lmul=dynamic 
> -march=rv64gcv_zvfh_zvl128b -mabi=lp64d --param 
> riscv-autovec-preference=scalable --param riscv-autovec-lmul=m2 
> -fno-vect-cost-model -ffast-math -ffat-lto-objects -fno-ident -S -o 
> cond_widen_reduc-2.s PASS: 
> gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c (test for 
> excess errors) gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: 
> \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times 
> FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
> scan-assembler-times 
> \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 2 
> gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: 
> \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times FAIL: 
> gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
> scan-assembler-times \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 
> 3 gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: 
> \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times FAIL: 
> gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c 
> scan-assembler-times 
> \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3 Executing on 
> host: 
> /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/xgcc 
> -B/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/ 
> /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc_run-1.c 
> -march=rv32gcv -mabi=ilp32d -mcmodel=medlow -fdiagnostics-plain-output 
> -ftree-vectorize -O2 --param riscv-autovec-lmul=dynamic --param 
> riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m2 
> -fno-vect-cost-model -ffast-math -lm -o ./cond_widen_reduc_run-1.exe 
> (timeout = 600) These failures are still on trunk 
> (b7d05f13e86bf49bfb78c9876deba388efc6082e). Thanks, Patrick Postcommit 
> CI bisection: 
> https://github.com/patrick-rivos/gcc-postcommit-ci/issues/130 |
> On 11/5/23 01:30,pan2.li@intel.com  wrote:
>> From: Pan Li<pan2.li@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.li@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 } } */
钟居哲 Nov. 7, 2023, 10:48 p.m. UTC | #4
Plz note those FAILs are not caused by this patch.
They are caused by this commit:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0c42741ad95af3a1e3ac07350da4c3a94865ed63 

It seems that precommit CI faild to locate the real root cause.



juzhe.zhong@rivai.ai
 
From: Patrick O'Neill
Date: 2023-11-08 03:21
To: pan2.li; gcc-patches
CC: juzhe.zhong; yanzhang.wang; kito.cheng
Subject: Re: [PATCH v1] RISC-V: Support FP rint to i/l/ll diff size autovec
Ah sorry for the noise - I just saw that this was resolved with a subsequent patch:

Precommit run: https://github.com/ewlu/gcc-precommit-ci/issues/608#issuecomment-1798058721

Patrick
On 11/7/23 11:17, Patrick O'Neill wrote:
Hi Pan,
This patch (9acea4376fd98696ba51e59f417c94911a4d8248) causes cond_widen_reduc-2.c to start failing on:
linux/newlib: rv32/64gc
linux/newlib: rv32gcv
linux/newlib: rv32/64gc_zba_zbb_zbc_zbs
FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c scan-assembler-times \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 2
FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c scan-assembler-times \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3
FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c scan-assembler-times \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3
Debug log output:
spawn -ignore SIGHUP /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/xgcc -B/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/ /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c -march=rv32gcv -mabi=ilp32d -mcmodel=medlow -fdiagnostics-plain-output -ftree-vectorize -O2 --param riscv-autovec-lmul=dynamic -march=rv64gcv_zvfh_zvl128b -mabi=lp64d --param riscv-autovec-preference=scalable --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math -ffat-lto-objects -fno-ident -S -o cond_widen_reduc-2.s
PASS: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c (test for excess errors)
gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times
FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c scan-assembler-times \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 2
gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times
FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c scan-assembler-times \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3
gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c: \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times
FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c scan-assembler-times \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3
Executing on host: /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/xgcc -B/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/  /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc_run-1.c  -march=rv32gcv -mabi=ilp32d -mcmodel=medlow   -fdiagnostics-plain-output   -ftree-vectorize -O2 --param riscv-autovec-lmul=dynamic --param riscv-autovec-preference=fixed-vlmax --param riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math      -lm  -o ./cond_widen_reduc_run-1.exe    (timeout = 600)
These failures are still on trunk (b7d05f13e86bf49bfb78c9876deba388efc6082e).
Thanks,
Patrick
Postcommit CI bisection: https://github.com/patrick-rivos/gcc-postcommit-ci/issues/130

On 11/5/23 01:30, pan2.li@intel.com wrote:
From: Pan Li <pan2.li@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.li@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 } } */
Patrick O'Neill Nov. 7, 2023, 11:28 p.m. UTC | #5
Thanks for pointing this out Juzhe, we're investigating how the CI got 
confused here. We'll let you know what we find out.

Patrick


On 11/7/23 14:48, 钟居哲 wrote:
> Plz note those FAILs are not caused by this patch.
> They are caused by this commit:
> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0c42741ad95af3a1e3ac07350da4c3a94865ed63
>
> It seems that precommit CI faild to locate the real root cause.
>
> ------------------------------------------------------------------------
> juzhe.zhong@rivai.ai
>
>     *From:* Patrick O'Neill <mailto:patrick@rivosinc.com>
>     *Date:* 2023-11-08 03:21
>     *To:* pan2.li <mailto:pan2.li@intel.com>; gcc-patches
>     <mailto:gcc-patches@gcc.gnu.org>
>     *CC:* juzhe.zhong <mailto:juzhe.zhong@rivai.ai>; yanzhang.wang
>     <mailto:yanzhang.wang@intel.com>; kito.cheng
>     <mailto:kito.cheng@gmail.com>
>     *Subject:* Re: [PATCH v1] RISC-V: Support FP rint to i/l/ll diff
>     size autovec
>
>     Ah sorry for the noise - I just saw that this was resolved with a
>     subsequent patch:
>
>     Precommit run:
>     https://github.com/ewlu/gcc-precommit-ci/issues/608#issuecomment-1798058721
>
>     Patrick
>
>     On 11/7/23 11:17, Patrick O'Neill wrote:
>>     Hi Pan,
>>     This patch (9acea4376fd98696ba51e59f417c94911a4d8248) causes|||cond_widen_reduc-2.c to start failing on: linux/newlib: rv32/64gc ||linux/newlib: ||rv32gcv ||linux/newlib: ||rv32/64gc|_zba_zbb_zbc_zbs|||FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c
>>     scan-assembler-times
>>     \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 2 FAIL:
>>     gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c
>>     scan-assembler-times
>>     \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3 FAIL:
>>     gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c
>>     scan-assembler-times
>>     \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3 Debug log
>>     output: spawn -ignore SIGHUP
>>     /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/xgcc
>>     -B/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/
>>     /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c
>>     -march=rv32gcv -mabi=ilp32d -mcmodel=medlow
>>     -fdiagnostics-plain-output -ftree-vectorize -O2 --param
>>     riscv-autovec-lmul=dynamic -march=rv64gcv_zvfh_zvl128b
>>     -mabi=lp64d --param riscv-autovec-preference=scalable --param
>>     riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math
>>     -ffat-lto-objects -fno-ident -S -o cond_widen_reduc-2.s PASS:
>>     gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c (test for
>>     excess errors)
>>     gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c:
>>     \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times
>>     FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c
>>     scan-assembler-times
>>     \\tvfwredusum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 2
>>     gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c:
>>     \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times
>>     FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c
>>     scan-assembler-times
>>     \\tvwredsum\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3
>>     gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c:
>>     \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t found 0 times
>>     FAIL: gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc-2.c
>>     scan-assembler-times
>>     \\tvwredsumu\\.vs\\tv[0-9]+,v[0-9]+,v[0-9]+,v0\\.t 3 Executing on
>>     host:
>>     /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/xgcc
>>     -B/github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/build/build-gcc-linux-stage2/gcc/
>>     /github/patrick-postcommit-runner-2/_work/gcc-postcommit-ci/gcc-postcommit-ci/riscv-gnu-toolchain/gcc/gcc/testsuite/gcc.target/riscv/rvv/autovec/cond/cond_widen_reduc_run-1.c
>>     -march=rv32gcv -mabi=ilp32d -mcmodel=medlow
>>     -fdiagnostics-plain-output -ftree-vectorize -O2 --param
>>     riscv-autovec-lmul=dynamic --param
>>     riscv-autovec-preference=fixed-vlmax --param
>>     riscv-autovec-lmul=m2 -fno-vect-cost-model -ffast-math -lm -o
>>     ./cond_widen_reduc_run-1.exe (timeout = 600) These failures are
>>     still on trunk (b7d05f13e86bf49bfb78c9876deba388efc6082e).
>>     Thanks, Patrick Postcommit CI bisection:
>>     https://github.com/patrick-rivos/gcc-postcommit-ci/issues/130 |
>>     On 11/5/23 01:30,pan2.li@intel.com  wrote:
>>>     From: Pan Li<pan2.li@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.li@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 } } */
>
diff mbox series

Patch

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 } } */