Specifications

28 Performance-Centric Compiler Switches Chapter 3
32035 Rev. 3.22 November 2007
Compiler Usage Guidelines for AMD64 Platforms
3.6 Microsoft
®
Compilers (64-Bit) for Microsoft
®
Windows
®
Microsoft provides C/C++ compilers for AMD64 architecture-based systems running the Microsoft
Windows operating system. The current version is Visual Studio 2008. This document contains the
latest C/C++ compiler recommendations for Visual Studio 2008. All the options described below
apply to this version of the compiler.
3.6.1 Invocation Commands
The cl command invokes the Microsoft C/C++ compiler.
3.6.2 Generic Performance Switches
The /O2, /GL and /fp:fast switches almost always result in improved performance. The /O2 switch
turns on several general optimizations. The /GL enables interprocedural optimizations. Using /fp:fast
allows the compiler to use a fast floating-point model. However, for applications that requires high
precision this switch should be avoided. For code that may be sensitive to cache size, consider using
the /O1 compiler switch. /O1 will generate smaller code at the possible expense of instruction
execution speed. However, the potential performance improvement due to smaller code footprint may
be of more benefit than any loss due to slower instructions.
Profile-Guided Optimization. The 64-bit Microsoft compiler allows profile-guided optimization.
Use the following steps for profile-guided optimization with 64-bit Microsoft compilers for Microsoft
Windows.
1. Compile the program with the /GL switch and link with the /LTCG:PGI switch.
2. Run the executable produced in Step 1. Running the executable generates several files with profile
information.
3. Relink the program with the /LTCG:PGO switch.
/D_SECURE_SCL=0. To turn off linking with secure C++ libraries, use the /D_SECURE_SCL=0
switch. This switch can improve the performance of iterator-heavy C++ code , but can sacrifice
security as buffer-overrun checks are disabled.
/OPT:ref,icf. This linker option removes redundant symbols and unused functions, resulting in a
smaller binary.
3.6.3 /favor Performance Switch
When targeting AMD Family 10h processors, use the /favor:blend switch for best performance. If no
favor flag is specified, /favor:blend is the default. When targeting AMD processors prior to AMD
family 10h, use the /favor:AMD64 switch. It will typically result in improved performance on those
platforms.