From 920b72f4f6cccc3ca0bca203c8150cfcbe3a7daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Thomas?= Date: Sat, 29 Jun 2024 22:44:34 +0200 Subject: [PATCH] arm: Fix fma & fmaf implementations The vfma.f32|64 z, x, y instruction performs the operation z += x * y without intermediate rounding. The register used for z is both read and written by the instruction. The inline assembly must therefore use the "+" constraint modifier. --- newlib/libm/machine/arm/s_fma_arm.c | 2 +- newlib/libm/machine/arm/sf_fma_arm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/newlib/libm/machine/arm/s_fma_arm.c b/newlib/libm/machine/arm/s_fma_arm.c index f945419b56..6a2b403e1d 100644 --- a/newlib/libm/machine/arm/s_fma_arm.c +++ b/newlib/libm/machine/arm/s_fma_arm.c @@ -41,7 +41,7 @@ double fma (double x, double y, double z) { - asm ("vfma.f64 %P0, %P1, %P2" : "=w" (z) : "w" (x), "w" (y)); + asm ("vfma.f64 %P0, %P1, %P2" : "+w" (z) : "w" (x), "w" (y)); return z; } diff --git a/newlib/libm/machine/arm/sf_fma_arm.c b/newlib/libm/machine/arm/sf_fma_arm.c index 4befd90170..8d1b63d990 100644 --- a/newlib/libm/machine/arm/sf_fma_arm.c +++ b/newlib/libm/machine/arm/sf_fma_arm.c @@ -41,7 +41,7 @@ float fmaf (float x, float y, float z) { - asm ("vfma.f32 %0, %1, %2" : "=t" (z) : "t" (x), "t" (y)); + asm ("vfma.f32 %0, %1, %2" : "+t" (z) : "t" (x), "t" (y)); return z; }