From c5a4df30c6ff4d9ac53f869c4462f0688759957f Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 6 Dec 2022 11:53:20 +0000 Subject: [PATCH] risc-v: fix RVV backend on clang with undefined CV_RVV_SCALABLE - v_interleave_quads - v_pack_triplets - v_signmask --- .../include/opencv2/core/hal/intrin_rvv.hpp | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/core/include/opencv2/core/hal/intrin_rvv.hpp b/modules/core/include/opencv2/core/hal/intrin_rvv.hpp index a592976827..dca54a27d1 100644 --- a/modules/core/include/opencv2/core/hal/intrin_rvv.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_rvv.hpp @@ -2646,14 +2646,14 @@ inline v_##_Tpvec v_interleave_quads(const v_##_Tpvec& vec) \ v_store(ptrvec, vec); \ for (int i = 0; i < v_##_Tpvec::nlanes/8; i++) \ { \ - ptr[8*i ] = ptrvec[4*i ]; \ - ptr[8*i+1] = ptrvec[4*i+4]; \ - ptr[8*i+2] = ptrvec[4*i+1]; \ - ptr[8*i+3] = ptrvec[4*i+5]; \ - ptr[8*i+4] = ptrvec[4*i+2]; \ - ptr[8*i+5] = ptrvec[4*i+6]; \ - ptr[8*i+6] = ptrvec[4*i+3]; \ - ptr[8*i+7] = ptrvec[4*i+7]; \ + ptr[8*i ] = ptrvec[8*i ]; \ + ptr[8*i+1] = ptrvec[8*i+4]; \ + ptr[8*i+2] = ptrvec[8*i+1]; \ + ptr[8*i+3] = ptrvec[8*i+5]; \ + ptr[8*i+4] = ptrvec[8*i+2]; \ + ptr[8*i+5] = ptrvec[8*i+6]; \ + ptr[8*i+6] = ptrvec[8*i+3]; \ + ptr[8*i+7] = ptrvec[8*i+7]; \ } \ return v_load(ptr); \ } @@ -2753,7 +2753,7 @@ inline int v_signmask(const _Tpvec& a) \ { \ uint8_t ans[16] = {0};\ vsm(ans, vmslt(a, 0, vl), vl);\ - return reinterpret_cast(ans)[0];\ + return reinterpret_cast(ans)[0] & ((1 << (vl)) - 1);\ } OPENCV_HAL_IMPL_RVV_SIGNMASK_OP(v_int8x16, 8, 16) @@ -2810,7 +2810,7 @@ OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_float64x2, double, f64) #ifndef __clang__ inline v_int8x16 v_pack_triplets(const v_int8x16& vec) { - uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFF0F0E0D0C0A}; return v_int8x16((vint8m1_t)vrgather_vv_u8m1((vuint8m1_t)vint8m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16)); } inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) @@ -2820,7 +2820,7 @@ inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) inline v_int16x8 v_pack_triplets(const v_int16x8& vec) { - uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + uint64 ptr[2] = {0x0908050403020100, 0xFFFF0F0E0D0C0B0A}; return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)vint16m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16)); } inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) @@ -2836,7 +2836,7 @@ inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } inline v_int8x16 v_pack_triplets(const v_int8x16& vec) { - uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + uint64 ptr[2] = {0x0908060504020100, 0xFFFFFF0F0E0D0C0A}; return v_int8x16(vreinterpret_i8m1(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16))); } inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) @@ -2846,7 +2846,7 @@ inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) inline v_int16x8 v_pack_triplets(const v_int16x8& vec) { - uint64 ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + uint64 ptr[2] = {0x0908050403020100, 0xFFFF0F0E0D0C0B0A}; return v_int16x8(v_reinterpret_as_s16(v_uint8x16(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16)))); } inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec)