This switch enables optimization. It can have the following possible values:
Switches on optimizations, corresponding to level 2 optimizations.
Switches off all kinds of optimizations.
Returns to default (i.e. command-line or config file) specified optimizations.
Parses the string and switches on the optimizations found in the string as if they were passed using the -Oo command line option. The optimizations must be separated by commas.
The following strings are supported:
Use register variables.
Use uncertain optimizations.
Optimize for size.
Skip stackframes.
Peephole optimizations.
Use common subexpression elimination at the assembler level.
Unroll loops.
Change tail recursion to regular while.
Reorder fields if this results in better alignment.
Fast math operations.
Remove calls to empty procedures.
Use common subexpression elimination.
Use DFA (Data Flow Analysis).
Try to automatically inline procedures where appropriate.
Enable some level 1 optimizations. Note that this is not the same as -O1, it is a separate flag.
Enable some level 2 optimizations. Note that this is not the same as -O2, it is a separate flag.
Level 3 optimizations. Note that this is not the same as -O2, it is a separate flag.
Level 4 optimizations. Note that this is not the same as -O2, it is a separate flag.
ARM CPU only: perform instruction scheduling. Enabled by default at -O3 and higher.
i8086 and i386 CPUs only: use the (E)BP register for register variables when it is not used to hold the frame pointer. Enabled by default when using level 4 optimizations.
x86-64 CPU only: use the RBP register for register variables when it is not used to hold the frame pointer. Enabled by default when using level 4 optimizations.
Allow removing expressions whose result is not used, even when this can change
program behaviour. For example, range check errors can disappear when indexing an
array and not doing anything with the loaded value, or access violations due to invalid
pointer dereferences can disappear.
Note: it does not (and must not) remove expressions that have explicit side-effects.
Enabled by default when using level 4 optimizations.
Perform constant propagation across statements. Enabled by default when using level 3 optimizations or higher.
Remove stores to variables if the value of that variable is no longer used afterwards. This optimization is not enabled by default at any optimization level. Requires DFA (Data Flow Analysis) to be active (otherwise it won’t do anything), which itself is enabled by default when using level 3 optimizations or higher.
ARM and Xtensa CPU only (currently the switch is not yet used there). Do not use a separate frame pointer register if a procedure/function has no nested pure assembler procedures/functions. This requires the compiler to estimate the size of the stack frame in advance, and if that estimate is wrong this will result in an internal compiler error. For this reason it is not enabled by default at any optimization level.
Optimize expressions of the form ”x := x ¡op¿ y” by directly modifying the value of x rather than loading, modifying and then storing it. This is not enabled by default at any optimization level.
You can disable a certain optimization by prefixing the value with NO.
Example:
{$OPTIMIZATION ON}
is equivalent to
{$OPTIMIZATION LEVEL2}
Multiple optimizations can be specified with:
{$OPTIMIZATION REGVAR,SIZE,LEVEL2}
Disable loop unrolling with:
{$OPTIMIZATION NOLOOPUNROLL}
This switch is also activated by the -Ooxxx command line switch. Note the small ’o’: it is -Oo followed by the switch name.