Debian Codegraph @

gcc/testsuite/g++.target/i386/pr102566-5a.C

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