Version: **

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; if (...) { A=y; } else { B=z; } | (deletion) if (...) { A=y; } else { B=z; A=x; } |

**Deletion of common formula**

Before Optimization | After Optimization |

t1=a+b; | 1=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=0; | (deletion) /*Not use "a" after this*/ |

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

**Deletion of un-execution sentence**

**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; /*Not define "a" and "b" between this.*/ | (deletion) /*Not use "a" after this*/ |

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

**Deletion of unused variable **

Before Optimization | After Optimization |

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

**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**

The following optimization feature is exercised in addition to the feature provided by optimization level 1.

However, it tends to increase object size.

Loops Unrolling for straight loops.

###### 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