ILE C/C++ Programmer's Guide


Choosing Compiler Options to Optimize for Speed or Size

There are several ways to improve compile-time performance. These include both front end and back end compile-time activities.

Table 6 describes different compiler options to make your program run faster, and to make your compiled program smaller. Note that sometimes you have to decide which is more important to you, program size or program speed. In some cases optimizing for one aspect means the other suffers.

Optimization is the process through which the system looks for processing shortcuts that reduce the amount of system resources necessary to produce output. Processing shortcuts are translated into machine code, allowing the procedures in a module to run more efficiently. A highly optimized program or service program should run faster than it would without optimization.

To control the level of optimization, use the OPTIMIZE option on the Create Module and Create Bound Program commands. Changing the desired optimization level requires recompiling your source code. Changing the optimization of a module can also be accomplished through a Change Module (CHGMOD) command.

Note:
You cannot use the Change Module (CHGMOD) command to change the optimization level without recompiling your source code.

You should be aware of the following limitations when working with optimized code:

Use the guidelines in Table 6, except where they are contradicted. Intrinsic functions may improve performance, but they increase the size of your module.

Table 6. Compiler Options for Performance

Option Optimize for Speed Optimize for Size
OPTIMIZE 10	//Default value
OPTIMIZE 20
OPTIMIZE 30
OPTIMIZE 40
Turns on optimization.
Yes Yes
INLINE(*OFF)
Turns off inlining. May reduce module size, especially if the inlined functions consist of small pieces of code.
No Yes
INLINE(*ON)
Turns on inlining. Saves many function calls when a function is called in a few places but executed many times.
Yes No
DBGVIEW(*NONE)
Does not generate debug information, which would increase module size.
No Yes


[ Top of Page | Previous Page | Next Page | Table of Contents ]