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?


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. But maybe the cost of both operations is not so different on today's CPUs; I don't know.

Thanks,
  Martin



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