[PATCH 1/4] LoongArch: Optimize f{max,min}imum{,f}
Xi Ruoyao
xry111@xry111.site
Mon Feb 24 10:38:03 GMT 2025
On Mon, 2025-02-24 at 17:50 +0800, Xi Ruoyao wrote:
> diff --git a/sysdeps/loongarch/fpu/s_fmaximum.c
> b/sysdeps/loongarch/fpu/s_fmaximum.c
> index 07fc7214a1..b66360a948 100644
> --- a/sysdeps/loongarch/fpu/s_fmaximum.c
> +++ b/sysdeps/loongarch/fpu/s_fmaximum.c
> @@ -24,17 +24,10 @@
> double
> __fmaximum (double x, double y)
> {
> - int x_cond;
> - int y_cond;
> - asm volatile ("fclass.d \t%0, %1" : "=f" (x_cond) : "f" (x));
> - asm volatile ("fclass.d \t%0, %1" : "=f" (y_cond) : "f" (y));
> + double a = __builtin_isnan (y) ? y : x;
> + double b = __builtin_isnan (x) ? x : y;
This is not future-proof: it may be broken when GCC developers fix
https://gcc.gnu.org/PR66462.
I'll make V2 to use inline assembly for this instead.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the Libc-alpha
mailing list