Optimization Level of SOFTUNE C Compiler in FR Family FR81S MCUs – KBA218675

Version 2

    Version: **


    Translation - Japanese: FRファミリFR81S MCUのSOFTUNE Cコンパイラの最適化レベル - KBA218675 - Community Translated (JA)





      1. Optimization Level 0
          No optimization will be effected. This level is equivalent to not specifying -O


      1. Optimization Level 1
          Optimization will be effected in accordance with detailed analyses of a program flow.                                                                                                                                                                         
        Before OptimizationAfter Optimization
        if (...) {if (...) {
        } else {} else {
        B=z;B=z; A=x;
        Before OptimizationAfter Optimization
        Before OptimizationAfter Optimization
        a=b;(deletion)/*Not use "a" after this*/
        =a;=0;/*Replace "a" to "0"*/
        Before OptimizationAfter Optimization
        a=b;(deletion)/*Do not use "a" after this*/
        /*Not define "a" and "b" between this.*/
        =a;=b;/*Replace "a" by "b"*/
        Before OptimizationAfter Optimization
        /*Do not use "a" after this*/
        Before OptimizationAfter Optimization
        Before OptimizationAfter Optimization
        • Deletion of a immediately after a branch
        • Deletion of a continuous branch
        • Change the following execution order
        • Deletion of common formula
        • Deletion of common formula
              If the constant can be calculated, it is done at during compile


        • Propagation of constanta
              The variable that the constant substitutes is replaced by the constant.
        • Deletion of non-execution sentences
              If there is a sentence which is not executed, such statements are not generated.


        • Moving of an unchanged formula in loop
              The formula that is not changed in a loop is moved out of the loop.


        • Propagation of copy
        • Deletion of unused variables
        • Deletion of simple substitution
        • Strength Reduction
              Replacing to high-speed calculation.
        • In-line expansion of functions (same as those effected by specifying -x func).


        • Table branching of "switch-case"


      • Implementing instruction scheduling (same as those effected by specifying -Kschedule)      
        • Best use of the delay branch instruction
        • Avoiding an interlock for the LD instruction
        • Optimization of the assembler instruction
      • Assignment of resistor
    1. Optimization Level 2
        This Level is optimized as follows (including optimization Level 1)                                                           
      Before unrollingfor(i=0;i<3;i++){ a[i]=0;}
      After unrollinga[0]=0;
      • Loop unrolling
            Loop unrolling reduces the loop number of times, and improves execution speed. However, it increases the object size. Therefore, if the object size is important, this optimization should not be used.
    2. 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 of a loop has two exits
      • Loop unrolling of a loop has a branch in the "if" sentence
      • Optimization function is repeated.
    3. 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 those effected by specifying -K EOPT)
      • Standard Function Expansion/Change (same as those effected by specifying -K LIB)
            Standard function (strcpy, strcmp, strlen, memcpy, memset) inline expansion is implemented.