[PR] riscv: cpu: Check VLEN for RISCV_HWPROBE_IMA_V (PR #24231)

CheryDan via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <[email protected]>
PR #24231 opened by CheryDan
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24231
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24231.patch

# Require 128-bit VLEN for `RISCV_HWPROBE_IMA_V`

Add the existing `VLEN >= 128` check to the `RISCV_HWPROBE_IMA_V` detection path, keeping it consistent with the Zve-based path.

This prevents RVV CPU flags from being enabled on systems with a smaller VLEN.



>From ad45932f5b6a0b556163b6c3887a4b04fc7ed453 Mon Sep 17 00:00:00 2001
From: daichengrong <[email protected]>
Date: Fri, 21 Aug 2026 17:55:19 +0800
Subject: [PATCH] riscv: cpu: Check VLEN for RISCV_HWPROBE_IMA_V

Require ff_get_rv_vlenb() >= 16 when detecting the V extension through
RISCV_HWPROBE_IMA_V, matching the existing Zve detection path.

This keeps the minimum 128-bit VLEN requirement consistent across both
hwprobe paths.

Signed-off-by: daichengrong <[email protected]>
---
 libavutil/riscv/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavutil/riscv/cpu.c b/libavutil/riscv/cpu.c
index 481d63a39f..b1a2fc9c02 100644
--- a/libavutil/riscv/cpu.c
+++ b/libavutil/riscv/cpu.c
@@ -63,7 +63,8 @@ int ff_get_cpu_flags_riscv(void)
         if (pairs[0].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA)
             ret |= AV_CPU_FLAG_RVI;
 #ifdef RISCV_HWPROBE_IMA_V
-        if (pairs[1].value & RISCV_HWPROBE_IMA_V)
+        if ((pairs[1].value & RISCV_HWPROBE_IMA_V) &&
+                 ff_get_rv_vlenb() >= 16)
             ret |= AV_CPU_FLAG_RVV_I32 | AV_CPU_FLAG_RVV_I64
                  | AV_CPU_FLAG_RVV_F32 | AV_CPU_FLAG_RVV_F64;
 #ifdef RISCV_HWPROBE_EXT_ZVE32X
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.