From e237e8d7fb5d39d8666e29ae868177878c156c3e Mon Sep 17 00:00:00 2001 From: Mark Zhuang Date: Tue, 30 Sep 2025 09:41:30 +0800 Subject: [PATCH] RVV: Enable some function for intrinsic >= v1.0 According to README of rvv-intrinsic-doc, Clang 19 and GCC 14 supports the v1.0 version. But __riscv_v_intrinsic is 12000 on Clang 19, so need Clang >= 20 to test this patch. I test it with Clang 21. Change-Id: I0e75efcdab3e7bc0ce1acd19eca3568b47c84cbf Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/6995438 Reviewed-by: Justin Green Reviewed-by: Frank Barchard --- include/libyuv/row.h | 17 ++++++++++------- include/libyuv/scale_row.h | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/include/libyuv/row.h b/include/libyuv/row.h index d063ad5b7..68c66f751 100644 --- a/include/libyuv/row.h +++ b/include/libyuv/row.h @@ -823,7 +823,11 @@ extern "C" { #endif #if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector) -#if defined(__riscv_v_intrinsic) && __riscv_v_intrinsic > 11000 +#if defined(__riscv_v_intrinsic) && __riscv_v_intrinsic >= 100000 +// Since v1.0, vcreate intrinsic is introduced +#define LIBYUV_RVV_HAS_VCREATE +#endif +#if defined(__riscv_v_intrinsic) && __riscv_v_intrinsic >= 12000 // Since v0.12, TUPLE_TYPE is introduced for segment load and store. #define LIBYUV_RVV_HAS_TUPLE_TYPE // Since v0.12, VXRM(fixed-point rounding mode) is included in arguments of @@ -832,7 +836,6 @@ extern "C" { #endif #endif -// The following are available for RVV 1.2 #if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector) #define HAS_ABGRTOYJROW_RVV #define HAS_ABGRTOYROW_RVV @@ -858,10 +861,9 @@ extern "C" { #define HAS_SPLITRGBROW_RVV #define HAS_SPLITUVROW_RVV #define HAS_SPLITXRGBROW_RVV -#endif -// The following are available for RVV 1.1 -// TODO(fbarchard): Port to RVV 1.2 (tuple) +// The following are available for RVV v0.11 and RVV v1.0 +// TODO(fbarchard): Port to RVV v0.12 (tuple) // missing support for vcreate_v: // __riscv_vcreate_v_u16m2x2 // __riscv_vcreate_v_u16m2x4 @@ -872,8 +874,8 @@ extern "C" { // __riscv_vcreate_v_u8m2x3 // __riscv_vcreate_v_u8m2x4 // __riscv_vcreate_v_u8m4x2 -#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector) && \ - !defined(LIBYUV_RVV_HAS_TUPLE_TYPE) +#if !defined(LIBYUV_RVV_HAS_TUPLE_TYPE) || \ + (defined(LIBYUV_RVV_HAS_TUPLE_TYPE) && defined(LIBYUV_RVV_HAS_VCREATE)) #define HAS_AB64TOARGBROW_RVV #define HAS_AR64TOAB64ROW_RVV #define HAS_ARGBATTENUATEROW_RVV @@ -908,6 +910,7 @@ extern "C" { #define HAS_RGB24TOARGBROW_RVV #define HAS_RGBATOARGBROW_RVV #endif +#endif #if defined(_MSC_VER) && !defined(__CLR_VER) && !defined(__clang__) #if defined(VISUALC_HAS_AVX2) diff --git a/include/libyuv/scale_row.h b/include/libyuv/scale_row.h index 86efcbfca..16f626439 100644 --- a/include/libyuv/scale_row.h +++ b/include/libyuv/scale_row.h @@ -157,10 +157,11 @@ extern "C" { #define HAS_SCALEARGBROWDOWN2_RVV #endif -// The following are available on RVV 1.1 -// TODO: Port to RVV 1.2 #if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector) && \ - defined(__riscv_v_intrinsic) && __riscv_v_intrinsic == 11000 + defined(__riscv_v_intrinsic) +// The following are available on RVV v0.11 and RVV v1.0 +// TODO: Port to RVV v0.12 +#if __riscv_v_intrinsic == 11000 || __riscv_v_intrinsic >= 100000 #define HAS_SCALEROWDOWN34_0_BOX_RVV #define HAS_SCALEROWDOWN34_1_BOX_RVV #define HAS_SCALEROWDOWN38_2_BOX_RVV @@ -171,12 +172,7 @@ extern "C" { #define HAS_SCALEROWDOWN38_RVV #define HAS_SCALEROWUP2_BILINEAR_RVV #define HAS_SCALEROWUP2_LINEAR_RVV -#endif -// The following are available on RVV -#if !defined(LIBYUV_DISABLE_RVV) && defined(__riscv_vector) && \ - defined(__riscv_v_intrinsic) && __riscv_v_intrinsic == 11000 -#define HAS_SCALEARGBFILTERCOLS_RVV #define HAS_SCALEARGBROWDOWN2BOX_RVV #define HAS_SCALEARGBROWDOWN2LINEAR_RVV #define HAS_SCALEARGBROWDOWNEVENBOX_RVV @@ -194,6 +190,12 @@ extern "C" { #define HAS_SCALEUVROWDOWN2LINEAR_RVV #endif +// The following are available on RVV v0.11 +#if __riscv_v_intrinsic == 11000 +#define HAS_SCALEARGBFILTERCOLS_RVV +#endif +#endif + // Scale ARGB vertically with bilinear interpolation. void ScalePlaneVertical(int src_height, int dst_width,