I'll start out by saying that my experience is limited to SPARC assembly language and the SUN cc compiler. That said, why is it that aggressive compiler optimizations could cause instability or incorrect operation of programs?
I know that Gentoo turns off optimizations when compiling OpenOffice.org, because OOo is sensitive to optimizations and the OOo guys will not support it if aggressive optimizations are turned on. Also, most people don't compile with level 5 optimizations, they opt for 2 or 3 instead. So, it seems that programs can be affected adversely by optimization level.
However, having looked at some assembly created from C programs compiled with different optimization levels, I don't see how this could be the case. The main differences I've noticed between different levels of optimization are loop unrolling, using registers instead of main memory for holding intermediate values, and rearranging instructions to get rid of nops. I don't understand how any of this can change the reliability of execution. What am I missing?
I know that Gentoo turns off optimizations when compiling OpenOffice.org, because OOo is sensitive to optimizations and the OOo guys will not support it if aggressive optimizations are turned on. Also, most people don't compile with level 5 optimizations, they opt for 2 or 3 instead. So, it seems that programs can be affected adversely by optimization level.
However, having looked at some assembly created from C programs compiled with different optimization levels, I don't see how this could be the case. The main differences I've noticed between different levels of optimization are loop unrolling, using registers instead of main memory for holding intermediate values, and rearranging instructions to get rid of nops. I don't understand how any of this can change the reliability of execution. What am I missing?