[PATCH v2 01/10] LoongArch: Hard Float Support for functions {ll/l/ }rint{f/ }.

Xi Ruoyao xry111@xry111.site
Mon Nov 7 14:38:29 GMT 2022


On Mon, 2022-11-07 at 22:05 +0800, Xiaolin Tang wrote:

> +long long int
> +__llrint (double x)
> +{
> +  asm volatile ("frint.d \t%0, %1" : "=f" (x) : "f" (x));
> +  return x;
> +}

GCC trunk generates:

__llrint:
	frint.d 	$f0, $f0
	ftintrz.l.d $f0,$f0
	movfr2gr.d	$r4,$f0
	jr	$r1

It's not optimal.  The optimal way is:

__llrint:
	ftint.l.d 	$f0, $f0
	movfr2gr.d	$r4,$f0
	jr	$r1

I have a GCC patch to expand __builtin_llrint to ftint.l.d and
movgr2fr.d (with -fno-math-errno, which is enabled by Glibc building
system).

But I need some time to test my patch correctly: unfortunately I'm now
hitting some "random crashes" running Expect on LoongArch so I can't
complete GCC regression test.


More information about the Libc-alpha mailing list