Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

RE: [AVR-Chat] TWI not working when optimization is on

2013-08-07 by Chuck Hackett

> From: John Samperi
>
> At 09:47 PM 7/08/2013, you wrote:
> >All works fine until I turn on optimization (-O).
> 
> You are turning it OFF!! The code will be HUGE and will not keep some
necessary
> tight timings. Very bad boy, use -Os at least which is good for most jobs.

Hi John,

I could be wrong, but, on page 86 of the GCC manual it says that "-O" (or
"-O1"):

"With ‘-O’, the compiler tries to reduce code size and execution time,
without performing any optimizations that take a great deal of compilation
time. ‘-O’ turns on the following optimization flags: ..."

For "-Os" it says:

"Optimize for size. ‘-Os’ enables all ‘-O2’ optimizations that do not
typically increase code size. It also performs further optimizations
designed to reduce code size."

As far as I can tell, "-O" turns on basic optimization.  When I use it no
optimization my code size is 73942 bytes (56.4% of an ATMega1284p) and 48660
bytes (37.1%) with "-O" specified.

So the code does get smaller with "-O" specified 

... and, just for completeness ... 44668 bytes (34.1%) with "-Os" specified
... :-)

... or did I misread something?
 
Cheers,

Chuck Hackett
"Good judgment comes from experience, experience comes from bad judgment"
7.5" gauge Union Pacific Northern (4-8-4) 844
http://www.whitetrout.net/Chuck

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.