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

C compiler optimazation

Hallo

I have been looking into compiler optimazation. My project has a level of 0 - No optimazation
As I can read from the help file, default is level 2. Using level 2 will decrease the size but also remove the possiblity to debug.
Thats ok for released version of the software.

But are there any benefits, other then smaller code size, using compiler optimazation? I mean, is there any performance gain ? Better interrupt respons etc?
I don't have any problem fitting un-optimized code into the flash.

But if using optimazation makes it hard to debug, then its difficult to "debug" any problems caused by the optimazation? Is there any gurantie, that if the code work with no optimazation, then its behaves the same with optimazations on??

/Thomas

Parents
  • But are there any benefits, other then smaller code size, using compiler optimazation?

    Quite possibly, yes.

    I mean, is there any performance gain ?

    Definitely.

    Better interrupt respons etc?

    Quite possibly.

    But if using optimazation makes it hard to debug, then its difficult to "debug" any problems caused by the optimazation?

    It's usually fairly easy to tell whether a problem is caused directly by the compiler optimizations, since it will disappear at a lower optimization setting. A more detailed analysis usually required a look at the assembly output for the passage in question.

    Is there any gurantie, that if the code work with no optimazation, then its behaves the same with optimazations on??

    No, there's no such guarantee. In fact, as far as issues like timing are concerned, it's safe to assume that the optimized code will behave differently.

Reply
  • But are there any benefits, other then smaller code size, using compiler optimazation?

    Quite possibly, yes.

    I mean, is there any performance gain ?

    Definitely.

    Better interrupt respons etc?

    Quite possibly.

    But if using optimazation makes it hard to debug, then its difficult to "debug" any problems caused by the optimazation?

    It's usually fairly easy to tell whether a problem is caused directly by the compiler optimizations, since it will disappear at a lower optimization setting. A more detailed analysis usually required a look at the assembly output for the passage in question.

    Is there any gurantie, that if the code work with no optimazation, then its behaves the same with optimazations on??

    No, there's no such guarantee. In fact, as far as issues like timing are concerned, it's safe to assume that the optimized code will behave differently.

Children
No data