views:

42

answers:

1

According to msdn,

/O2 (Maximize Speed)

is equivalent to

/Og/Oi/Ot/Oy/Ob2/Gs/GF/Gy

and according to msdn again, the following pragma

#pragma optimize( "[optimization-list]", {on | off} )

uses the same letters in its "optimization-list" than the /O compiler option. Available letters for the pragma are:

  • g - Enable global optimizations.
  • p - Improve floating-point consistency.
  • s or t - Specify short or fast sequences of machine code.
  • y - Generate frame pointers on the program stack.

Which ones should I use to have the same meaning as /O2 ?

A: 

From the docs:

  1. /Og enables global optimizations
  2. /Oi generates intrinsic functions for appropriate function calls.
  3. /Ot (a default setting) tells the compiler to favor optimizations for speed over optimizations for size.
  4. /Oy suppresses the creation of frame pointers on the call stack for quicker function calls.
  5. /Ob2 expands functions marked as inline or __inline and any other function that the compiler chooses

The /G options aren't strictly optimizations, so that leaves us with g & t, plus #pragma intrinsic (for 2), #pragma auto_inline (for 5) and possibly #pragma inline_depth.

bosmacs