
5-6
SC100 C Compiler
Optimization Techniques and Hints
5.2 Using the Optimizer
By default, the compiler optimizes all source code files using Level 2 optimization in non-global mode.
You can choose to optimize your source code at the level that you require at each stage of program
development, and you can optimize individual sections of the program according to their purpose in the
application. For example, you may wish to prepare your application as follows:
During initial development stages
: Use the default Level 2 optimization to compile your source
code files, individually or in groups. If required, optimize certain sections of the application for
maximum speed, and optimize other sections for size, to reduce the memory space they occupy.
During final development stages
: Select Level 2 and global mode, in order to apply all
optimizations globally across the entire application. The compilation is slower, but produces the
most effective optimization results.
You select the optimization level and mode to be applied by specifying one or more options in the shell
command line, as described below in
Section 5.2.1,
“
Invoking the Optimizer.
”
5.2.1 Invoking the Optimizer
The optimizer can be invoked by including the required option(s) in the shell command line or command
file, as illustrated in the examples that follow. For more detailed information about the use and syntax of
the shell command line, refer to
Section 3.2,
“
Invoking the Shell,
”
on page 3-10.
The command line shown in Example 5-2 invokes the optimizer with one input source file, and the default
optimization settings. The optimizer applies Level 2 optimizations in non-global mode, with a balance
between space and time optimizations.
Example 5-2. Invoking the optimizer with default settings
ccsc100 -o file.eld file.c
Example 5-3 shows how to invoke the optimizer with the Level 1 option, to apply high-level optimizations
only. The optimizer maintains a balance between time and space optimizations, and operates in non-global
mode.
Example 5-3. Invoking the optimizer for high-level optimizations only
ccsc100 -O1 -o file.eld file.c
In Example 5-4, the optimizer applies all optimizations in non-global mode, with the emphasis on
increasing the speed of the program at the expense of its size.
Example 5-4. Invoking the optimizer for time optimization
ccsc100 -Ot -o file.eld file.c