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 qualifier hurts single-threaded optimized case


On 8/13/06, Paolo Carlini <pcarlini@suse.de> wrote:
Richard Guenther wrote:

> bits/atomicity.h has volatile qualifiers on the _Atomic_word*
> arguments to
> the __*_single and __*_dispatch variants of the atomic operations.  This
> huts especially the single-threaded optimization variants which are
> usually
> inlined.  Removing those qualifiers allows to reduce code size
> significantly
> as can be seen in the following simple testcase

Ok, what can be done, realistically, considering that __exchange_and_add
and __atomic_add are exported, thus in any case cannot change signature,
and, if possible, we would rather avoid too ugly casts?

For v3 nothing, as e.g rope still uses volatile atomic words and so we would get warnings passing them to unqualified versions. For v7 we should fix it and remove the qualifiers.

One could change __exchange_and_add_single and __atomic_add_single for
v3 with ugly casts as follows

 static inline _Atomic_word
 __exchange_and_add_single(volatile _Atomic_word* __mem, int __val)
 {
   _Atomic_word *__m = (_Atomic_word*)__mem;
   _Atomic_word __result = *__m;
   *__m += __val;
   return __result;
 }

 static inline void
 __atomic_add_single(volatile _Atomic_word* __mem, int __val)
 { _Atomic_word *__m = (_Atomic_word*)__mem; *__m += __val; }

which gives the same improvement.  But I really wanted to raise this
issue as a thing to consider for v7 plannings on changes in this areas.

Richard.


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