Hacker News new | ask | show | jobs
by yongjik 1480 days ago
If they were integer variables, I guess the compiler would have done that, but you can't really do that with floats because i+A+A is not necessarily i+2*A. (Of course, in this particular example, the difference doesn't matter for the programmer, but the compiler doesn't know that!)

I think there's some gcc option that enables these "dangerous" optimizations. -ffast-math, or something like that?

1 comments

No the computer would have been unlikely to be able to figure out the math to coalesce 8 recursive additions into one operation.