Everything

-ip_optimize


< Compile Options / Optimize Options >

[Format]

-ip_optimize

[Description]

-

This option applies global optimization including

-

optimization that utilizes interprocedural alias analysis and

-

propagation of constant parameters and return values.

[Example]

Examples 1.

-

<C source code>

static int func1(int *a, int *b) {
    *a=0;
    *b=1;
    return *a;
}
int x[2];
int func2() {
    return func1(x, x+1);
}

-

<Output assembly code without ip_optimize>

; -optimize=2 -size
__$func1:
  MOV.L #00000000H, [R1]
  MOV.L #00000001H, [R2]
  MOV.L [R1], R1
  RTS
_func2:
  MOV.L #_x,R1
  ADD #04H, R1, R2
  BRA __$func1

-

<Output assembly code with ip_optimize>

; -optimize=2 -size
__$func1:
  MOV.L #00000000H, [R1]
  MOV.L #00000001H, [R2]
  MOV.L #00000000H, R1
  RTS
_func2:
  MOV.L #_x,R1
  ADD #04H, R1, R2
  BRA __$func1

Examples 2.

-

<C source code>

static int func(int x, int y, int z) {
    return x-y+z;
}
int func2() {
    return func(3,4,5);
}

-

<Output assembly code without ip_optimize>

__$func:
  ADD R3, R1
  SUB R2, R1
  RTS
_func2:
  MOV.L #00000005H, R3
  MOV.L #00000004H, R2
  MOV.L #00000003H, R1
  BRA __$func

-

<Output assembly code with ip_optimize>

__$func:
  MOV.L #00000004H, R1
  RTS
_func2:
  MOV.L #00000005H, R3
  MOV.L #00000004H, R2
  MOV.L #00000003H, R1
  BRA __$func

[Remarks]

-

Inter-file optimization is also applied when this option is used with merge_files.