This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC] [BZ15384] Enchance finite and isfinite.
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Sun, 21 Apr 2013 15:07:33 +0200
- Subject: [RFC] [BZ15384] Enchance finite and isfinite.
Hi, on http://sourceware.org/bugzilla/show_bug.cgi?id=15384 is request
to improve finite.
I noticed that integer constants there are unnecessary, shift suffices.
However on x64 even gcc without optimizations expands finite to inline
version which is slower than my version(see benchmark).
I will fill this to gcc bugzilla.
A standard says that function finite returns nonzero value. Comment says
we need to return 1, is that necessary? If it is I could omit one shift.
Ondra
* sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c (__finite): Avoid
64bit constants
---
sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
index f25ede8..9632ec9 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
@@ -10,7 +10,7 @@
*/
/*
- * finite(x) returns 1 is x is finite, else 0;
+ * finite(x) returns nonzero value if is x is finite, else 0;
* no branching!
*/
@@ -21,9 +21,10 @@
int
__finite(double x)
{
- int64_t lx;
+ uint64_t lx;
EXTRACT_WORDS64(lx,x);
- return (int)((uint64_t)((lx&INT64_C(0x7fffffffffffffff))-INT64_C(0x7ff0000000000000))>>63);
+ lx = lx>>52;
+ return ((lx&127)+1)>>7;
}
hidden_def (__finite)
weak_alias (__finite, finite)
--
1.7.4.4