The /Ox option combines a number of different optimizations:
Enable global register allocation (/Oe)
Enable global common subexpression optimization (/Og)
Enable block-scoped common subexpression optimization (/Oc)
Generate intrinsic functions (/Oi)
Perform maximum inlining (/Ob2)
Perform loop optimizations (/Ol)
Optimize for speed (/Ot)
Remove stack probes (/Gs)
Summary: Use /Ozax /Gr to get the fastest program.
The /Ox option does not include several optimizations that can improve code efficiency: /Oa (assume no aliasing), /Oz (enable aggressive optimizations), and /Gr (use fastcall calling convention). Before enabling these optimizations, you should read the sections that describe the /Oa and /Oz options and the fastcall calling convention to determine if they are appropriate for your application. See the next section for linker options that can make your program faster.
Summary: Use /Ose /Gsy to get the smallest program.
If you are more concerned with executable file size than execution time, use the /Ose and /Gsy options. The /Oa option can reduce the size of your program further, but you should use it only if it is appropriate for your application. If your program will be run only on an 80286 or higher processor, use the /G2 option to produce smaller code by using the advanced instruction set. If your program will be run only on machines with an 80x87 coprocessor, use the /FPi87 option to produce smaller code for floating-point calculations. See the next section for linker options that can make your program smaller.