avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] volatile...


From: Joerg Wunsch
Subject: Re: [avr-gcc-list] volatile...
Date: Fri, 15 Dec 2006 09:33:13 +0100 (MET)

Javier Almansa Sobrino <address@hidden> wrote:

> I've noted a non volatile variable is like don't exists (I think).

A local variable can often be optimized by the compiler into a
register, and it will live there only for the short amount of time
when its value is really needed.  It might not even exist at all,
e. g. if you're assigning some value to a local variable, but then
only use that variable inside a few expressions that all look the
same, the compiler might as well pre-compute that entire expression,
and store its value instead.  (This is called "common subexpression
elimination", or CSE.)

As others have explained, access to objects qualified "volatile" must
not be optimized away by the compiler, so you'll inhibit all of these
optimizations.  The outcome is that you might debug it a bit better,
at the price of poorer code.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]