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