Answer:

**About the C Compiler optimizes**

This content is related to optimization level by Softune C Compiler.

**Optimization Level 0**

No optimization will be effected. This level is equivalent to cases where the -0 is not specified.

**Optimization Level 1**

Optimization will be effected in accordance with detailed analyses of a program flow.

Deletion of branch immediately after

Deletion of continuous branch

Merging execution line except of "if" sentence to "then-else"

When there is defined data either "else" section or "then" section in "if" sentence, the sentence is moved to section, which there is no defined, if there is defined sentence of the data except of "if" sentence.

And if there is no "else" section in "if" sentence, suitable transaction unit to "else" section is generated, and the sentence is moved to the transaction unit.

[Before Optimization] | [After Optimization] |

A=x; | (deletion) |

if (...) { | if (...) { |

A=y; | A=y; |

} else { | } else { |

B=z; | B=z; A=x; |

} | } |

Deletion of common formula

[Before Optimization] | [After Optimization] |

t1=a+b; | t1=a+b; |

t2=a+b; | t2=t1; |

Calculation of constant (folding constant in)

Possible constant of calculation is calculated at compiling.

Spread of constant

Variable, what constant is substituted, is replaced to the constant.

[Before Optimization] | [After Optimization] | |

a=b; | (deletion) | /*Not use "a" after this*/ |

=a; | =0; | /*Replace "a" to "0"*/ |

Deletion of un-execution sentence

When truth can be judged for formula (e.g. "if", "while" and others sentences) or there is a sentence of not executing (e.g. branch of no judgment and others), any code is not generated.

Moving of unchanged formula in loop

Formula, what is not changed in loop, is moved out of loop.

Spread of copy

[Before Optimization] | [After Optimization] | |

a=b; | (deletion) | /*Not use "a" after this*/ |

/*Not define "a" and "b" between this.*/ | ||

=a; | =b; | /*Replace "a" to "b"*/ |

Deletion of unused variable

[Before Optimization] | [After Optimization] |

a=b; | (deletion) |

/*Not use "a" after this*/ |

Deletion of simple substitution

[Before Optimization] | [After Optimization] |

a=b; | a=b; |

b=a; | (deletion) |

Reduce of strength

Multiplication by constant of square is replaced to operation of higher speed by shifting.

[Before Optimization] | [After Optimization] |

a=b*2; | a=b<<2; |

The in-line expansion of functions (same as effected by -x func specifying)

Branch of table for "switch-case"

to implement instruction scheduling (same as effected by -Kschedule specifying)

Best use of delay branch instruction

Avoiding of interlock for LD instruction

Optimization of assembler instruction

Assignment of resister

**Optimization Level 2**

This Level is optimized as following (including optimization Level

Loop unrolling

Loop unrolling is improved execution speed by reducing loop times if loop times is possible to detect. But object size is increased. Therefore if object size is important, this optimization shouldn't be used.

(Before unrolling) |

for(i=0;i<3;i++){ a[i]=0;} |

(After unrolling) |

a[0]=0; a[1]=0; a[2]=0; |

**Optimization Level 3**

The following optimization features are exercised in addition to the features provided by optimization level 2. However, the translation time will increase.

Loop unrolling for loop, what has two exit

Loop unrolling for loop, what have any branch in "if" sentence

In optimization function repeated execution.

**Optimization Level 4**

The following optimization features are exercised in addition to the features provided by optimization level 3.

Arithmetic Operation Evaluation Type Change (same as effected by -K EOPT specifying)

Standard Function Expansion/Change (same as effected by -K LIB specifying)

Standard function (strcpy, strcmp, strlen, memcpy, memset) in-line expansion is implemented.

## Comments