This is the mail archive of the gcc@gcc.gnu.org mailing 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]

Re: Fast operations on floating point numbers?


On Thu, Dec 04, 2003 at 03:22:31PM +0100, Martin Reinecke wrote:
> Peter Barada wrote:
> 
> > If flipsign is only refered to inside the(hevily executed) loop, you
> > could try:
> > 
> > double a, flip;
> > int flipsign;
> > 
> > flip = flipsign ? -1.0 : 1.0;
> > 
> > for (;;) {
> >   ...
> >   a *= flip;
> >   ...
> > }
> > 
> > And get rid of the conditional...
> 
> Unfortunately this does not work in all places where I have this
> problem. But even where I can use it, there is still a
> full floating-point multiplication where the simple XORing of
> a single bit should do.

On many modern CPUs, the full floating point multiplication will be
faster than the XOR, because you'll be using a pipelined multiplier
and keeping the pipe full, and there isn't an XOR instruction that
operates on a floating point register.


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