https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124960

            Bug ID: 124960
           Summary: [bug] __sync_val_compare_and_swap build-in failed on
                    aarch64
           Product: gcc
           Version: 14.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhenhangwang at huawei dot com
  Target Milestone: ---

demo.c:

```
volatile __attribute__((aligned (sizeof (__int128_t)))) __int128_t v = 10;

int
main ()
{
  if (__sync_val_compare_and_swap (&v, (__int128_t) 10, (__int128_t) 0) != 10)
    __builtin_abort ();
  if (__sync_val_compare_and_swap (&v, (__int128_t) 10, (__int128_t) 15) != 0)
    __builtin_abort ();
  if (__sync_val_compare_and_swap (&v, (__int128_t) 0, (__int128_t) 42) != 0)
    __builtin_abort ();
  if (__sync_val_compare_and_swap (&v, (__int128_t) 31, (__int128_t) 35) != 42)
    __builtin_abort ();
  return 0;
}

```
gcc -O2  -mbig-endian -mno-outline-atomics 

When using the __int128_t data type, two X-registers are required to store the
data. In this case, the registers used for comparison are incorrect on
aarch64_be.For specific details, you can refer to godbolt.

https://godbolt.org/z/xxf8fn689

Reply via email to