| 1 |
/* { dg-do compile { target { c++11 && { ! ia32 } } } } */ |
| 2 |
/* { dg-options "-O2" } */ |
| 3 |
|
| 4 |
#include <atomic> |
| 5 |
|
| 6 |
bool |
| 7 |
tbit0 (std::atomic<unsigned long long> &i) |
| 8 |
{ |
| 9 |
#define BIT (1ll << 0) |
| 10 |
return i.fetch_and(~BIT, std::memory_order_relaxed) & BIT; |
| 11 |
#undef BIT |
| 12 |
} |
| 13 |
|
| 14 |
bool |
| 15 |
tbit30 (std::atomic<unsigned long long> &i) |
| 16 |
{ |
| 17 |
#define BIT (1ll << 30) |
| 18 |
return i.fetch_and(~BIT, std::memory_order_relaxed) & BIT; |
| 19 |
#undef BIT |
| 20 |
} |
| 21 |
|
| 22 |
bool |
| 23 |
tbit31 (std::atomic<unsigned long long> &i) |
| 24 |
{ |
| 25 |
#define BIT (1ll << 63) |
| 26 |
return i.fetch_and(~BIT, std::memory_order_relaxed) & BIT; |
| 27 |
#undef BIT |
| 28 |
} |
| 29 |
|
| 30 |
/* { dg-final { scan-assembler-times "lock;?\[ \t\]*btrq" 3 } } */ |
| 31 |
/* { dg-final { scan-assembler-not "cmpxchg" } } */ |