Merge pull request #27575 from pratham-mcw:arm64-cvround-fast-math

core: add ARM64 NEON support for cvRound in fast_math.hpp
This commit is contained in:
Alexander Smorkalov 2025-07-28 12:46:58 +03:00 committed by GitHub
commit 8e20ec2f26
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -201,6 +201,10 @@ cvRound( double value )
{
#if defined CV_INLINE_ROUND_DBL
CV_INLINE_ROUND_DBL(value);
#elif defined _MSC_VER && defined _M_ARM64
float64x1_t v = vdup_n_f64(value);
int64x1_t r = vcvtn_s64_f64(v);
return static_cast<int>(vget_lane_s64(r, 0));
#elif ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __SSE2__)) && !defined(__CUDACC__)
__m128d t = _mm_set_sd( value );
return _mm_cvtsd_si32(t);
@ -323,6 +327,10 @@ CV_INLINE int cvRound(float value)
{
#if defined CV_INLINE_ROUND_FLT
CV_INLINE_ROUND_FLT(value);
#elif defined _MSC_VER && defined _M_ARM64
float32x2_t v = vdup_n_f32(value);
int32x2_t r = vcvtn_s32_f32(v);
return vget_lane_s32(r, 0);
#elif ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __SSE2__)) && !defined(__CUDACC__)
__m128 t = _mm_set_ss( value );
return _mm_cvtss_si32(t);