This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH]: Expand finite() as inline i386 asm
- From: Geert Bosch <bosch at adacore dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Uros Bizjak <ubizjak at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 1 Feb 2007 10:11:26 -0500
- Subject: Re: [PATCH]: Expand finite() as inline i386 asm
- References: <5787cf470701250731rb6cba27l360293b491b972a1@mail.gmail.com> <20070201005832.GA8302@redhat.com>
On Jan 31, 2007, at 19:58, Richard Henderson wrote:
Second, as I mentioned in the notes for PR 30652, I suspect
that using non-trapping comparisons will result in better
code than all these bit manipulations. I.e.
isfinite(d) => islessequal(fabs(d), DBL_MAX)
The 'Valid attribute in Ada (see s-fatgen.adb, function Valid)
does essentially the same in a target-independent way.
Also, by keeping the entire operation in the integer domain,
it avoids trapping on some architectures (e.g. MIPS).
It generates the following code for x86 (single):
_ada_is_valid:
.LFB4:
movl 4(%esp), %eax
andl $2139095040, %eax
cmpl $2139095040, %eax
setne %al
ret
for x86 double:
_ada_is_valid:
.LFB4:
subl $28, %esp
.LCFI0:
movl 36(%esp), %eax
andl $2146435072, %eax
shrl $20, %eax
cmpl $2047, %eax
setne %al
addl $28, %esp
ret
.LFE4:
(Of course the extra stack adjustments should have been optimized away)