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

Version: **

 

Answer:

 

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

  2. Optimization Level 1
      Optimization will be effected in accordance with detailed analyses of a program flow.  
        
    • Deletion of a immediately after a branch
    •   
    • Deletion of a continuous branch
    •   
    • Change the following execution order
    •  
                                                                                                                                                                           
    Before OptimizationAfter Optimization
    A=x;(deletion)
    if (...) {if (...) {
    A=y;{A=y;
    } else {} else {
    B=z;B=z; A=x;
    }}
      
        
    • Deletion of common formula
    •  
                                                                                   
    Before OptimizationAfter Optimization
    t1=a+b;t1=a+b;
    t2=a+b;t2=t1;
      
        
    • 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.
    •  
                                                                                                     
    Before OptimizationAfter Optimization 
    a=b;(deletion)/*Not use "a" after this*/
    =a;=0;/*Replace "a" to "0"*/
      
        
    • 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
    •  
                                                                                                                     
    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"*/
      
        
    • Deletion of unused variables
    •  
                                                                             
    Before OptimizationAfter Optimization
    a=b;(deletion)
    /*Do not use "a" after this*/
      
        
    • Deletion of simple substitution
    •  
                                                                                   
    Before OptimizationAfter Optimization
    a=b;a=b;
    b=a;(deletion)
      
        
    • Strength Reduction
          Replacing to high-speed calculation.
    •  
                                                             
    Before OptimizationAfter Optimization
    a=b*2;a=b<<2;
      
        
    • 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
    •  
  3. Optimization Level 2
      This Level is optimized as follows (including optimization Level 1)  
        
    • 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.
    •  
                                                             
    Before unrollingfor(i=0;i<3;i++){ a[i]=0;}
    After unrollinga[0]=0;
          a[1]=0;
          a[2]=0;
  4. 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.
    •  
  5. 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.
    •