| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-mv3-atomics -O2 -masm=pseudoc" } */ |
| 3 |
|
| 4 |
int |
| 5 |
foo (int *p, int *expected, int desired) |
| 6 |
{ |
| 7 |
return __atomic_compare_exchange (p, expected, &desired, 0, |
| 8 |
__ATOMIC_ACQUIRE, __ATOMIC_RELAXED); |
| 9 |
} |
| 10 |
|
| 11 |
int |
| 12 |
foo64 (long *p, long *expected, long desired) |
| 13 |
{ |
| 14 |
return __atomic_compare_exchange (p, expected, &desired, 0, |
| 15 |
__ATOMIC_ACQUIRE, __ATOMIC_RELAXED); |
| 16 |
} |
| 17 |
|
| 18 |
int |
| 19 |
bar (int *p, int *new) |
| 20 |
{ |
| 21 |
int old; |
| 22 |
__atomic_exchange (p, new, &old, __ATOMIC_RELAXED); |
| 23 |
return old; |
| 24 |
} |
| 25 |
|
| 26 |
int |
| 27 |
bar64 (long *p, long *new) |
| 28 |
{ |
| 29 |
long old; |
| 30 |
__atomic_exchange (p, new, &old, __ATOMIC_SEQ_CST); |
| 31 |
return old; |
| 32 |
} |
| 33 |
|
| 34 |
/* { dg-final { scan-assembler "r. = cmpxchg_64\\(r.\\+0, r., r.\\)" } } */ |
| 35 |
/* { dg-final { scan-assembler "w. = cmpxchg32_32\\(r.\\+0, w., w.\\)" } } */ |
| 36 |
/* { dg-final { scan-assembler-times "w. = xchg32_32\\(r.\\+0, w.\\)" 1 } } */ |
| 37 |
/* { dg-final { scan-assembler-times "r. = xchg_64\\(r.\\+0, r.\\)" 1 } } */ |
| 38 |
|