From 08d94ddd3025811b23a98e2bf8c2bce11f7a675d Mon Sep 17 00:00:00 2001 From: Jan Blaesi Date: Sat, 1 Aug 2026 22:05:16 +0200 Subject: [PATCH] implement psf_lrint and psf_lrintf using arm neon intrinsics --- src/common.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/common.h b/src/common.h index c5b7d90b..d599a3e9 100644 --- a/src/common.h +++ b/src/common.h @@ -36,6 +36,10 @@ # endif #endif +#if defined(__aarch64__) || defined(_M_ARM64) +# define HAVE_NEON_INTRINSICS +#endif + #ifdef HAVE_SSE2_INTRINSICS #ifdef HAVE_IMMINTRIN_H #include @@ -44,6 +48,10 @@ #endif #endif /* HAVE_SSE2_INTRINSICS */ +#if defined(HAVE_NEON_INTRINSICS) +#include +#endif /* HAVE_NEON_INTRINSICS */ + #include #ifdef HAVE_VISIBILITY @@ -214,6 +222,18 @@ psf_lrint (double x) return _mm_cvtsd_si32 (_mm_load_sd (&x)) ; } +#elif defined(HAVE_NEON_INTRINSICS) + +static inline int psf_lrintf (float x) +{ + return vcvts_s32_f32(x); +} /* psf_lrintf */ + +static inline int psf_lrint (double x) +{ + return (int) vcvtd_s64_f64(x); +} /* psf_lrint */ + #else static inline int psf_lrintf (float x)