[PATCH] libm: riscv: Reduce sqrt and sqrtf function for code size

Kito Cheng kito.cheng@gmail.com
Mon May 19 07:03:59 GMT 2025


LGTM, thanks :)

On Wed, May 14, 2025 at 4:57 PM Songhe Zhu <zhusonghe@eswincomputing.com> wrote:
>
> From: zhusonghe <zhusonghe@eswincomputing.com>
>
> The merged below patch modifies the __ieee754_sqrtf and __ieee754_sqrt functions to use a shared implementation, replacing the original fsqrt.d[s] instruction usage.
>
> patch:https://sourceware.org/git/?p=newlib-cygwin.git;a=commit;h=d572c4482b473d7725be0f9380d4f5d8342e4390
>
> Signed-off-by: Songhe Zhu <zhusonghe@eswincomputing.com>
> ---
>  newlib/libm/machine/riscv/e_sqrt.c  | 1 +
>  newlib/libm/machine/riscv/ef_sqrt.c | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/newlib/libm/machine/riscv/e_sqrt.c b/newlib/libm/machine/riscv/e_sqrt.c
> index 0c5aaadf3..ba000d36c 100644
> --- a/newlib/libm/machine/riscv/e_sqrt.c
> +++ b/newlib/libm/machine/riscv/e_sqrt.c
> @@ -35,6 +35,7 @@
>
>  #include <math.h>
>  #include "math_config.h"
> +#include "riscv_math.h"
>
>  #if defined(__RISCV_HARD_FLOAT) && __RISCV_HARD_FLOAT >= 64
>
> diff --git a/newlib/libm/machine/riscv/ef_sqrt.c b/newlib/libm/machine/riscv/ef_sqrt.c
> index cc41813dd..fd7ab4b41 100644
> --- a/newlib/libm/machine/riscv/ef_sqrt.c
> +++ b/newlib/libm/machine/riscv/ef_sqrt.c
> @@ -35,6 +35,7 @@
>
>  #include <math.h>
>  #include "math_config.h"
> +#include "riscv_math.h"
>
>  #if defined(__RISCV_HARD_FLOAT) && __RISCV_HARD_FLOAT >= 32
>
> --
> 2.17.1
>


More information about the Newlib mailing list