Microchip Technology SW006022-1N Data Sheet
Compiler Command-Line Driver
2012 Microchip Technology Inc.
DS52071B-page 71
3.7.6
Options for Controlling Optimization
The following options control compiler optimizations.
Optimization levels available depend
on the compiler edition (see Chapter 15. “Optimizations”.)
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
.
-save-temps
Don’t delete intermediate files. Place them in the current directory and name
them based on the source file. Thus, compiling foo.c with -c
-save-temps
them based on the source file. Thus, compiling foo.c with -c
-save-temps
would produce the following files:
foo.i
(preprocessed file)
foo.p
(pre procedure abstraction assembly language file)
foo.s
(assembly language file)
foo.o
(object file)
TABLE 3-11:
GENERAL OPTIMIZATION OPTIONS
Option
Edition
Definition
-O0
All
Do not optimize. (This is the default.)
Without -O, the compiler’s goal is to reduce the cost of compilation
and to make debugging produce the expected results. Statements
are independent: if you stop the program with a breakpoint between
statements, you can then assign a new value to any variable or
change the program counter to any other statement in the function
and get exactly the results you would expect from the source code.
The compiler only allocates variables declared register in regis-
ters.
Without -O, the compiler’s goal is to reduce the cost of compilation
and to make debugging produce the expected results. Statements
are independent: if you stop the program with a breakpoint between
statements, you can then assign a new value to any variable or
change the program counter to any other statement in the function
and get exactly the results you would expect from the source code.
The compiler only allocates variables declared register in regis-
ters.
-O
-O1
All
Optimize. Optimizing compilation takes somewhat longer, and a lot
more host memory for a large function.
With -O, the compiler tries to reduce code size and execution time.
When -O is specified, the compiler turns on -fthread-jumps and
-fdefer-pop. The compiler turns on -fomit-frame-pointer.
more host memory for a large function.
With -O, the compiler tries to reduce code size and execution time.
When -O is specified, the compiler turns on -fthread-jumps and
-fdefer-pop. The compiler turns on -fomit-frame-pointer.
-O2
STD, PRO
Optimize even more. 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 (-fun-
roll-loops
optimizations that do not involve a space-speed trade-off. -O2 turns
on all optional optimizations except for loop unrolling (-fun-
roll-loops
), function inlining (-finline-functions), and strict
aliasing optimizations (-fstrict-aliasing). It also turns on
Frame Pointer elimination (-fomit-frame-pointer). As com-
pared to -O, this option increases both compilation time and the
performance of the generated code.
Frame Pointer elimination (-fomit-frame-pointer). As com-
pared to -O, this option increases both compilation time and the
performance of the generated code.
-O3
PRO
Optimize yet more. -O3 turns on all optimizations specified by -O2
and also turns on the inline-functions option.
and also turns on the inline-functions option.
-Os
PRO
Optimize for size. -Os enables all -O2 optimizations that do not typi-
cally increase code size. It also performs further optimizations
designed to reduce code size.
cally increase code size. It also performs further optimizations
designed to reduce code size.
TABLE 3-10:
DEBUGGING OPTIONS (CONTINUED)
Option
Definition