This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Effect of changing Optimization Level

My code currently has an optimization level of 8. But i'm out of code space and want to change it to level 9. Is there any side effect if we use optimization level 9??

Parents
  • It is a bit strange to have 11 different optimization levels. That somehow gives an indication that each optimization has a natural order or at least cost in relation to every other optimization.

    Most compilers settles for maybe two or three optimization levels (little, medium and much or maybe fast, medium and expensive). This then complemented with another switch to inform the compiler if it should prioritize speed or size. And finally - for the control freaks - a full set of optimization flags to allow full customization of what optimization steps to use.

    One thing interesting here is the note that the total size tends to grow at optimization levels above 9, since the documentation for lvl 10 and 11 says:

    10 Rearrange Code (Linker Optimization): When
    detecting common block subroutines, code is rearranged
    to obtain larger recurring sequences.
    
    11 Reuse of Common Exit Code (Linker Optimization):
    Identical exit sequences are reused. This may reduce
    the size of common block subroutines even further.
    This optimization level generates the most compact
    program code possible.
    

    They are performed by the linker, so it would have been reasonable to think that the linker only performed these steps for the cases where the linker sees an actual benefit.

Reply
  • It is a bit strange to have 11 different optimization levels. That somehow gives an indication that each optimization has a natural order or at least cost in relation to every other optimization.

    Most compilers settles for maybe two or three optimization levels (little, medium and much or maybe fast, medium and expensive). This then complemented with another switch to inform the compiler if it should prioritize speed or size. And finally - for the control freaks - a full set of optimization flags to allow full customization of what optimization steps to use.

    One thing interesting here is the note that the total size tends to grow at optimization levels above 9, since the documentation for lvl 10 and 11 says:

    10 Rearrange Code (Linker Optimization): When
    detecting common block subroutines, code is rearranged
    to obtain larger recurring sequences.
    
    11 Reuse of Common Exit Code (Linker Optimization):
    Identical exit sequences are reused. This may reduce
    the size of common block subroutines even further.
    This optimization level generates the most compact
    program code possible.
    

    They are performed by the linker, so it would have been reasonable to think that the linker only performed these steps for the cases where the linker sees an actual benefit.

Children