public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/39677]  New: AMD Opteron E needs workaround for lock erratum
@ 2009-04-07 13:36 bonzini at gnu dot org
  2009-10-13  1:07 ` [Bug target/39677] " rth at gcc dot gnu dot org
  2009-12-07 16:12 ` rth at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: bonzini at gnu dot org @ 2009-04-07 13:36 UTC (permalink / raw)
  To: gcc-bugs

From
http://code.google.com/p/google-perftools/source/browse/trunk/src/base/atomicops-internals-x86.h

  bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence
                            // after acquire compare-and-swap.

...

inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
                                         Atomic32 old_value,
                                         Atomic32 new_value) {
  Atomic32 prev;
  __asm__ __volatile__("lock; cmpxchgl %1,%2"
                       : "=a" (prev)
                       : "q" (new_value), "m" (*ptr), "0" (old_value)
                       : "memory");
  return prev;
}

inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
                                       Atomic32 old_value,
                                       Atomic32 new_value) {
  Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);
  if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
    __asm__ __volatile__("lfence" : : : "memory");
  }
  return x;
}

inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
                                       Atomic32 old_value,
                                       Atomic32 new_value) {
  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
}

This bug can also affect lock+xadd combinations.


-- 
           Summary: AMD Opteron E needs workaround for lock erratum
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: openmp
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bonzini at gnu dot org
GCC target triplet: i386-*-*, x86_64-*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39677


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-19 18:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-39677-4@http.gcc.gnu.org/bugzilla/>
2021-07-19 18:28 ` [Bug target/39677] AMD Opteron E needs workaround for lock erratum pinskia at gcc dot gnu.org
2009-04-07 13:36 [Bug middle-end/39677] New: " bonzini at gnu dot org
2009-10-13  1:07 ` [Bug target/39677] " rth at gcc dot gnu dot org
2009-12-07 16:12 ` rth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).