From a00818047ff5671586c7b296cac6175b250f85d3 Mon Sep 17 00:00:00 2001 From: Liutong HAN Date: Tue, 11 Jul 2023 16:10:27 +0800 Subject: [PATCH] =?UTF-8?q?Add=20missing=20=E2=80=9Dv=5Fpopcount=E2=80=9C?= =?UTF-8?q?=20for=20RVV=20and=20enable=20tests.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/opencv2/core/hal/intrin_rvv_scalable.hpp | 9 +++++++++ modules/core/test/test_intrin_utils.hpp | 2 ++ 2 files changed, 11 insertions(+) diff --git a/modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp b/modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp index 60066ba04186..dab82489f83b 100644 --- a/modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp @@ -1651,6 +1651,10 @@ inline v_uint32 v_popcount(const v_uint32& a) { return v_hadd(v_hadd(v_popcount(vreinterpret_u8m1(a)))); } +inline v_uint64 v_popcount(const v_uint64& a) +{ + return v_hadd(v_hadd(v_hadd(v_popcount(vreinterpret_u8m1(a))))); +} inline v_uint8 v_popcount(const v_int8& a) { @@ -1664,6 +1668,11 @@ inline v_uint32 v_popcount(const v_int32& a) { return v_popcount(v_abs(a));\ } +inline v_uint64 v_popcount(const v_int64& a) +{ + // max(0 - a) is used, since v_abs does not support 64-bit integers. + return v_popcount(v_reinterpret_as_u64(vmax(a, v_sub(v_setzero_s64(), a), VTraits::vlanes()))); +} //////////// SignMask //////////// diff --git a/modules/core/test/test_intrin_utils.hpp b/modules/core/test/test_intrin_utils.hpp index 01ca50a26e61..481e6bb1f214 100644 --- a/modules/core/test/test_intrin_utils.hpp +++ b/modules/core/test/test_intrin_utils.hpp @@ -2048,6 +2048,7 @@ void test_hal_intrin_uint64() .test_rotate<0>().test_rotate<1>() .test_extract_n<0>().test_extract_n<1>() .test_extract_highest() + .test_popcount() //.test_broadcast_element<0>().test_broadcast_element<1>() ; } @@ -2069,6 +2070,7 @@ void test_hal_intrin_int64() .test_extract_highest() //.test_broadcast_element<0>().test_broadcast_element<1>() .test_cvt64_double() + .test_popcount() ; }