Microchip Technology SW006023-2N Data Sheet
Compiler Command Line Driver
2012 Microchip Technology Inc.
DS51686E-page 73
The following options control specific optimizations. The -O2 option turns on all of
these optimizations except -funroll-loops, -funroll-all-loops and
-fstrict-aliasing
these optimizations except -funroll-loops, -funroll-all-loops and
-fstrict-aliasing
.
You can use the following flags in the rare cases when “fine-tuning” of optimizations to
be performed is desired.
be performed is desired.
-O2
Optimization level 2. The compiler performs nearly all supported optimizations
that do not involve a space-speed trade-off. -O2 turns on all optional
optimizations except for loop unrolling (-funroll-loops), function inlining
(-finline-functions), and strict aliasing optimizations
(-fstrict-aliasing). It also turns on force copy of memory operands
(-fforce-mem) and Frame Pointer elimination (-fomit-frame-pointer). As
compared to -O, this option increases both compilation time and the performance
of the generated code.
that do not involve a space-speed trade-off. -O2 turns on all optional
optimizations except for loop unrolling (-funroll-loops), function inlining
(-finline-functions), and strict aliasing optimizations
(-fstrict-aliasing). It also turns on force copy of memory operands
(-fforce-mem) and Frame Pointer elimination (-fomit-frame-pointer). As
compared to -O, this option increases both compilation time and the performance
of the generated code.
-O3
Optimization level 3. -O3 turns on all optimizations specified by -O2 and also
turns on the inline-functions option.
turns on the inline-functions option.
-Os
Optimize for size. -Os enables all -O2 optimizations that do not typically increase
code size. It also performs further optimizations designed to reduce code size.
code size. It also performs further optimizations designed to reduce code size.
TABLE 3-12:
SPECIFIC OPTIMIZATION OPTIONS
Option
Definition
-falign-functions
-falign-functions=
n
Align the start of functions to the next power-of-two greater than n,
skipping up to n bytes. For instance, -falign-functions=32
aligns functions to the next 32-byte boundary, but
-falign-functions=24
skipping up to n bytes. For instance, -falign-functions=32
aligns functions to the next 32-byte boundary, but
-falign-functions=24
would align to the next 32-byte
boundary only if this can be done by skipping 23 bytes or less.
-fno-align-functions
-fno-align-functions
and -falign-functions=1 are
equivalent and mean that functions are not aligned.
The assembler only supports this flag when n is a power of two, so
n
The assembler only supports this flag when n is a power of two, so
n
is rounded up. If n is not specified, use a machine-dependent
default.
-falign-labels
-falign-labels=n
Align all branch targets to a power-of-two boundary, skipping up to
n
n
bytes like -falign-functions. This option can easily make
code slower, because it must insert dummy operations for when the
branch target is reached in the usual flow of the code.
If -falign-loops or -falign-jumps are applicable and are
greater than this value, then their values are used instead.
If n is not specified, use a machine-dependent default which is very
likely to be 1, meaning no alignment.
branch target is reached in the usual flow of the code.
If -falign-loops or -falign-jumps are applicable and are
greater than this value, then their values are used instead.
If n is not specified, use a machine-dependent default which is very
likely to be 1, meaning no alignment.
-falign-loops
-falign-loops=n
Align loops to a power-of-two boundary, skipping up to
n
bytes like
-falign-functions
. The hope is that the loop is executed many
times, which makes up for any execution of the dummy operations.
If
If
n
is not specified, use a machine-dependent default.
-fcaller-saves
Enable values to be allocated in registers that are clobbered by
function calls, by emitting extra instructions to save and restore the
registers around such calls. Such allocation is done only when it
seems to result in better code than would otherwise be produced.
function calls, by emitting extra instructions to save and restore the
registers around such calls. Such allocation is done only when it
seems to result in better code than would otherwise be produced.
-fcse-follow-jumps
In common subexpression elimination, scan through jump
instructions when the target of the jump is not reached by any other
path. For example, when CSE encounters an if statement with an
else
instructions when the target of the jump is not reached by any other
path. For example, when CSE encounters an if statement with an
else
clause, CSE follows the jump when the condition tested is
false.
TABLE 3-11:
GENERAL OPTIMIZATION OPTIONS (CONTINUED)
Option
Definition