Fast operations on floating point numbers?

Davide Rossetti davide.rossetti@roma1.infn.it
Thu Dec 4 17:49:00 GMT 2003


Martin Reinecke wrote:

> Hi,
>
> I'm not completely sure whether this question belongs to a C/C++ 
> newsgroup,
> but it is probably compiler-specific, so I'm trying my luck here.
>
> I'm developing a numerical simulation code which contains operations
> like this one
>
> double a;
> int flipsign;
>
> [...]
>
> if (flipsign)
>   a = -a;
>
> in an inner loop which is executed billions of times.
> I suspect that the conditional slows the execution down,
> and the "a=-a" statement might not be optimal as well.

if you are on SSE2 platform (dunno if altivec...) and are using -mss2 
-fmpmath=sse
double is mapped onto SSE2 regs. in that case I seem to remember that 
the NEG operation is optimized as a SSE XOR. the bit which I do not know 
is if it is even able to use the SSE insn to generate masks to avoid 
jumps... hope so...




More information about the Gcc mailing list