Hacker News new | ask | show | jobs
by xxpor 711 days ago
>Something as simple and common as a summation loop can often be sped up 2-4x by simply having multiple accumulators that you then combine after the loop body; this lets the processor "run ahead" without loop carried dependencies and execute multiple accumulations each cycle.

Shouldn't the compiler be smart enough to figure that out these days (at least if it truly is a straightforward accumulation loop)?

1 comments

Such optimizations may be forbidden by the fact that floating point addition is not associative unless you tell the compiler not to worry about that (I believe)
> floating point addition is not associative unless you tell the compiler not to worry about that

Ah yes, fun and safe math optimizations.

Ah yes, I always forget about the rules with floats. My line of work only ever uses ints.