I've been trying to read through the MSDN pages on the various optimization flags.
We currently have most of our projects set to /O2
which optimizes for "maximize speed".
My confusion is what exactly this means. Which of the following statements are closer to true regarding the /O2
flag?
- Optimize the code for both speed and size, but if there is contention prefer optimization for speed
- Optimize the code only for speed, do not optimize for size.
I made the argument that we should use the /Ox
flag, but that was when I was under the impression that Option 2 was true.
I was basically told "we're not going to change from /O2
to /Ox
unless someone has solid evidence that we need to do so".
So my question is does /O2
still perform memory optimizations? E.g. return value optimization, copy elision, etc. What would we gain from switching from /O2
to /Ox
?