Skip to content

Commit

Permalink
arm: Fix fma & fmaf implementations
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mickael9 authored and Richard Earnshaw committed Jul 1, 2024
1 parent c4fb5da commit 920b72f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion newlib/libm/machine/arm/s_fma_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion newlib/libm/machine/arm/sf_fma_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 920b72f

Please sign in to comment.