c++ - Visual Studio 2013 optimization flags (/O2 vs /Ox) -
this question has answer here:
i've been trying read through msdn pages on various optimization flags.
we have of our projects set /o2
optimizes "maximize speed".
my confusion means. of following statements closer true regarding /o2
flag?
- optimize code both speed , size, if there contention prefer optimization speed
- optimize code only speed, not optimize size.
i made argument should use /ox
flag, when under impression option 2 true.
i told "we're not going change /o2
/ox
unless has solid evidence need so".
so question /o2
still perform memory optimizations? e.g. return value optimization, copy elision, etc. gain switching /o2
/ox
?
as arkanosis pointed out correctly, when going /o2 /ox, disable /gs, /gf, /gy. question which of these flags may increase execution speed?
/gs identical /gs0 , can have negative impact on performance. see below description on msdn.
activates stack probes every function call requires storage local variables. can have negative impact on performance
/gf eliminates duplicate strings (constants) - called string pooling. reduce code size. lower code produce lower number of instruction cache misses doubt effect observable on codes.
/gy flag alows packaging individual functions comdat structures. these can used workaround avoid compile time errors due multiple definitions of same symbol. msdn documentation states affects build time not execution time. recommend using it.
conclusion:
/ox disables /gs, /gf, /gy. in cases, these options hurt performance , never improve execution speed, compared /o2. of course have benefits not related speed.
Comments
Post a Comment