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
d3a4e4141f
commit
af1dfd5050
@ -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…
x
Reference in New Issue
Block a user