-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

Only optimization that debugging is not affected is performed (It is the same result as when -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.

nothing

Optimization with debugging precedence

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

default

Default

Performs optimization that debugging is not affected (optimization of expressions and register allocation, and the like).

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.

 

-

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 4 has been specified.

If the -Ospeed option is specified, this item is assumed that the -Ounroll=4 option is specified.

inline

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 or -Ospeed option is specified (when the -Osize option is specified, it is assumed that the -Oinline=3 option has been specified. When the -Ospeed option is specified, it is assumed that the -Oinline=2 option has been specified).

If any of the -Osize, -Ospeed or -Oinline option is not specified, this item is assumed that the -Oinline=1 option is specified.

If the -Onothing option is specified, this item is assumed that the -Oinline=0 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.

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).

delete_static_func

on or off

Deleting unused static functions

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

This item is valid when the -Onothing option is not specified.

pipeline

on or off

Pipeline optimization

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

This item is always valid when the -Ospeed option is specified.

tail_call

on or off

Converting function calls at the end of functions to jr

If "on" is specified, then if there is a function call at the end of a function, and certain conditions are met, a jr instruction will be generated for that call rather than a jarl instruction. The lp store/restore 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.

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

map

file name

External variable access optimization

Base addresses are set in accordance with the external symbol allocation information generated by the linker, and code for accessing external and static variables relative to the base addresses is generated.

When symbol "__gp_data" is defined and a value is specified in gp in the code of the startup routine, code for accessing variables relative to gp when possible is generated in accordance with the external symbol allocation information.

Specify the external symbol allocation information file generated by the optimizing linker as file name.

If file name is omitted, it performs linking once, and then after creating the external symbol allocation information file, repeats the process from compilation to linking.

smap

None

Optimization of access to external variables defined in the compilation unit

Base address is set for external and static variables defined in the file to be compiled, and code that accesses these relative to the base address is generated.

 

-

If item is omitted, it is assumed that this option has specified "-Osize".

-

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

-

When -Oitem is not specified, the optimization items are interpreted as follows according to the -Olevel setting.

Optimization Item (item)

Optimization Level (level)

nothing

default

size

speed

unroll

1

1

1

4

inline

0

1

3

2

inline_size

-

-

-

100

delete_static_func

off

on

on

on

pipeline

off

off

off

on

tail_call

off

off

on

on

map

-

-

-

-

smap

-

-

-

-

This table does not ensure that the optimization result is the same between the case where an optimization level is selected and then each optimization item setting is changed to the value shown for another level in this table and the case where the latter level is specified from the beginning. For example, the code output by specifying "-Ospeed" may not be the same as that output by specifying "-Osize -Ounroll=4 -Oinline=2 -Oinline_size=100 -Opipeline=on".

[Example of use]

-

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

>ccrh -Osize -Xcommon=rh850 main.c