I've written a lot of interpreters in C/++ lately, and spent a lot of time profiling and optimizing them.
I can't remember -O3 ever being faster than -O2, it's usually slightly slower for me.
I can't remember -O3 ever being faster than -O2, it's usually slightly slower for me.
In the past, at a time when I worked on a very performance sensitive codebase that was also limited in scope, we compiled with -Osize and did all the loop optimizations we wanted manually (and with pragmas). That produced faster code than -O2 or -O3.
In other words, loop unrolling is, more often than not, harmful.
A more granular control over optimisation would be good, however.
I turned on PGO for the D compiler recently and it compiled it's tests 15% faster. Boom.