[PATCH 2/2] MIPS: Hard-float rounding instructions support
Xi Ruoyao
xry111@xry111.site
Mon Dec 25 10:51:42 GMT 2023
On Mon, 2023-12-25 at 18:35 +0800, Junxian Zhu wrote:
/* snip */
> +/*
> + * ceil(x)
> + * Return x rounded toward -inf to integral value
> + * Method:
> + * Bit twiddling.
> + */
> +
> +#if ((__mips_fpr == 64) && (__mips_hard_float == 1) && ((__mips == 32 && __mips_isa_rev > 1) || __mips == 64))
> +#include <sys/regdef.h>
> +#include <sysdep.h>
> +#include <libm-alias-double.h>
> +
> +ENTRY(__ceil)
> + .set push
> + .set noreorder
> + .set noat
> +# $f0=ret, $f12=double, a0=int64/int32_h, a1=int32_l, a2=sign, a3=exp
> +#if __mips == 64
> + dmfc1 a0, $f12 # assign int64
> +#else
> + mfhc1 a0, $f12 # assign int64
> +#endif
> + cfc1 t0, $f26
> + ceil.l.d $f0, $f12
No, C23 does not allow this function to raise an INEXACT exception, but
ceil.l.d will do so.
Such optimizations should be performed in GCC which can be controlled by
the programmer with -std=c23 and/or -f[no-]fp-int-builtin-inexact, not
in Glibc where we cannot know if the programmer wants to deviate from
C23.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
More information about the Libc-alpha
mailing list