2 /* { dg-do compile } */
3 /* { dg-options "-O2" } */
7 __attribute__((noinline
, noclone
)) int
10 unsigned int mask
= (1u << bit
);
11 return (__sync_fetch_and_or (a
, mask
) & mask
) != 0;
14 __attribute__((noinline
, noclone
)) int
17 unsigned int mask
= (1u << bit
);
18 unsigned int t1
= __atomic_fetch_or (a
, mask
, __ATOMIC_RELAXED
);
19 unsigned int t2
= t1
& mask
;
23 __attribute__((noinline
, noclone
)) long int
24 f3 (long int *a
, int bit
)
26 unsigned long int mask
= (1ul << bit
);
27 return (__atomic_fetch_or (a
, mask
, __ATOMIC_SEQ_CST
) & mask
) == 0;
30 __attribute__((noinline
, noclone
)) int
33 unsigned int mask
= (1u << 7);
34 return (__sync_fetch_and_or (a
, mask
) & mask
) != 0;
37 __attribute__((noinline
, noclone
)) int
40 unsigned int mask
= (1u << 13);
41 return (__atomic_fetch_or (a
, mask
, __ATOMIC_RELAXED
) & mask
) != 0;
44 __attribute__((noinline
, noclone
)) int
47 unsigned int mask
= (1u << 0);
48 return (__atomic_fetch_or (a
, mask
, __ATOMIC_SEQ_CST
) & mask
) != 0;
51 __attribute__((noinline
, noclone
)) void
54 unsigned int mask
= (1u << bit
);
55 if ((__sync_fetch_and_xor (a
, mask
) & mask
) != 0)
59 __attribute__((noinline
, noclone
)) void
62 unsigned int mask
= (1u << bit
);
63 if ((__atomic_fetch_xor (a
, mask
, __ATOMIC_RELAXED
) & mask
) == 0)
67 __attribute__((noinline
, noclone
)) int
70 unsigned int mask
= (1u << bit
);
71 return (__atomic_fetch_xor (a
, mask
, __ATOMIC_SEQ_CST
) & mask
) != 0;
74 __attribute__((noinline
, noclone
)) int
77 unsigned int mask
= (1u << 7);
78 return (__sync_fetch_and_xor (a
, mask
) & mask
) != 0;
81 __attribute__((noinline
, noclone
)) int
84 unsigned int mask
= (1u << 13);
85 return (__atomic_fetch_xor (a
, mask
, __ATOMIC_RELAXED
) & mask
) != 0;
88 __attribute__((noinline
, noclone
)) int
91 unsigned int mask
= (1u << 0);
92 return (__atomic_fetch_xor (a
, mask
, __ATOMIC_SEQ_CST
) & mask
) != 0;
95 __attribute__((noinline
, noclone
)) int
98 unsigned int mask
= (1u << bit
);
99 return (__sync_fetch_and_and (a
, ~mask
) & mask
) != 0;
102 __attribute__((noinline
, noclone
)) int
103 f14 (int *a
, int bit
)
105 unsigned int mask
= (1u << bit
);
106 return (__atomic_fetch_and (a
, ~mask
, __ATOMIC_RELAXED
) & mask
) != 0;
109 __attribute__((noinline
, noclone
)) int
110 f15 (int *a
, int bit
)
112 unsigned int mask
= (1u << bit
);
113 return (__atomic_fetch_and (a
, ~mask
, __ATOMIC_SEQ_CST
) & mask
) != 0;
116 __attribute__((noinline
, noclone
)) int
119 unsigned int mask
= (1u << 7);
120 return (__sync_fetch_and_and (a
, ~mask
) & mask
) != 0;
123 __attribute__((noinline
, noclone
)) int
126 unsigned int mask
= (1u << 13);
127 return (__atomic_fetch_and (a
, ~mask
, __ATOMIC_RELAXED
) & mask
) != 0;
130 __attribute__((noinline
, noclone
)) int
133 unsigned int mask
= (1u << 0);
134 return (__atomic_fetch_and (a
, ~mask
, __ATOMIC_SEQ_CST
) & mask
) != 0;
137 __attribute__((noinline
, noclone
)) unsigned long int
138 f19 (unsigned long int *a
, int bit
)
140 unsigned long int mask
= (1ul << bit
);
141 return (__atomic_xor_fetch (a
, mask
, __ATOMIC_SEQ_CST
) & mask
) != 0;
144 __attribute__((noinline
, noclone
)) unsigned long int
145 f20 (unsigned long int *a
)
147 unsigned long int mask
= (1ul << 7);
148 return (__atomic_xor_fetch (a
, mask
, __ATOMIC_SEQ_CST
) & mask
) == 0;
151 __attribute__((noinline
, noclone
)) int
152 f21 (int *a
, int bit
)
154 unsigned int mask
= (1u << bit
);
155 return (__sync_fetch_and_or (a
, mask
) & mask
);
158 __attribute__((noinline
, noclone
)) unsigned long int
159 f22 (unsigned long int *a
)
161 unsigned long int mask
= (1ul << 7);
162 return (__atomic_xor_fetch (a
, mask
, __ATOMIC_SEQ_CST
) & mask
);
165 __attribute__((noinline
, noclone
)) unsigned long int
166 f23 (unsigned long int *a
)
168 unsigned long int mask
= (1ul << 7);
169 return (__atomic_fetch_xor (a
, mask
, __ATOMIC_SEQ_CST
) & mask
);
172 __attribute__((noinline
, noclone
)) unsigned short int
173 f24 (unsigned short int *a
)
175 unsigned short int mask
= (1u << 7);
176 return (__sync_fetch_and_or (a
, mask
) & mask
) != 0;
179 __attribute__((noinline
, noclone
)) unsigned short int
180 f25 (unsigned short int *a
)
182 unsigned short int mask
= (1u << 7);
183 return (__atomic_fetch_or (a
, mask
, __ATOMIC_SEQ_CST
) & mask
) != 0;
186 /* { dg-final { scan-assembler-times "lock;?\[ \t\]*bts" 9 } } */
187 /* { dg-final { scan-assembler-times "lock;?\[ \t\]*btc" 10 } } */
188 /* { dg-final { scan-assembler-times "lock;?\[ \t\]*btr" 6 } } */