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

[Bug target/55492] New: __atomic_load doesn't match ACQUIRE memory model


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

             Bug #: 55492
           Summary: __atomic_load doesn't match ACQUIRE memory model
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: yvan.roux@linaro.org


Created attachment 28796
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28796
Generic expansion patch proposal

Compiling this code for ARMv7

int v;

int foo()
{
  return __atomic_load_n (&v, __ATOMIC_ACQUIRE);
}

generates a data memory barrier defore the load:

foo:
    movw    r3, #:lower16:v
    movt    r3, #:upper16:v
    dmb     sy
    ldr     r0, [r3, #0]
    bx      lr

But, the `Acquireâ semantics imply that no reads in the current thread
dependent on the value currently loaded can be reordered before this load.
Thus, the barrier needs to be after the load and not before.

The issue seems to be in expand_atomic_load which put a memory fence before
the load in any memory model. The attached patch fixes the problem.


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