Michael James wrote:
Hello,
I am trying to get gcc to optimize an inner math loop. The first part
of the loop computes a single precision float expression (which may or
may not be NAN), and the second part sums all of these results into a
double precision total:
Conceptually, the code is:
double sum = 0;
for(i=0; i<n; ++i) {
float x = ..computed..;
sum += isnan(x)? 0: x;
}
Forcing NANs to be zero may sound like a good idea,
but it's better to force it to a small value. Some
studies have shown that using zero tends to create
more NANs in computations as results get closer and
closer to zero, while substituting a small value
results in convergence to representable values.
--
Michael Eager [EMAIL PROTECTED]
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077