[Bug target/56944] Better isfinite in some cases?
glisse at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Apr 14 10:21:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56944
--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> 2013-04-14 10:21:53 UTC ---
Maybe in C terms:
isnan(x) -> x!=x
isinf(x) -> fabs(x)>DBL_MAX
isfinite(x) -> fabs(x)<=DBL_MAX
what I am suggesting (with -fno-trapping-math, and maybe -Os) is:
isfinite(x) -> !isnan(x-x)
but even without that, something like:
isfinite(x) -> x & mask1 != mask1 (or <) where mask1 is +inf
Since fabs(x) is implemented as x & mask2, this saves one constant, and it has
the nice advantage of forcing denormals to zero before the comparison, so the
running time of the function is the same for denormals instead of being 100
times longer. Note that writing a C program that convinces gcc to generate
exactly this code is very hard (even using intrinsics or inline asm, I
basically have to write the whole function in asm).
More information about the Gcc-bugs
mailing list