This is the mail archive of the gcc-patches@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]

[PATCH] Speed up single-threaded case of atomic ops and reduce text size


This patch speeds up the Boost wave preprocessor by 1% and also improves
runtimes of the DLV testsuite by the same margin while reducing text-size
over a wider variety of libstdc++ users.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Ok for mainline?

For v7 we might want to remove the volatile qualifier from the
atomic ops interface.

Thanks,
Richard.

2006-08-16  Richard Guenther  <rguenther@suse.de>

	* include/bits/atomicity.h (__exchange_and_add_single): Use
	a not volatile-qualified pointer to access memory.
	(__atomic_add_single): Likewise.

Index: libstdc++-v3/include/bits/atomicity.h
===================================================================
*** libstdc++-v3/include/bits/atomicity.h	(revision 116006)
--- libstdc++-v3/include/bits/atomicity.h	(working copy)
*************** _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*** 62,75 ****
    static inline _Atomic_word
    __exchange_and_add_single(volatile _Atomic_word* __mem, int __val)
    {
!     _Atomic_word __result = *__mem;
!     *__mem += __val;
      return __result;
    }
  
    static inline void
    __atomic_add_single(volatile _Atomic_word* __mem, int __val)
!   { *__mem += __val; }
  
    static inline _Atomic_word
    __attribute__ ((__unused__))
--- 62,76 ----
    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; }
  
    static inline _Atomic_word
    __attribute__ ((__unused__))


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