-O


This option specifies the optimization level or the details of each optimization items.

[Specification format]

-O[level]
-O[item[=value][,item[=value]]...]

 

-

Interpretation when omitted

Optimization that is effective for both the object size and execution speed is done. (It is the same result as when the -Odefault option is specified).

[Detailed description]

-

This option specifies the optimization level or the details of each optimization items.

-

The items that can be specified as level are shown below.
An error will occur if any other item is specified.

default

Default

Does optimization that is effective for both the object size and execution speed.

size

Optimization with the object size precedence

Regards reducing the ROM/RAM capacity as important and performs the maximum optimization that is effective for general programs.

speed

Optimization with the execution speed precedence

Regards shortening the execution speed as important and performs the maximum optimization that is effective for general programs.

nothing

Optimization with debugging precedence

Regards debugging as important and suppresses all optimization including default optimization.

 

-

If level is omitted, it is assumed that "size" has been specified.

-

The items that can be specified as item and value are shown below.
An error will occur if any other item is specified.

Optimization Item (item)

Parameter (value)

Description

unroll

0 to 4294967295

(Integer value)

Loop expansion

The loop statements (for, while, and do-while) are expanded.

Use value to specify the maximum rate of increase in code size after loop expansion.

A value of 0 set as value has the same meaning as a value of 1.

If value is omitted, it is assumed that "2" has been specified.

This item is valid when the -Osize, -Ospeed, or -Odefault option is specified.

delete_static_func

on or off

Deleting unused static functions

If value is omitted, it is assumed that "on" has been specified.

inline_level

0 to 3

(Integer value)

Inline expansion for functions

value signifies the level of the expansion.

0: Suppresses all inline expansion including the function for which "#pragma inline" is specified.

1: Performs inline expansion for only a function for which "#pragma inline" is specified.

2: Distinguishes a function that is the target of expansion automatically and expands it.

3: Distinguishes the function that is the target of expansion automatically and expands it, while minimizing the increase in code size.

However, if 1 to 3 is specified, the function that is specified by "#pragma inline" may not be expanded according to the content of the function and the status of compilation.

If value is omitted, it is assumed that 2 has been specified.

This item is valid when the -Osize, -Ospeed, or -Odefault option is specified.

inline_size

0 to 65535

(Integer value)

Size for inline expansion

Specify the maximum increasing rate (%) of the code size up to which inline expansion is performed.

When 100 is specified, functions are expanded inline until the code size increases by 100%.

If value is omitted, it is assumed that 100 has been specified.

This item is valid when the -Oinline=2 option is specified (including when the -Ospped option is specified).

pipeline

[V1.03 or later]

on or off

Pipeline optimization

If value is omitted, it is assumed that "on" has been specified.

This item is valid when the -Osize, -Ospeed, or -Odefault option is specified.

tail_call

on or off

Replacement of a function call at the end of a function with br instruction

If "on" is specified, then if there is a function call at the end of a function, and certain conditions are met, a br instruction will be generated for that call rather than a call instruction. The ret code will be removed, reducing the code size.

However, some debug functions cannot be used.

If value is omitted, it is assumed that "on" has been specified.

merge_files

-

Merging of multiple files before compilation

If this option is omitted, compilation is done in input file units without merging the files.

Multiple C source files are merged then compiled, and output as a single file.

The output file name is the specified output file name when -o is specified. When -o is not specified, the output file name becomes the file name according to the interpretation when -o is omitted for the C source file name that has been specified first.

When there is only one input file or this option is specified simultaneously with -P, this option is invalid.

When this option is specified simultaneously with -S or -c, an empty file is created and its file name is in accordance with the interpretation when -o is omitted for the C source file name that has been specified second or later.

When this option is specified simultaneously with -Oinline_level, inline expansion is performed between files.

When linking an object file created with this option specified, operation is not guaranteed if linker option -delete, -rename, or -replace is specified simultaneously.

intermodule

-

Global optimization execution

The main optimization contents are the following.

-

Optimization using alias analysis between procedures

-

Propagation of constants, such as parameters and return values

whole_program

-

Optimization assuming that the whole program consists only of the input file

If this option is omitted, it is not assumed that the whole program consists only of the target file for compilation.

The compilation is performed assuming that the following conditions are met. Operation is not guaranteed if these conditions are not met.

-

The values and addresses of extern variables defined in the files to be compiled will not be modified or referenced from outside those files.

-

If a file to be compiled calls a function defined outside the files to be compiled, the called function will never call a function in the files to be compiled.

 

If this option is specified, it is assumed that the -Ointermodule option is specified.

If two or more C source files are input, it is assumed that the -Omerge_files option is specified.

alias

ansi or noansi

Optimization considering the type pointed to by pointers

If this option is omitted, noansi is assumed.

same_code

[V1.02 or later]

on or off

The multiple same instruction sequences that are found within a single section of the compilation unit are integrated into a function.

If value is omitted, it is assumed that on is specified.

This option is valid when the -Osize, -Ospeed, or -Odefault option is specified.

 

-

If this option is specified more than once for the same item, the option specified last will be valid.

-

According to the -Olevel setting, the following values can be specified as -Oitem.
The -Oitem items not listed in the table are not affected by the -Olevel settings.

Optimization Item (item)

Optimization Level (level)

-Osize

-Ospeed

-Odefault

-Onothing

unroll

1

2

1

1

delete_static_func

on

on

on

off

inline_level

3

2

3

-

inline_size

0

100

0

-

tail_call

on

on

on

off

pipeline

on

on

on

off

same_code

on

off

off

off

[Example of use]

-

To perform optimization with the object size precedence, describe as:

>ccrl -Osize -cpu=S2 -dev=dr5f100pj.dvf main.c

[Caution]

When source-level debugging is performed using an optimized object code, take account of the following ramifications.

-

A variable may not be read or written at the location where that variable is referenced in the source program because an expression has been transformed (copy propagation, common subexpression recognition, etc.) due to optimization.

-

Step execution may not be performed according to the source program because statements have been optimized (code sharing, elimination, rearrangement, etc.).
In addition, a breakpoint may not be set for a particular statement. For example, if a statement has been deleted, a breakpoint cannot be set at that statement.

-

There is a possibility that the variable's available range (range in which the variable can be referenced in the program) or variable's location (register or memory location) is changed due to optimization (rearrangement of statements, register allocation, etc.) of statements or variables.

-

Step execution for an inline-expanded statement is performed not at the inline-expanded part but within the inline expansion source function.
Since calling of the inline-expanded function is deleted, a breakpoint cannot be set there.

-

Since a great amount of memory is consumed to process debugging information at compilation, it may result in "out of memory".