summaryrefslogtreecommitdiff
path: root/src/math/aarch64/fmaxf.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2017-03-19 05:26:45 +0100
committerRich Felker <dalias@aerifal.cx>2017-03-21 12:39:18 -0400
commit54807d47acecab778498ced88ce8f62bfa16e379 (patch)
tree2203cc44d6061f092dd104ef6f89d4f2ca9fa1d7 /src/math/aarch64/fmaxf.c
parentb6e1fe0d5e78dac647e85d49c2d537bb071ba49e (diff)
downloadmusl-54807d47acecab778498ced88ce8f62bfa16e379.tar.gz
musl-54807d47acecab778498ced88ce8f62bfa16e379.tar.bz2
musl-54807d47acecab778498ced88ce8f62bfa16e379.tar.xz
musl-54807d47acecab778498ced88ce8f62bfa16e379.zip
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.
Diffstat (limited to 'src/math/aarch64/fmaxf.c')
-rw-r--r--src/math/aarch64/fmaxf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/math/aarch64/fmaxf.c b/src/math/aarch64/fmaxf.c
new file mode 100644
index 00000000..ee5eac2d
--- /dev/null
+++ b/src/math/aarch64/fmaxf.c
@@ -0,0 +1,7 @@
+#include <math.h>
+
+float fmaxf(float x, float y)
+{
+ __asm__ ("fmaxnm %s0, %s1, %s2" : "=w"(x) : "w"(x), "w"(y));
+ return x;
+}