From 54807d47acecab778498ced88ce8f62bfa16e379 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sun, 19 Mar 2017 05:26:45 +0100 Subject: aarch64: add single instruction math functions this should increase performance and reduce code size on aarch64. the compiled code was checked against using __builtin_* instead of inline asm with gcc-6.2.0. lrint is two instructions. c with inline asm is used because it is safer than a pure asm implementation, this prevents ll{rint,round} to be an alias of l{rint,round} (because the types don't match) and depends on gcc style inline asm support. ceil, floor, round, trunc can either raise inexact on finite non-integer inputs or not raise any exceptions. the new implementation does not raise exceptions while the generic c code does. on aarch64, the underflow exception is signaled before rounding (ieee 754 allows both before and after rounding, but it must be consistent), the generic fma c code signals it after rounding so using single instruction fixes a slight conformance issue too. --- src/math/aarch64/rint.c | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/math/aarch64/rint.c (limited to 'src/math/aarch64/rint.c') diff --git a/src/math/aarch64/rint.c b/src/math/aarch64/rint.c new file mode 100644 index 00000000..45b194b5 --- /dev/null +++ b/src/math/aarch64/rint.c @@ -0,0 +1,7 @@ +#include + +double rint(double x) +{ + __asm__ ("frintx %d0, %d1" : "=w"(x) : "w"(x)); + return x; +} -- cgit v1.2.1