mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-20 11:11:24 +00:00
Add an irint() function in inline asm for amd64 and i386. irint() is
the same as lrint() except it returns int instead of long. Though the extern lrint() is fairly fast on these arches, it still takes about 12 cycles longer than the inline version, and 12 cycles is a lot in applications where [li]rint() is used to avoid slow conversions that are only a couple of times slower. This is only for internal use. The libm versions of *rint*() should also be inline, but that would take would take more header engineering. Implementing irint() instead of lrint() also avoids a conflict with the extern declaration of the latter.
This commit is contained in:
parent
f839bac29c
commit
0ddfa46b44
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=176462
@ -221,6 +221,36 @@ cpackl(long double x, long double y)
|
||||
}
|
||||
#endif /* _COMPLEX_H */
|
||||
|
||||
#ifdef __GNUCLIKE_ASM
|
||||
|
||||
/* Asm versions of some functions. */
|
||||
|
||||
#ifdef __amd64__
|
||||
static __inline int
|
||||
irint(double x)
|
||||
{
|
||||
int n;
|
||||
|
||||
asm("cvtsd2si %1,%0" : "=r" (n) : "Y" (x));
|
||||
return (n);
|
||||
}
|
||||
#define HAVE_EFFICIENT_IRINT
|
||||
#endif
|
||||
|
||||
#ifdef __i386__
|
||||
static __inline int
|
||||
irint(double x)
|
||||
{
|
||||
int n;
|
||||
|
||||
asm("fistl %0" : "=m" (n) : "t" (x));
|
||||
return (n);
|
||||
}
|
||||
#define HAVE_EFFICIENT_IRINT
|
||||
#endif
|
||||
|
||||
#endif /* __GNUCLIKE_ASM */
|
||||
|
||||
/*
|
||||
* ieee style elementary functions
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user