1.2.59 $OPTIMIZATION : Enable Optimizations

This switch enables optimization. It can have the following possible values:

ON

Switches on optimizations, corresponding to level 2 optimizations.

OFF

Switches of all kinds of optimizations.

DEFAULT

Returns to default (i.e. command-line or config file) specified optimizations.

XYZ

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:

REGVAR

Use register variables.

UNCERTAIN

Use uncertain optimizations.

SIZE

Optimize for size.

STACKFRAME

Skip stackframes.

PEEPHOLE

Peephole optimizations.

ASMCSE

Use common subexpression elimination at the assembler level.

LOOPUNROLL

Unroll loops

TAILREC

change tail recursion to regular while

ORDERFIELDS

Reorder fields if this results in better alignment.

FASTMATH

Fast math operations

REMOVEEMPTYPROCS

remove calls to empty procedures.

CSE

Use common subexpression elimination

DFA

Use DFA (Data Flow Analysis).

AUTOINLINE

Try to automatically inline procedures where appropriate.

LEVEL1

Level 1 optimizations.

LEVEL2

Level 2 optimizations.

LEVEL3

Level 3 optimizations.

LEVEL4

Level 4 optimizations.

SCHEDULE

ARM CPU only: perform instruction scheduling. Enabled by default at -O3 and higher.

USEEBP

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.

USERBP

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.

DEADVALUES

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.

CONSTPROP

Perform constant propagation across statements. Enabled by default when using level 3 optimizations or higher.

DEADSTORE

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.

FORCENOSTACKFRAME

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.

USELOADMODIFYSTORE

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.