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

Message ID 20231107064115.1848826-1-pan2.li@intel.com
State Unresolved
Headers
Series [v1] RISC-V: Support FP ceil to i/l/ll diff size autovec |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Li, Pan2 Nov. 7, 2023, 6:41 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     |
+---------+-----------+----------+
| iceil   | DF => SI  | DF => SI |
| iceilf  | -         | -        |
| lceil   | -         | DF => SI |
| lceilf  | SF => DI  | -        |
| llceil  | -         | -        |
| llceilf | SF => DI  | SF => DI |
+---------+-----------+----------+

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

Before this patch:
.L3:
  flw      fa0,0(s0)
  addi     s0,s0,4
  addi     s1,s1,8
  call     ceilf
  fcvt.l.s a5,fa0,rtz
  sd       a5,-8(s1)
  bne      s2,s0,.L3
  ld       ra,24(sp)
  ld       s0,16(sp)
  ld       s1,8(sp)
  ld       s2,0(sp)
  addi     sp,sp,32
  jr       ra

After this patch:
  fsrmi        3  // RUP mode
.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 lceil.l
	* config/riscv/riscv-v.cc (expand_vec_lceil):  Leverage
	emit_vec_rounding_to_integer for ceil.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c: New test.
	* gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c: New test.
	* gcc.target/riscv/rvv/autovec/vls/math-llceilf-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                   |  8 +-
 .../riscv/rvv/autovec/unop/math-iceil-1.c     | 18 ++++
 .../riscv/rvv/autovec/unop/math-iceil-run-1.c | 83 ++++++++++++++++++
 .../rvv/autovec/unop/math-lceil-rv32-0.c      | 18 ++++
 .../rvv/autovec/unop/math-lceil-rv32-run-0.c  | 83 ++++++++++++++++++
 .../rvv/autovec/unop/math-lceilf-rv64-0.c     | 18 ++++
 .../rvv/autovec/unop/math-lceilf-rv64-run-0.c | 84 +++++++++++++++++++
 .../riscv/rvv/autovec/unop/math-llceilf-0.c   | 19 +++++
 .../rvv/autovec/unop/math-llceilf-run-0.c     | 84 +++++++++++++++++++
 .../riscv/rvv/autovec/vls/math-iceil-1.c      | 27 ++++++
 .../riscv/rvv/autovec/vls/math-lceil-rv32-0.c | 27 ++++++
 .../rvv/autovec/vls/math-lceilf-rv64-0.c      | 27 ++++++
 .../riscv/rvv/autovec/vls/math-llceilf-0.c    | 27 ++++++
 14 files changed, 520 insertions(+), 9 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llceilf-0.c
  

Comments

juzhe.zhong@rivai.ai Nov. 7, 2023, 6:43 a.m. UTC | #1
OK



juzhe.zhong@rivai.ai
 
From: pan2.li
Date: 2023-11-07 14:41
To: gcc-patches
CC: juzhe.zhong; pan2.li; yanzhang.wang; kito.cheng
Subject: [PATCH v1] RISC-V: Support FP ceil to i/l/ll diff size autovec
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     |
+---------+-----------+----------+
| iceil   | DF => SI  | DF => SI |
| iceilf  | -         | -        |
| lceil   | -         | DF => SI |
| lceilf  | SF => DI  | -        |
| llceil  | -         | -        |
| llceilf | SF => DI  | SF => DI |
+---------+-----------+----------+
 
Given below code:
void
test_lceilf (long *out, float *in, unsigned count)
{
  for (unsigned i = 0; i < count; i++)
    out[i] = __builtin_lceilf (in[i]);
}
 
Before this patch:
.L3:
  flw      fa0,0(s0)
  addi     s0,s0,4
  addi     s1,s1,8
  call     ceilf
  fcvt.l.s a5,fa0,rtz
  sd       a5,-8(s1)
  bne      s2,s0,.L3
  ld       ra,24(sp)
  ld       s0,16(sp)
  ld       s1,8(sp)
  ld       s2,0(sp)
  addi     sp,sp,32
  jr       ra
 
After this patch:
  fsrmi        3  // RUP mode
.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 lceil.l
* config/riscv/riscv-v.cc (expand_vec_lceil):  Leverage
emit_vec_rounding_to_integer for ceil.
 
gcc/testsuite/ChangeLog:
 
* gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c: New test.
* gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c: New test.
* gcc.target/riscv/rvv/autovec/vls/math-llceilf-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                   |  8 +-
.../riscv/rvv/autovec/unop/math-iceil-1.c     | 18 ++++
.../riscv/rvv/autovec/unop/math-iceil-run-1.c | 83 ++++++++++++++++++
.../rvv/autovec/unop/math-lceil-rv32-0.c      | 18 ++++
.../rvv/autovec/unop/math-lceil-rv32-run-0.c  | 83 ++++++++++++++++++
.../rvv/autovec/unop/math-lceilf-rv64-0.c     | 18 ++++
.../rvv/autovec/unop/math-lceilf-rv64-run-0.c | 84 +++++++++++++++++++
.../riscv/rvv/autovec/unop/math-llceilf-0.c   | 19 +++++
.../rvv/autovec/unop/math-llceilf-run-0.c     | 84 +++++++++++++++++++
.../riscv/rvv/autovec/vls/math-iceil-1.c      | 27 ++++++
.../riscv/rvv/autovec/vls/math-lceil-rv32-0.c | 27 ++++++
.../rvv/autovec/vls/math-lceilf-rv64-0.c      | 27 ++++++
.../riscv/rvv/autovec/vls/math-llceilf-0.c    | 27 ++++++
14 files changed, 520 insertions(+), 9 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llceilf-0.c
 
diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md
index 5b5105f5b46..b59bb880a45 100644
--- a/gcc/config/riscv/autovec.md
+++ b/gcc/config/riscv/autovec.md
@@ -2466,8 +2466,7 @@ (define_expand "lround<mode><v_f2di_convert>2"
(define_expand "lceil<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_lceil (operands[0], operands[1], <MODE>mode, <V_F2SI_CONVERT>mode);
     DONE;
@@ -2477,8 +2476,7 @@ (define_expand "lceil<mode><v_f2si_convert>2"
(define_expand "lceil<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_lceil (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 4ad1b6df525..65a04c47ddf 100644
--- a/gcc/config/riscv/riscv-v.cc
+++ b/gcc/config/riscv/riscv-v.cc
@@ -4176,12 +4176,10 @@ expand_vec_lround (rtx op_0, rtx op_1, machine_mode vec_fp_mode,
void
expand_vec_lceil (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_RUP, vec_fp_mode);
+  emit_vec_rounding_to_integer (op_0, op_1, vec_fp_mode, vec_int_mode,
+ UNARY_OP_FRM_RUP);
}
void
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c
new file mode 100644
index 00000000000..c6a4b450245
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c
@@ -0,0 +1,18 @@
+/* { 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_iceil:
+**   frrm\s+[atx][0-9]+
+**   ...
+**   fsrmi\s+3
+**   ...
+**   vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+
+**   ...
+**   fsrm\s+[atx][0-9]+
+**   ret
+*/
+TEST_UNARY_CALL_CVT (double, int, __builtin_iceil)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c
new file mode 100644
index 00000000000..036734e1ac5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c
@@ -0,0 +1,83 @@
+/* { 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
+
+double in[ARRAY_SIZE];
+int out[ARRAY_SIZE];
+int ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (double, int, __builtin_iceil)
+TEST_ASSERT (int)
+
+TEST_INIT_CVT (double, 0.0, int, __builtin_iceil (-0.0), 1)
+TEST_INIT_CVT (double, -0.0, int, __builtin_iceil (-0.0), 2)
+TEST_INIT_CVT (double, 1.2, int, __builtin_iceil (1.2), 3)
+TEST_INIT_CVT (double, -1.2, int, __builtin_iceil (-1.2), 4)
+TEST_INIT_CVT (double, 1.5, int, __builtin_iceil (1.5), 5)
+TEST_INIT_CVT (double, -1.5, int, __builtin_iceil (-1.5), 6)
+TEST_INIT_CVT (double, 1.8, int, __builtin_iceil (1.8), 7)
+TEST_INIT_CVT (double, -1.8, int, __builtin_iceil (-1.8), 8)
+TEST_INIT_CVT (double, 0.2, int, __builtin_iceil (0.2), 9)
+TEST_INIT_CVT (double, -0.2, int, __builtin_iceil (-0.2), 10)
+TEST_INIT_CVT (double, 0.5, int, __builtin_iceil (0.5), 11)
+TEST_INIT_CVT (double, -0.5, int, __builtin_iceil (-0.5), 12)
+TEST_INIT_CVT (double, 0.8, int, __builtin_iceil (0.8), 13)
+TEST_INIT_CVT (double, -0.8, int, __builtin_iceil (-0.8), 14)
+TEST_INIT_CVT (double, 4.0, int, __builtin_iceil (4.0), 15)
+TEST_INIT_CVT (double, -4.0, int, __builtin_iceil (-4.0), 16)
+TEST_INIT_CVT (double, 4503599627370495.5, int, __builtin_iceil (4503599627370495.5), 17)
+TEST_INIT_CVT (double, 4503599627370497.0, int, __builtin_iceil (4503599627370497.0), 18)
+TEST_INIT_CVT (double, -4503599627370495.5, int, __builtin_iceil (-4503599627370495.5), 19)
+TEST_INIT_CVT (double, -4503599627370496.0, int, __builtin_iceil (-4503599627370496.0), 20)
+TEST_INIT_CVT (double, 2147483647.0, int, __builtin_iceil (2147483647.0), 21)
+TEST_INIT_CVT (double, -2147483648.0, int, __builtin_iceil (-2147483648.0), 22)
+TEST_INIT_CVT (double, 2147483647.0000002384185791, int, 0x7fffffff, 23)
+TEST_INIT_CVT (double, -2147483648.0000004768371582, int, __builtin_iceil (-2147483648.0000004768371582), 24)
+TEST_INIT_CVT (double, 9223372036854774784.0, int, __builtin_iceil (9223372036854774784.0), 25)
+TEST_INIT_CVT (double, 9223372036854775808.0, int, 0x7fffffff, 26)
+TEST_INIT_CVT (double, -9223372036854775808.0, int, __builtin_iceil (-9223372036854775808.0), 27)
+TEST_INIT_CVT (double, -9223372036854777856.0, int, 0x80000000, 28)
+TEST_INIT_CVT (double, __builtin_inf (), int, __builtin_iceil (__builtin_inf ()), 29)
+TEST_INIT_CVT (double, -__builtin_inf (), int, __builtin_iceil (-__builtin_inf ()), 30)
+TEST_INIT_CVT (double, __builtin_nan (""), int, 0x7fffffff, 31)
+
+int
+main ()
+{
+  RUN_TEST_CVT (double, int, 1, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 2, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 3, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 4, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 5, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 6, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 7, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 8, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 9, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 10, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 11, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 12, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 13, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 14, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 15, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 16, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 17, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 18, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 19, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 20, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 21, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 22, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 23, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 24, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 25, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 26, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 27, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 28, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 29, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 30, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 31, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c
new file mode 100644
index 00000000000..da103bde8bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c
@@ -0,0 +1,18 @@
+/* { 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_int___builtin_lceil:
+**   frrm\s+[atx][0-9]+
+**   ...
+**   fsrmi\s+3
+**   ...
+**   vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+
+**   ...
+**   fsrm\s+[atx][0-9]+
+**   ret
+*/
+TEST_UNARY_CALL_CVT (double, int, __builtin_lceil)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c
new file mode 100644
index 00000000000..93a705bf203
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c
@@ -0,0 +1,83 @@
+/* { 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
+
+double in[ARRAY_SIZE];
+long out[ARRAY_SIZE];
+long ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (double, long, __builtin_lceil)
+TEST_ASSERT (long)
+
+TEST_INIT_CVT (double, 0.0, long, __builtin_lceil (-0.0), 1)
+TEST_INIT_CVT (double, -0.0, long, __builtin_lceil (-0.0), 2)
+TEST_INIT_CVT (double, 1.2, long, __builtin_lceil (1.2), 3)
+TEST_INIT_CVT (double, -1.2, long, __builtin_lceil (-1.2), 4)
+TEST_INIT_CVT (double, 1.5, long, __builtin_lceil (1.5), 5)
+TEST_INIT_CVT (double, -1.5, long, __builtin_lceil (-1.5), 6)
+TEST_INIT_CVT (double, 1.8, long, __builtin_lceil (1.8), 7)
+TEST_INIT_CVT (double, -1.8, long, __builtin_lceil (-1.8), 8)
+TEST_INIT_CVT (double, 0.2, long, __builtin_lceil (0.2), 9)
+TEST_INIT_CVT (double, -0.2, long, __builtin_lceil (-0.2), 10)
+TEST_INIT_CVT (double, 0.5, long, __builtin_lceil (0.5), 11)
+TEST_INIT_CVT (double, -0.5, long, __builtin_lceil (-0.5), 12)
+TEST_INIT_CVT (double, 0.8, long, __builtin_lceil (0.8), 13)
+TEST_INIT_CVT (double, -0.8, long, __builtin_lceil (-0.8), 14)
+TEST_INIT_CVT (double, 4.0, long, __builtin_lceil (4.0), 15)
+TEST_INIT_CVT (double, -4.0, long, __builtin_lceil (-4.0), 16)
+TEST_INIT_CVT (double, 4503599627370495.5, long, __builtin_lceil (4503599627370495.5), 17)
+TEST_INIT_CVT (double, 4503599627370497.0, long, __builtin_lceil (4503599627370497.0), 18)
+TEST_INIT_CVT (double, -4503599627370495.5, long, __builtin_lceil (-4503599627370495.5), 19)
+TEST_INIT_CVT (double, -4503599627370496.0, long, __builtin_lceil (-4503599627370496.0), 20)
+TEST_INIT_CVT (double, 2147483647.0, long, __builtin_lceil (2147483647.0), 21)
+TEST_INIT_CVT (double, -2147483648.0, long, __builtin_lceil (-2147483648.0), 22)
+TEST_INIT_CVT (double, 2147483647.0000002384185791, long, 0x7fffffff, 23)
+TEST_INIT_CVT (double, -2147483648.0000004768371582, long, __builtin_lceil (-2147483648.0000004768371582), 24)
+TEST_INIT_CVT (double, 9223372036854774784.0, long, __builtin_lceil (9223372036854774784.0), 25)
+TEST_INIT_CVT (double, 9223372036854775808.0, long, 0x7fffffff, 26)
+TEST_INIT_CVT (double, -9223372036854775808.0, long, __builtin_lceil (-9223372036854775808.0), 27)
+TEST_INIT_CVT (double, -9223372036854777856.0, long, 0x80000000, 28)
+TEST_INIT_CVT (double, __builtin_inf (), long, __builtin_lceil (__builtin_inf ()), 29)
+TEST_INIT_CVT (double, -__builtin_inf (), long, __builtin_lceil (-__builtin_inf ()), 30)
+TEST_INIT_CVT (double, __builtin_nan (""), long, 0x7fffffff, 31)
+
+long
+main ()
+{
+  RUN_TEST_CVT (double, long, 1, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 2, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 3, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 4, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 5, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 6, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 7, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 8, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 9, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 10, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 11, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 12, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 13, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 14, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 15, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 16, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 17, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 18, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 19, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 20, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 21, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 22, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 23, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 24, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 25, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 26, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 27, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 28, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 29, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 30, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 31, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c
new file mode 100644
index 00000000000..46f3d77ef92
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c
@@ -0,0 +1,18 @@
+/* { 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_lceilf:
+**   frrm\s+[atx][0-9]+
+**   ...
+**   fsrmi\s+3
+**   ...
+**   vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+
+**   ...
+**   fsrm\s+[atx][0-9]+
+**   ret
+*/
+TEST_UNARY_CALL_CVT (float, long, __builtin_lceilf)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c
new file mode 100644
index 00000000000..87edef58c99
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c
@@ -0,0 +1,84 @@
+/* { dg-do run { target { riscv_v && rv64 } } } */
+/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */
+
+#include <stdint-gcc.h>
+#include "test-math.h"
+
+#define ARRAY_SIZE 128
+
+float in[ARRAY_SIZE];
+int64_t out[ARRAY_SIZE];
+int64_t ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (float, int64_t, __builtin_lceilf)
+TEST_ASSERT (int64_t)
+
+TEST_INIT_CVT (float, 0.0, int64_t, __builtin_lceilf (-0.0), 1)
+TEST_INIT_CVT (float, -0.0, int64_t, __builtin_lceilf (-0.0), 2)
+TEST_INIT_CVT (float, 1.2, int64_t, __builtin_lceilf (1.2), 3)
+TEST_INIT_CVT (float, -1.2, int64_t, __builtin_lceilf (-1.2), 4)
+TEST_INIT_CVT (float, 1.5, int64_t, __builtin_lceilf (1.5), 5)
+TEST_INIT_CVT (float, -1.5, int64_t, __builtin_lceilf (-1.5), 6)
+TEST_INIT_CVT (float, 1.8, int64_t, __builtin_lceilf (1.8), 7)
+TEST_INIT_CVT (float, -1.8, int64_t, __builtin_lceilf (-1.8), 8)
+TEST_INIT_CVT (float, 0.2, int64_t, __builtin_lceilf (0.2), 9)
+TEST_INIT_CVT (float, -0.2, int64_t, __builtin_lceilf (-0.2), 10)
+TEST_INIT_CVT (float, 0.5, int64_t, __builtin_lceilf (0.5), 11)
+TEST_INIT_CVT (float, -0.5, int64_t, __builtin_lceilf (-0.5), 12)
+TEST_INIT_CVT (float, 0.8, int64_t, __builtin_lceilf (0.8), 13)
+TEST_INIT_CVT (float, -0.8, int64_t, __builtin_lceilf (-0.8), 14)
+TEST_INIT_CVT (float, 4.0, int64_t, __builtin_lceilf (4.0), 15)
+TEST_INIT_CVT (float, -4.0, int64_t, __builtin_lceilf (-4.0), 16)
+TEST_INIT_CVT (float, 8388607.5, int64_t, __builtin_lceilf (8388607.5), 17)
+TEST_INIT_CVT (float, 8388609.0, int64_t, __builtin_lceilf (8388609.0), 18)
+TEST_INIT_CVT (float, -8388607.5, int64_t, __builtin_lceilf (-8388607.5), 19)
+TEST_INIT_CVT (float, -8388609.0, int64_t, __builtin_lceilf (-8388609.0), 20)
+TEST_INIT_CVT (float, 2147483520.0, int64_t, __builtin_lceilf (2147483520.0), 21)
+TEST_INIT_CVT (float, 2147483648.0, int64_t, __builtin_lceilf (2147483648.0), 22)
+TEST_INIT_CVT (float, -2147483648.0, int64_t, __builtin_lceilf (-2147483648.0), 23)
+TEST_INIT_CVT (float, -2147483904.0, int64_t, __builtin_lceilf (-2147483904.0), 24)
+TEST_INIT_CVT (float, 9223371487098961920.0, int64_t, __builtin_lceilf (9223371487098961920.0), 25)
+TEST_INIT_CVT (float, 9223372036854775808.0, int64_t, 0x7fffffffffffffff, 26)
+TEST_INIT_CVT (float, -9223372036854775808.0, int64_t, __builtin_lceilf (-9223372036854775808.0), 27)
+TEST_INIT_CVT (float, -9223373136366403584.0, int64_t, 0x8000000000000000, 28)
+TEST_INIT_CVT (float, __builtin_inf (), int64_t, __builtin_lceilf (__builtin_inf ()), 29)
+TEST_INIT_CVT (float, -__builtin_inf (), int64_t, __builtin_lceilf (-__builtin_inf ()), 30)
+TEST_INIT_CVT (float, __builtin_nan (""), int64_t, 0x7fffffffffffffff, 31)
+
+int64_t
+main ()
+{
+  RUN_TEST_CVT (float, int64_t, 1, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 2, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 3, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 4, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 5, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 6, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 7, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 8, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 9, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 10, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 11, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 12, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 13, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 14, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 15, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 16, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 17, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 18, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 19, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 20, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 21, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 22, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 23, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 24, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 25, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 26, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 27, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 28, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 29, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 30, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 31, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c
new file mode 100644
index 00000000000..1d22f81530f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c
@@ -0,0 +1,19 @@
+/* { 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 <stdint-gcc.h>
+#include "test-math.h"
+
+/*
+** test_float_int64_t___builtin_llceilf:
+**   frrm\s+[atx][0-9]+
+**   ...
+**   fsrmi\s+3
+**   ...
+**   vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+
+**   ...
+**   fsrm\s+[atx][0-9]+
+**   ret
+*/
+TEST_UNARY_CALL_CVT (float, int64_t, __builtin_llceilf)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c
new file mode 100644
index 00000000000..45a96203838
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c
@@ -0,0 +1,84 @@
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */
+
+#include <stdint-gcc.h>
+#include "test-math.h"
+
+#define ARRAY_SIZE 128
+
+float in[ARRAY_SIZE];
+int64_t out[ARRAY_SIZE];
+int64_t ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (float, int64_t, __builtin_llceilf)
+TEST_ASSERT (int64_t)
+
+TEST_INIT_CVT (float, 0.0, int64_t, __builtin_llceilf (-0.0), 1)
+TEST_INIT_CVT (float, -0.0, int64_t, __builtin_llceilf (-0.0), 2)
+TEST_INIT_CVT (float, 1.2, int64_t, __builtin_llceilf (1.2), 3)
+TEST_INIT_CVT (float, -1.2, int64_t, __builtin_llceilf (-1.2), 4)
+TEST_INIT_CVT (float, 1.5, int64_t, __builtin_llceilf (1.5), 5)
+TEST_INIT_CVT (float, -1.5, int64_t, __builtin_llceilf (-1.5), 6)
+TEST_INIT_CVT (float, 1.8, int64_t, __builtin_llceilf (1.8), 7)
+TEST_INIT_CVT (float, -1.8, int64_t, __builtin_llceilf (-1.8), 8)
+TEST_INIT_CVT (float, 0.2, int64_t, __builtin_llceilf (0.2), 9)
+TEST_INIT_CVT (float, -0.2, int64_t, __builtin_llceilf (-0.2), 10)
+TEST_INIT_CVT (float, 0.5, int64_t, __builtin_llceilf (0.5), 11)
+TEST_INIT_CVT (float, -0.5, int64_t, __builtin_llceilf (-0.5), 12)
+TEST_INIT_CVT (float, 0.8, int64_t, __builtin_llceilf (0.8), 13)
+TEST_INIT_CVT (float, -0.8, int64_t, __builtin_llceilf (-0.8), 14)
+TEST_INIT_CVT (float, 4.0, int64_t, __builtin_llceilf (4.0), 15)
+TEST_INIT_CVT (float, -4.0, int64_t, __builtin_llceilf (-4.0), 16)
+TEST_INIT_CVT (float, 8388607.5, int64_t, __builtin_llceilf (8388607.5), 17)
+TEST_INIT_CVT (float, 8388609.0, int64_t, __builtin_llceilf (8388609.0), 18)
+TEST_INIT_CVT (float, -8388607.5, int64_t, __builtin_llceilf (-8388607.5), 19)
+TEST_INIT_CVT (float, -8388609.0, int64_t, __builtin_llceilf (-8388609.0), 20)
+TEST_INIT_CVT (float, 2147483520.0, int64_t, __builtin_llceilf (2147483520.0), 21)
+TEST_INIT_CVT (float, 2147483648.0, int64_t, __builtin_llceilf (2147483648.0), 22)
+TEST_INIT_CVT (float, -2147483648.0, int64_t, __builtin_llceilf (-2147483648.0), 23)
+TEST_INIT_CVT (float, -2147483904.0, int64_t, __builtin_llceilf (-2147483904.0), 24)
+TEST_INIT_CVT (float, 9223371487098961920.0, int64_t, __builtin_llceilf (9223371487098961920.0), 25)
+TEST_INIT_CVT (float, 9223372036854775808.0, int64_t, 0x7fffffffffffffff, 26)
+TEST_INIT_CVT (float, -9223372036854775808.0, int64_t, __builtin_llceilf (-9223372036854775808.0), 27)
+TEST_INIT_CVT (float, -9223373136366403584.0, int64_t, 0x8000000000000000, 28)
+TEST_INIT_CVT (float, __builtin_inf (), int64_t, __builtin_llceilf (__builtin_inf ()), 29)
+TEST_INIT_CVT (float, -__builtin_inf (), int64_t, __builtin_llceilf (-__builtin_inf ()), 30)
+TEST_INIT_CVT (float, __builtin_nan (""), int64_t, 0x7fffffffffffffff, 31)
+
+int64_t
+main ()
+{
+  RUN_TEST_CVT (float, int64_t, 1, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 2, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 3, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 4, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 5, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 6, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 7, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 8, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 9, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 10, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 11, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 12, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 13, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 14, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 15, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 16, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 17, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 18, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 19, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 20, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 21, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 22, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 23, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 24, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 25, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 26, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 27, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 28, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 29, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 30, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 31, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c
new file mode 100644
index 00000000000..a2a2e2458d9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (iceil, 1, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 2, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 4, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 8, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 16, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 32, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 64, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 128, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 256, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 512, double, int, __builtin_iceil)
+
+/* { 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-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-lceil-rv32-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c
new file mode 100644
index 00000000000..94168c1201e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv_zvl4096b -mabi=ilp32d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (lceil, 1, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 2, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 4, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 8, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 16, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 32, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 64, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 128, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 256, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 512, double, int, __builtin_lceil)
+
+/* { 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-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-lceilf-rv64-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c
new file mode 100644
index 00000000000..12ac4e5ccd0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (lceilf, 1, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 2, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 4, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 8, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 16, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 32, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 64, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 128, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 256, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 512, float, long, __builtin_lceilf)
+
+/* { 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-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-llceilf-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llceilf-0.c
new file mode 100644
index 00000000000..09842c0fc8e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llceilf-0.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (llceilf, 1, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 2, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 4, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 8, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 16, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 32, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 64, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 128, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 256, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 512, float, int64_t, __builtin_llceilf)
+
+/* { 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-assembler-times {vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 9 } } */
-- 
2.34.1
  
Li, Pan2 Nov. 7, 2023, 6:51 a.m. UTC | #2
Committed, thanks Juzhe.

Pan

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

OK
  

Patch

diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md
index 5b5105f5b46..b59bb880a45 100644
--- a/gcc/config/riscv/autovec.md
+++ b/gcc/config/riscv/autovec.md
@@ -2466,8 +2466,7 @@  (define_expand "lround<mode><v_f2di_convert>2"
 (define_expand "lceil<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_lceil (operands[0], operands[1], <MODE>mode, <V_F2SI_CONVERT>mode);
     DONE;
@@ -2477,8 +2476,7 @@  (define_expand "lceil<mode><v_f2si_convert>2"
 (define_expand "lceil<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_lceil (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 4ad1b6df525..65a04c47ddf 100644
--- a/gcc/config/riscv/riscv-v.cc
+++ b/gcc/config/riscv/riscv-v.cc
@@ -4176,12 +4176,10 @@  expand_vec_lround (rtx op_0, rtx op_1, machine_mode vec_fp_mode,
 
 void
 expand_vec_lceil (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_RUP, vec_fp_mode);
+  emit_vec_rounding_to_integer (op_0, op_1, vec_fp_mode, vec_int_mode,
+				UNARY_OP_FRM_RUP);
 }
 
 void
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c
new file mode 100644
index 00000000000..c6a4b450245
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-1.c
@@ -0,0 +1,18 @@ 
+/* { 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_iceil:
+**   frrm\s+[atx][0-9]+
+**   ...
+**   fsrmi\s+3
+**   ...
+**   vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+
+**   ...
+**   fsrm\s+[atx][0-9]+
+**   ret
+*/
+TEST_UNARY_CALL_CVT (double, int, __builtin_iceil)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c
new file mode 100644
index 00000000000..036734e1ac5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-iceil-run-1.c
@@ -0,0 +1,83 @@ 
+/* { 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
+
+double in[ARRAY_SIZE];
+int out[ARRAY_SIZE];
+int ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (double, int, __builtin_iceil)
+TEST_ASSERT (int)
+
+TEST_INIT_CVT (double, 0.0, int, __builtin_iceil (-0.0), 1)
+TEST_INIT_CVT (double, -0.0, int, __builtin_iceil (-0.0), 2)
+TEST_INIT_CVT (double, 1.2, int, __builtin_iceil (1.2), 3)
+TEST_INIT_CVT (double, -1.2, int, __builtin_iceil (-1.2), 4)
+TEST_INIT_CVT (double, 1.5, int, __builtin_iceil (1.5), 5)
+TEST_INIT_CVT (double, -1.5, int, __builtin_iceil (-1.5), 6)
+TEST_INIT_CVT (double, 1.8, int, __builtin_iceil (1.8), 7)
+TEST_INIT_CVT (double, -1.8, int, __builtin_iceil (-1.8), 8)
+TEST_INIT_CVT (double, 0.2, int, __builtin_iceil (0.2), 9)
+TEST_INIT_CVT (double, -0.2, int, __builtin_iceil (-0.2), 10)
+TEST_INIT_CVT (double, 0.5, int, __builtin_iceil (0.5), 11)
+TEST_INIT_CVT (double, -0.5, int, __builtin_iceil (-0.5), 12)
+TEST_INIT_CVT (double, 0.8, int, __builtin_iceil (0.8), 13)
+TEST_INIT_CVT (double, -0.8, int, __builtin_iceil (-0.8), 14)
+TEST_INIT_CVT (double, 4.0, int, __builtin_iceil (4.0), 15)
+TEST_INIT_CVT (double, -4.0, int, __builtin_iceil (-4.0), 16)
+TEST_INIT_CVT (double, 4503599627370495.5, int, __builtin_iceil (4503599627370495.5), 17)
+TEST_INIT_CVT (double, 4503599627370497.0, int, __builtin_iceil (4503599627370497.0), 18)
+TEST_INIT_CVT (double, -4503599627370495.5, int, __builtin_iceil (-4503599627370495.5), 19)
+TEST_INIT_CVT (double, -4503599627370496.0, int, __builtin_iceil (-4503599627370496.0), 20)
+TEST_INIT_CVT (double, 2147483647.0, int, __builtin_iceil (2147483647.0), 21)
+TEST_INIT_CVT (double, -2147483648.0, int, __builtin_iceil (-2147483648.0), 22)
+TEST_INIT_CVT (double, 2147483647.0000002384185791, int, 0x7fffffff, 23)
+TEST_INIT_CVT (double, -2147483648.0000004768371582, int, __builtin_iceil (-2147483648.0000004768371582), 24)
+TEST_INIT_CVT (double, 9223372036854774784.0, int, __builtin_iceil (9223372036854774784.0), 25)
+TEST_INIT_CVT (double, 9223372036854775808.0, int, 0x7fffffff, 26)
+TEST_INIT_CVT (double, -9223372036854775808.0, int, __builtin_iceil (-9223372036854775808.0), 27)
+TEST_INIT_CVT (double, -9223372036854777856.0, int, 0x80000000, 28)
+TEST_INIT_CVT (double, __builtin_inf (), int, __builtin_iceil (__builtin_inf ()), 29)
+TEST_INIT_CVT (double, -__builtin_inf (), int, __builtin_iceil (-__builtin_inf ()), 30)
+TEST_INIT_CVT (double, __builtin_nan (""), int, 0x7fffffff, 31)
+
+int
+main ()
+{
+  RUN_TEST_CVT (double, int, 1, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 2, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 3, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 4, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 5, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 6, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 7, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 8, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 9, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 10, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 11, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 12, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 13, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 14, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 15, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 16, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 17, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 18, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 19, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 20, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 21, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 22, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 23, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 24, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 25, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 26, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 27, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 28, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 29, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 30, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, int, 31, __builtin_iceil, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c
new file mode 100644
index 00000000000..da103bde8bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-0.c
@@ -0,0 +1,18 @@ 
+/* { 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_int___builtin_lceil:
+**   frrm\s+[atx][0-9]+
+**   ...
+**   fsrmi\s+3
+**   ...
+**   vfncvt\.x\.f\.w\s+v[0-9]+,\s*v[0-9]+
+**   ...
+**   fsrm\s+[atx][0-9]+
+**   ret
+*/
+TEST_UNARY_CALL_CVT (double, int, __builtin_lceil)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c
new file mode 100644
index 00000000000..93a705bf203
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceil-rv32-run-0.c
@@ -0,0 +1,83 @@ 
+/* { 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
+
+double in[ARRAY_SIZE];
+long out[ARRAY_SIZE];
+long ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (double, long, __builtin_lceil)
+TEST_ASSERT (long)
+
+TEST_INIT_CVT (double, 0.0, long, __builtin_lceil (-0.0), 1)
+TEST_INIT_CVT (double, -0.0, long, __builtin_lceil (-0.0), 2)
+TEST_INIT_CVT (double, 1.2, long, __builtin_lceil (1.2), 3)
+TEST_INIT_CVT (double, -1.2, long, __builtin_lceil (-1.2), 4)
+TEST_INIT_CVT (double, 1.5, long, __builtin_lceil (1.5), 5)
+TEST_INIT_CVT (double, -1.5, long, __builtin_lceil (-1.5), 6)
+TEST_INIT_CVT (double, 1.8, long, __builtin_lceil (1.8), 7)
+TEST_INIT_CVT (double, -1.8, long, __builtin_lceil (-1.8), 8)
+TEST_INIT_CVT (double, 0.2, long, __builtin_lceil (0.2), 9)
+TEST_INIT_CVT (double, -0.2, long, __builtin_lceil (-0.2), 10)
+TEST_INIT_CVT (double, 0.5, long, __builtin_lceil (0.5), 11)
+TEST_INIT_CVT (double, -0.5, long, __builtin_lceil (-0.5), 12)
+TEST_INIT_CVT (double, 0.8, long, __builtin_lceil (0.8), 13)
+TEST_INIT_CVT (double, -0.8, long, __builtin_lceil (-0.8), 14)
+TEST_INIT_CVT (double, 4.0, long, __builtin_lceil (4.0), 15)
+TEST_INIT_CVT (double, -4.0, long, __builtin_lceil (-4.0), 16)
+TEST_INIT_CVT (double, 4503599627370495.5, long, __builtin_lceil (4503599627370495.5), 17)
+TEST_INIT_CVT (double, 4503599627370497.0, long, __builtin_lceil (4503599627370497.0), 18)
+TEST_INIT_CVT (double, -4503599627370495.5, long, __builtin_lceil (-4503599627370495.5), 19)
+TEST_INIT_CVT (double, -4503599627370496.0, long, __builtin_lceil (-4503599627370496.0), 20)
+TEST_INIT_CVT (double, 2147483647.0, long, __builtin_lceil (2147483647.0), 21)
+TEST_INIT_CVT (double, -2147483648.0, long, __builtin_lceil (-2147483648.0), 22)
+TEST_INIT_CVT (double, 2147483647.0000002384185791, long, 0x7fffffff, 23)
+TEST_INIT_CVT (double, -2147483648.0000004768371582, long, __builtin_lceil (-2147483648.0000004768371582), 24)
+TEST_INIT_CVT (double, 9223372036854774784.0, long, __builtin_lceil (9223372036854774784.0), 25)
+TEST_INIT_CVT (double, 9223372036854775808.0, long, 0x7fffffff, 26)
+TEST_INIT_CVT (double, -9223372036854775808.0, long, __builtin_lceil (-9223372036854775808.0), 27)
+TEST_INIT_CVT (double, -9223372036854777856.0, long, 0x80000000, 28)
+TEST_INIT_CVT (double, __builtin_inf (), long, __builtin_lceil (__builtin_inf ()), 29)
+TEST_INIT_CVT (double, -__builtin_inf (), long, __builtin_lceil (-__builtin_inf ()), 30)
+TEST_INIT_CVT (double, __builtin_nan (""), long, 0x7fffffff, 31)
+
+long
+main ()
+{
+  RUN_TEST_CVT (double, long, 1, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 2, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 3, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 4, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 5, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 6, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 7, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 8, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 9, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 10, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 11, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 12, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 13, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 14, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 15, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 16, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 17, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 18, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 19, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 20, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 21, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 22, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 23, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 24, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 25, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 26, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 27, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 28, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 29, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 30, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (double, long, 31, __builtin_lceil, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c
new file mode 100644
index 00000000000..46f3d77ef92
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-0.c
@@ -0,0 +1,18 @@ 
+/* { 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_lceilf:
+**   frrm\s+[atx][0-9]+
+**   ...
+**   fsrmi\s+3
+**   ...
+**   vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+
+**   ...
+**   fsrm\s+[atx][0-9]+
+**   ret
+*/
+TEST_UNARY_CALL_CVT (float, long, __builtin_lceilf)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c
new file mode 100644
index 00000000000..87edef58c99
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-lceilf-rv64-run-0.c
@@ -0,0 +1,84 @@ 
+/* { dg-do run { target { riscv_v && rv64 } } } */
+/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */
+
+#include <stdint-gcc.h>
+#include "test-math.h"
+
+#define ARRAY_SIZE 128
+
+float in[ARRAY_SIZE];
+int64_t out[ARRAY_SIZE];
+int64_t ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (float, int64_t, __builtin_lceilf)
+TEST_ASSERT (int64_t)
+
+TEST_INIT_CVT (float, 0.0, int64_t, __builtin_lceilf (-0.0), 1)
+TEST_INIT_CVT (float, -0.0, int64_t, __builtin_lceilf (-0.0), 2)
+TEST_INIT_CVT (float, 1.2, int64_t, __builtin_lceilf (1.2), 3)
+TEST_INIT_CVT (float, -1.2, int64_t, __builtin_lceilf (-1.2), 4)
+TEST_INIT_CVT (float, 1.5, int64_t, __builtin_lceilf (1.5), 5)
+TEST_INIT_CVT (float, -1.5, int64_t, __builtin_lceilf (-1.5), 6)
+TEST_INIT_CVT (float, 1.8, int64_t, __builtin_lceilf (1.8), 7)
+TEST_INIT_CVT (float, -1.8, int64_t, __builtin_lceilf (-1.8), 8)
+TEST_INIT_CVT (float, 0.2, int64_t, __builtin_lceilf (0.2), 9)
+TEST_INIT_CVT (float, -0.2, int64_t, __builtin_lceilf (-0.2), 10)
+TEST_INIT_CVT (float, 0.5, int64_t, __builtin_lceilf (0.5), 11)
+TEST_INIT_CVT (float, -0.5, int64_t, __builtin_lceilf (-0.5), 12)
+TEST_INIT_CVT (float, 0.8, int64_t, __builtin_lceilf (0.8), 13)
+TEST_INIT_CVT (float, -0.8, int64_t, __builtin_lceilf (-0.8), 14)
+TEST_INIT_CVT (float, 4.0, int64_t, __builtin_lceilf (4.0), 15)
+TEST_INIT_CVT (float, -4.0, int64_t, __builtin_lceilf (-4.0), 16)
+TEST_INIT_CVT (float, 8388607.5, int64_t, __builtin_lceilf (8388607.5), 17)
+TEST_INIT_CVT (float, 8388609.0, int64_t, __builtin_lceilf (8388609.0), 18)
+TEST_INIT_CVT (float, -8388607.5, int64_t, __builtin_lceilf (-8388607.5), 19)
+TEST_INIT_CVT (float, -8388609.0, int64_t, __builtin_lceilf (-8388609.0), 20)
+TEST_INIT_CVT (float, 2147483520.0, int64_t, __builtin_lceilf (2147483520.0), 21)
+TEST_INIT_CVT (float, 2147483648.0, int64_t, __builtin_lceilf (2147483648.0), 22)
+TEST_INIT_CVT (float, -2147483648.0, int64_t, __builtin_lceilf (-2147483648.0), 23)
+TEST_INIT_CVT (float, -2147483904.0, int64_t, __builtin_lceilf (-2147483904.0), 24)
+TEST_INIT_CVT (float, 9223371487098961920.0, int64_t, __builtin_lceilf (9223371487098961920.0), 25)
+TEST_INIT_CVT (float, 9223372036854775808.0, int64_t, 0x7fffffffffffffff, 26)
+TEST_INIT_CVT (float, -9223372036854775808.0, int64_t, __builtin_lceilf (-9223372036854775808.0), 27)
+TEST_INIT_CVT (float, -9223373136366403584.0, int64_t, 0x8000000000000000, 28)
+TEST_INIT_CVT (float, __builtin_inf (), int64_t, __builtin_lceilf (__builtin_inf ()), 29)
+TEST_INIT_CVT (float, -__builtin_inf (), int64_t, __builtin_lceilf (-__builtin_inf ()), 30)
+TEST_INIT_CVT (float, __builtin_nan (""), int64_t, 0x7fffffffffffffff, 31)
+
+int64_t
+main ()
+{
+  RUN_TEST_CVT (float, int64_t, 1, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 2, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 3, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 4, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 5, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 6, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 7, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 8, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 9, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 10, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 11, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 12, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 13, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 14, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 15, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 16, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 17, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 18, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 19, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 20, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 21, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 22, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 23, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 24, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 25, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 26, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 27, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 28, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 29, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 30, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 31, __builtin_lceilf, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c
new file mode 100644
index 00000000000..1d22f81530f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-0.c
@@ -0,0 +1,19 @@ 
+/* { 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 <stdint-gcc.h>
+#include "test-math.h"
+
+/*
+** test_float_int64_t___builtin_llceilf:
+**   frrm\s+[atx][0-9]+
+**   ...
+**   fsrmi\s+3
+**   ...
+**   vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+
+**   ...
+**   fsrm\s+[atx][0-9]+
+**   ret
+*/
+TEST_UNARY_CALL_CVT (float, int64_t, __builtin_llceilf)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c
new file mode 100644
index 00000000000..45a96203838
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/unop/math-llceilf-run-0.c
@@ -0,0 +1,84 @@ 
+/* { dg-do run { target { riscv_v } } } */
+/* { dg-additional-options "-std=c99 -O3 -ftree-vectorize -fno-vect-cost-model -ffast-math" } */
+
+#include <stdint-gcc.h>
+#include "test-math.h"
+
+#define ARRAY_SIZE 128
+
+float in[ARRAY_SIZE];
+int64_t out[ARRAY_SIZE];
+int64_t ref[ARRAY_SIZE];
+
+TEST_UNARY_CALL_CVT (float, int64_t, __builtin_llceilf)
+TEST_ASSERT (int64_t)
+
+TEST_INIT_CVT (float, 0.0, int64_t, __builtin_llceilf (-0.0), 1)
+TEST_INIT_CVT (float, -0.0, int64_t, __builtin_llceilf (-0.0), 2)
+TEST_INIT_CVT (float, 1.2, int64_t, __builtin_llceilf (1.2), 3)
+TEST_INIT_CVT (float, -1.2, int64_t, __builtin_llceilf (-1.2), 4)
+TEST_INIT_CVT (float, 1.5, int64_t, __builtin_llceilf (1.5), 5)
+TEST_INIT_CVT (float, -1.5, int64_t, __builtin_llceilf (-1.5), 6)
+TEST_INIT_CVT (float, 1.8, int64_t, __builtin_llceilf (1.8), 7)
+TEST_INIT_CVT (float, -1.8, int64_t, __builtin_llceilf (-1.8), 8)
+TEST_INIT_CVT (float, 0.2, int64_t, __builtin_llceilf (0.2), 9)
+TEST_INIT_CVT (float, -0.2, int64_t, __builtin_llceilf (-0.2), 10)
+TEST_INIT_CVT (float, 0.5, int64_t, __builtin_llceilf (0.5), 11)
+TEST_INIT_CVT (float, -0.5, int64_t, __builtin_llceilf (-0.5), 12)
+TEST_INIT_CVT (float, 0.8, int64_t, __builtin_llceilf (0.8), 13)
+TEST_INIT_CVT (float, -0.8, int64_t, __builtin_llceilf (-0.8), 14)
+TEST_INIT_CVT (float, 4.0, int64_t, __builtin_llceilf (4.0), 15)
+TEST_INIT_CVT (float, -4.0, int64_t, __builtin_llceilf (-4.0), 16)
+TEST_INIT_CVT (float, 8388607.5, int64_t, __builtin_llceilf (8388607.5), 17)
+TEST_INIT_CVT (float, 8388609.0, int64_t, __builtin_llceilf (8388609.0), 18)
+TEST_INIT_CVT (float, -8388607.5, int64_t, __builtin_llceilf (-8388607.5), 19)
+TEST_INIT_CVT (float, -8388609.0, int64_t, __builtin_llceilf (-8388609.0), 20)
+TEST_INIT_CVT (float, 2147483520.0, int64_t, __builtin_llceilf (2147483520.0), 21)
+TEST_INIT_CVT (float, 2147483648.0, int64_t, __builtin_llceilf (2147483648.0), 22)
+TEST_INIT_CVT (float, -2147483648.0, int64_t, __builtin_llceilf (-2147483648.0), 23)
+TEST_INIT_CVT (float, -2147483904.0, int64_t, __builtin_llceilf (-2147483904.0), 24)
+TEST_INIT_CVT (float, 9223371487098961920.0, int64_t, __builtin_llceilf (9223371487098961920.0), 25)
+TEST_INIT_CVT (float, 9223372036854775808.0, int64_t, 0x7fffffffffffffff, 26)
+TEST_INIT_CVT (float, -9223372036854775808.0, int64_t, __builtin_llceilf (-9223372036854775808.0), 27)
+TEST_INIT_CVT (float, -9223373136366403584.0, int64_t, 0x8000000000000000, 28)
+TEST_INIT_CVT (float, __builtin_inf (), int64_t, __builtin_llceilf (__builtin_inf ()), 29)
+TEST_INIT_CVT (float, -__builtin_inf (), int64_t, __builtin_llceilf (-__builtin_inf ()), 30)
+TEST_INIT_CVT (float, __builtin_nan (""), int64_t, 0x7fffffffffffffff, 31)
+
+int64_t
+main ()
+{
+  RUN_TEST_CVT (float, int64_t, 1, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 2, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 3, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 4, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 5, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 6, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 7, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 8, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 9, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 10, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 11, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 12, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 13, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 14, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 15, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 16, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 17, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 18, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 19, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 20, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 21, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 22, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 23, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 24, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 25, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 26, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 27, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 28, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 29, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 30, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+  RUN_TEST_CVT (float, int64_t, 31, __builtin_llceilf, in, out, ref, ARRAY_SIZE);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c
new file mode 100644
index 00000000000..a2a2e2458d9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-iceil-1.c
@@ -0,0 +1,27 @@ 
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (iceil, 1, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 2, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 4, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 8, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 16, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 32, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 64, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 128, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 256, double, int, __builtin_iceil)
+DEF_OP_V_CVT (iceil, 512, double, int, __builtin_iceil)
+
+/* { 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-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-lceil-rv32-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c
new file mode 100644
index 00000000000..94168c1201e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceil-rv32-0.c
@@ -0,0 +1,27 @@ 
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv_zvl4096b -mabi=ilp32d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (lceil, 1, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 2, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 4, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 8, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 16, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 32, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 64, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 128, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 256, double, int, __builtin_lceil)
+DEF_OP_V_CVT (lceil, 512, double, int, __builtin_lceil)
+
+/* { 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-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-lceilf-rv64-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c
new file mode 100644
index 00000000000..12ac4e5ccd0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-lceilf-rv64-0.c
@@ -0,0 +1,27 @@ 
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (lceilf, 1, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 2, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 4, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 8, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 16, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 32, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 64, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 128, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 256, float, long, __builtin_lceilf)
+DEF_OP_V_CVT (lceilf, 512, float, long, __builtin_lceilf)
+
+/* { 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-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-llceilf-0.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llceilf-0.c
new file mode 100644
index 00000000000..09842c0fc8e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vls/math-llceilf-0.c
@@ -0,0 +1,27 @@ 
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv_zvl4096b -mabi=lp64d -O3 --param=riscv-autovec-lmul=m8 -ffast-math -fdump-tree-optimized" } */
+
+#include "def.h"
+
+DEF_OP_V_CVT (llceilf, 1, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 2, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 4, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 8, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 16, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 32, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 64, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 128, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 256, float, int64_t, __builtin_llceilf)
+DEF_OP_V_CVT (llceilf, 512, float, int64_t, __builtin_llceilf)
+
+/* { 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-assembler-times {vfwcvt\.x\.f\.v\s+v[0-9]+,\s*v[0-9]+} 9 } } */