[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
probably this is well-known, but for Sparc, gcc -O compiles a call to
the standard maths function fabs() as a fabss instruction (this works
for single or double precision). Nothing could be easier :).
The latest Solaris compilers (f95 at least) will convert the conditional
( (x) >= 0.0 ? (x) : -(x) ) to an fabss too.
eg. #define ATL_dabs(x) fabs(x)
>> From email@example.com Sun May 13 03:32:06 2001
>> My guess is that there are system-dependant ways to make fabs() one cycle
>> nonetheless, and I'm hoping some of you know or can easily discover them.
>> Anyway, I want to ask anyone who can figure out to do fabs() without an if
>> to post to the list. The solution can be as nonportable as you want;
>> I figure in-line assembler may be required, but hopefully it can be used
>> with a C macro. Here's an example macro for double precision:
>> #define ATL_dabs(x) ( (x) >= 0.0 ? (x) : -(x) )
>> If anyone can do it without the if, I think we can speedup quite a few
>> routines . . .
>> Any pointers appreciated,
- Re: abs()
- From: Camm Maguire <firstname.lastname@example.org>