2.3.6 /O, /O1, /O2, /Od and /Ox
CLAXP provides four basic levels of optimization:
- /Od
Perform no optimization. This choice is recommended in combination with the /Zd or /Zi option when debugging is intended. It is the default if /Zi or /Z7 is specified and there are no explicit optimization options. - /O1
Perform all optimizations that are consistent with keeping the resulting code small. This implies the /Ob1 (user-directed inlining) and /Oi- (do not generate intrinsics) options by default, but these may be overridden. Note that enabling intrinsics is not likely to increase code size significantly, so the use of /Oi is recommended with /O1 even though it is not defaulted. - /Ox
Perform optimizations that benefit speed even if the code requires more space. For example, loop unrolling may occur. /Ob1 option is assumed by default to give the user more control over inlining, but this can be overridden. /Oi is also implied. - /O2
Perform all speed optimizations, including automatic inlining by the compiler. /Ob2 is assumed by default, but this can be overridden. /Oi is also implied.
The default if no explicit optimization option is given is equivalent to /Ox /Oi- unless /Zi or /Z7 is specified (in which case the default is /Od).
/O is equivalent to /O2.
/Ox and /O2 (similarly, /O) include all of the optimizations that are implied by the Microsoft /Oc (block subexpression), /Og (global subexpression), /Oi (enable intrinsics), /Ol (loop optimization), and /Oo (peephole optimization) options in some prior C compilers. However, CLAXP does not allow independent control of these optimizations (other than /Oi).
Note that /Os and /Ot, which express a preferred bias in the trade-offs performed for other optimizations, are not supported. Typical usage of these options with other Microsoft compilers would be in conjunction with /Ox. The intent of /Oxs is best expressed as /O1i to CLAXP, and the intent of /Oxt is achieved by either /Ox or /O2 (depending on the application).