Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Which compiler optimizations are "safe" and which are "dangerous"?

Status
Not open for further replies.

blapcb

Full Member level 3
Joined
Jan 7, 2007
Messages
188
Helped
2
Reputation
4
Reaction score
0
Trophy points
1,296
Location
Planet earth (most of the time)
Activity points
2,766
Which compiler optimizations are "safe" and which are "dangerous"?

It is very easy to hit "High" on the compiler optimization options and it will definitely reduce code. However, it can also lead to unexpected results (or so I understand) if certain coding techniques are not followed.

My question is, are there any specific optimization options ("transformations") that are considered "safe" (i.e. not expected to introduce any risk) and others that are considered "risky"?

PS - I am using IAR Embedded Workbench for MSP430

Thanks
 

Re: Which compiler optimizations are "safe" and which are "dangerous"?

It is very easy to hit "High" on the compiler optimization options and it will definitely reduce code. However, it can also lead to unexpected results (or so I understand) if certain coding techniques are not followed.

My question is, are there any specific optimization options ("transformations") that are considered "safe" (i.e. not expected to introduce any risk) and others that are considered "risky"?

PS - I am using IAR Embedded Workbench for MSP430

Thanks

I also use IAR EW for AVR, all my projects are compiled in both debug and release mode (optimization for speed mainly). It doesn't matter if eventually the project is released in debug mode, I always want to check that the project is running succesfully with both modes. So my point is that you can trust IAR on this, I don't believe it would behave differently for AVR and MSP.
One detail you should have in mind is that a level 4 optimized project is very hard to debug, but still you can use directives for certain functions (see compiler guide from help menu), as well as asm("nop") commands for forcing breakpoints to be placed without problems.
As for special coding techniques, please follow the below thread about volatile variables.

https://www.edaboard.com/threads/233868/

Hope that helped.
Alexandros
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top