This option specifies the optimization level or the details of each optimization items.
The -Odefault option is assumed.
Note that the items that can be specified for level vary depending on the version.
[V1.11 or earlier] All items other than -Olite can be specified for level for both the paid editions and free evaluation edition.
[V1.12 or later] All items can be specified for level for the paid editions and the free evaluation edition within the trial period.
Only -Olite or -Onothing can be specified for a free evaluation edition whose trial period has expired. If any other value is specified, a warning message is output, and then the value is changed to -Olite.
The items that can be specified as item and value are shown below. |
If this option is specified more than once for the same item, the option specified last will be valid. |
The -Oitem items not listed in the table are not affected by the -Olevel setting.
Note that optimization through the -Olevel setting does not precisely match the optimization result obtained by specifying each -Oitem value separately. For example, when the -Odefault level is specified as -Olevel and then each -Oitem is separately set to match the corresponding item value for the -Osize level, the optimization result is not equivalent to that obtained when -Osize is specified from the beginning.
If specification of the -O option is omitted, it is assumed that the -Odefault option has been specified. |
If only -Oitem is specified (-Olevel is not specified), it is assumed that -Odefault has been specified for -Olevel. |
>ccrl -cpu=S2 -dev=dr5f100pj.dvf main.c # Same as -Odefault >ccrl -cpu=S2 -dev=dr5f100pj.dvf -O main.c # Same as -Osize >ccrl -cpu=S2 -dev=dr5f100pj.dvf -Ounroll=8 main.c # Same as -Odefault -Ounroll=8 >ccrl -cpu=S2 -dev=dr5f100pj.dvf -O -Ounroll=8 main.c # Same as -Osize -Ounroll=8 |
extern long x[2]; extern int y[2]; static long func1(long *a, int *b) { *a=0; *b=1; return *a; } long func2(void) { return func1(&x[0], &y[1]); } |
_func1@1: .STACK _func1@1 = 6 movw de, ax push bc pop hl clrw ax movw [de+0x02], ax movw [de], ax onew ax movw [hl], ax clrw bc ; 0 is directly assigned because a and b point to different clrw ax ; addresses. ret |
static __near int func(int x, int y, int z) { return z-x-y; } int func2(void) { return func(3,4,8); } |
.SECTION .text,TEXT _func@1: .STACK _func@1 = 4 onew ax ; 1(=8-3-4) is directly assigned. ret .SECTION .textf,TEXTF _func2: .STACK _func2 = 4 movw de, #0x0008 movw bc, #0x0004 movw ax, #0x0003 br !_func@1 |
As ps and n have different types, the value of n will not be affected by "ps = 2;". Therefore, the value used for assignment in "n = 1" is used again at (A).
(When "ps = 2;" changes the value of n, the result will be changed.)
_func: .STACK _func = 4 movw de, ax clrw ax movw bc, ax movw !LOWW(_n+0x00002), ax onew ax movw hl, ax movw !LOWW(_n), ax onew ax incw ax movw [de], ax movw ax, bc ; (A) The value used for assignment in n = 1 is used again. movw !LOWW(_x+0x00002), ax movw ax, hl ; (A) movw !LOWW(_x), ax ret |
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.). |
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. |