1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Merge pull request #28243 from pratham-mcw:cvfloor-neon-opt

core: add NEON support for cvFloor in fast_math.hpp #28243

- This PR adds NEON intrinsics-based implementation for the cvFloor function in fast_math.hpp for Windows-ARM64.
- Both float and double overloads now use NEON intrinsics for cvFloor Function.
- calchist and calchist1d function uses cvFloor function for its computations. 
- After adding these changes both functions showed improvement in performance.

**Performance Benchmarks:**
<img width="956" height="273" alt="image" src="https://github.com/user-attachments/assets/a00c98cd-d245-4d11-a9fd-361a3bd89f59" />

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
This commit is contained in:
pratham-mcw
2026-01-24 16:12:16 +05:30
committed by GitHub
parent 1d20b65f1f
commit b229f1efd3
@@ -237,6 +237,8 @@ CV_INLINE int cvFloor( double value )
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
return (int)__builtin_floor(value);
#elif defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
return (int)vcvtmd_s64_f64(value);
#elif defined __loongarch64
int i;
double tmp;
@@ -264,6 +266,8 @@ CV_INLINE int cvCeil( double value )
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
return (int)__builtin_ceil(value);
#elif defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
return (int)vcvtpd_s64_f64(value);
#elif defined __loongarch64
int i;
double tmp;
@@ -362,6 +366,8 @@ CV_INLINE int cvFloor( float value )
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
return (int)__builtin_floorf(value);
#elif defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
return (int)vcvtms_s32_f32(value);
#elif defined __loongarch__
int i;
float tmp;
@@ -389,6 +395,8 @@ CV_INLINE int cvCeil( float value )
#if defined CV__FASTMATH_ENABLE_GCC_MATH_BUILTINS || \
defined CV__FASTMATH_ENABLE_CLANG_MATH_BUILTINS
return (int)__builtin_ceilf(value);
#elif defined(_MSC_VER) && (defined(_M_ARM64) || defined(_M_ARM64EC))
return (int)vcvtps_s32_f32(value);
#elif defined __loongarch__
int i;
float tmp;