Fast operations on floating point numbers?

Falk Hueffner falk.hueffner@student.uni-tuebingen.de
Thu Dec 4 14:34:00 GMT 2003


Martin Reinecke <martin@MPA-Garching.MPG.DE> writes:

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

a = -a should produce optimal code. If it doesn't, please file a bug
report. We should not need intrinsics for this.

> Similarly, there is the math library function ldexp(), which
> multiplies a double with a given power of two. For some reason it is
> extremely slow, but in principle it should just add a number to the
> exponent of the double (and do a few sanity checks).

gcc provides __builtin_ldexp for this. I don't know whether it is well
optimized, though. If it doesn't produce optimal code for your
platform, please file a bug report with the assembly you would like to
see for it.

-- 
	Falk



More information about the Gcc mailing list