Richard Henderson - Re: [PATCH]: Expand finite() as inline i386 asm (original) (raw)

This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

On Thu, Feb 01, 2007 at 10:11:26AM -0500, Geert Bosch wrote:

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).

islessequal is by definition non-trapping, in contrast to the <= operator. MIPS does in fact implement this operation via c.ule.[sd] instructions. Which, presumably, couldn't be emitted from Ada once upon a time.

The significant advantage of implementing these operations in the fpu (when possible), is that the value is usually already in the fpu, and so we avoid a costly transfer of the value into the general registers. Your x86 example is more or less the exception, because of passing parameters on the stack by default.

r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]