>From 693d5d07dba7a368979c69bf30674a9a272880ab Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Sat, 22 Sep 2018 18:47:27 +0000 Subject: [PATCH 3/5] arm: add single instruction fma vfma is available in vfpv4, feature test is __ARM_FEATURE_FMA && __ARM_FP&8 for double precision. __ARM_FP&8 is set if double precision fp instructions are available in the hardware and the float-abi allows it. Old compilers may not define it, but then __ARM_FEATURE_FMA won't be defined either. --- src/math/arm/fma.c | 15 +++++++++++++++ src/math/arm/fmaf.c | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/math/arm/fma.c create mode 100644 src/math/arm/fmaf.c diff --git a/src/math/arm/fma.c b/src/math/arm/fma.c new file mode 100644 index 00000000..3e52c45a --- /dev/null +++ b/src/math/arm/fma.c @@ -0,0 +1,15 @@ +#include + +#if __ARM_FEATURE_FMA && __ARM_FP&8 + +double fma(double x, double y, double z) +{ + __asm__ ("vfma.f64 %P0, %P1, %P2" : "+w"(z) : "w"(x), "w"(y)); + return z; +} + +#else + +#include "../fma.c" + +#endif diff --git a/src/math/arm/fmaf.c b/src/math/arm/fmaf.c new file mode 100644 index 00000000..54451c1f --- /dev/null +++ b/src/math/arm/fmaf.c @@ -0,0 +1,15 @@ +#include + +#if __ARM_FEATURE_FMA && __ARM_FP&4 && !BROKEN_VFP_ASM + +float fmaf(float x, float y, float z) +{ + __asm__ ("vfma.f32 %0, %1, %2" : "+t"(z) : "t"(x), "t"(y)); + return z; +} + +#else + +#include "../fmaf.c" + +#endif -- 2.18.0