Methods to Optimize Code Size
Favors size over speed
This option enables optimizations that do not increase code size; it produces smaller code size than option
Osdisables some optimizations that may increase code size for a small speed benefit.
Minimizes code size
Compared to option
O1disables even more optimizations that are generally known to increase code size. Specifying option
As an intermediate step in reducing code size, you can replace option
O2before specifying option
O1may improve performance for applications with very large code size, many branches, and execution time not dominated by code within loops.
Disable or Decrease the Amount of Inlining
Strip Symbols from Your Binaries
Dynamically Link Intel-Provided Libraries
Exclude Unused Code and Data from the Executable
Disable Recognition and Expansion of Intrinsic Functions
Optimize Exception Handling Data on Linux Systems
Disable Loop Unrolling
Disable Automatic Vectorization
Avoid References to Compiler-Specific Libraries
Use Inter-Procedural Optimization (IPO)
- Some of these methods may already be applied by default when optionsOsandO1are specified. All the methods mentioned in subsequent topics can be applied at higher optimization levels.
- Some of the options referred to in these topics will not necessarily cause code size reduction, and they may provide varying results (good, bad, or neutral) based on the characteristics of the target code. Still, these are the recommended things to try to see if they cause your binaries to become smaller while maintaining acceptable performance.