This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: volatile semantics
- From: Michael Veksler <VEKSLER at il dot ibm dot com>
- To: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- Cc: Dale Johannesen <dalej at apple dot com>, Daniel Berlin <dberlin at dberlin dot org>, gcc at gcc dot gnu dot org, "D. Hugh Redelmeier" <hugh at mimosa dot com>, joseph at codesourcery dot com, Mike Stump <mrs at apple dot com>, Nathan Sidwell <nathan at codesourcery dot com>
- Date: Sun, 17 Jul 2005 07:32:37 +0300
- Subject: Re: volatile semantics
Gabriel Dos Reis wrote on 17/07/2005 06:07:29:
>
> | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20222
>
> Andrew Pinski has declared this to be a bug, but the audit trail
> isn't clear as to why.
>
Maybe because gcc treats -O1 differently from -O2, -O3,
and -Os ? Also, since abs is a (built in) function, passing
extern volatile int i1;
as a parameter to abs(int) should be generating a single
memory access - only when the parameter is created.
The implementation of abs should not matter in this case -
as the parameter has already been copied.
If abs was implemented as inline rather than built in:
inline int abs(int a) { return a < 0 ? -a : a ; }
would it still generate 2 loads? This does not make sense,
since abs is a separate function, with `a' being declared as
a non-volatile variable.
Michael