Clean up roundtoint and converttoint
Ideally single instruction is used for rounding and conversion that round to the nearest integer independently of the current rounding mode, otherwise the argument reduction in expf is not reducing into the optimal range in non-nearest rounding mode. AArch64 has the necessary instructions, both for rounding ties away from zero (round function in C) and rounding ties to even (roundeven function in TS 18661), originally the later was used, but the former can be expressed in portable C code without relying on ACLE intrinsics. A bit of complication is that round and lround are not always inlined as a single instruction: - gcc inlines lround with -fno-math-errno, but fails to inline (long)round as a single instruction (at least up to gcc-8). - clang inlines (long)round, but not lround. Portable code is still better than relying on arm_neon.h, so use the round function when it works and keep the shift based rounding as fallback (which only gives precise results in nearest rounding mode, but is the optimal implementation for most targets). HAVE_FAST_ROUND and HAVE_FAST_LROUND are set based on preprocessor heuristics (user can override them with CFLAGS) for now, once there is a configure script we can detect these at configure time.
Loading
Please register or sign in to comment