From 059640b8beb83cbd08ae2afba20a4777f052cfd0 Mon Sep 17 00:00:00 2001 From: Oleksiy Yakovenko Date: Sat, 16 Nov 2024 18:26:32 +0100 Subject: [PATCH] neon64 implementation of ftoi --- include/deadbeef/fastftoi.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/deadbeef/fastftoi.h b/include/deadbeef/fastftoi.h index 32e8fe2482..e406771b81 100644 --- a/include/deadbeef/fastftoi.h +++ b/include/deadbeef/fastftoi.h @@ -157,6 +157,27 @@ static __inline void fpu_restore(fpu_control fpu){ #endif /* Special MSVC x64 implementation */ +#if defined(__aarch64__) + +# define FPU_CONTROL + +#include + +typedef int16_t fpu_control; + +static inline int ftoi(float f) { + float32x2_t fvec = vld1_f32(&f); + int32x2_t ivec = vcvt_s32_f32(fvec); + return vget_lane_s32(ivec, 0); +} + +static inline void fpu_setround(fpu_control *fpu){ +} + +static inline void fpu_restore(fpu_control fpu){ +} + +#endif /* If no special implementation was found for the current compiler / platform, use the default implementation here: */