This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]