[AArch64/arm] PR testsuite/85326 Avoid C++ tests when C++ compiler not present
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / pr49244-1.c
blob70ccf6e935a84e524de5bd0b3eabee5a3d6eb538
1 /* PR target/49244 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2" } */
5 void bar (void);
7 __attribute__((noinline, noclone)) int
8 f1 (int *a, int bit)
10 unsigned int mask = (1u << bit);
11 return (__sync_fetch_and_or (a, mask) & mask) != 0;
14 __attribute__((noinline, noclone)) int
15 f2 (int *a, int bit)
17 unsigned int mask = (1u << bit);
18 unsigned int t1 = __atomic_fetch_or (a, mask, __ATOMIC_RELAXED);
19 unsigned int t2 = t1 & mask;
20 return t2 != 0;
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
31 f4 (int *a)
33 unsigned int mask = (1u << 7);
34 return (__sync_fetch_and_or (a, mask) & mask) != 0;
37 __attribute__((noinline, noclone)) int
38 f5 (int *a)
40 unsigned int mask = (1u << 13);
41 return (__atomic_fetch_or (a, mask, __ATOMIC_RELAXED) & mask) != 0;
44 __attribute__((noinline, noclone)) int
45 f6 (int *a)
47 unsigned int mask = (1u << 0);
48 return (__atomic_fetch_or (a, mask, __ATOMIC_SEQ_CST) & mask) != 0;
51 __attribute__((noinline, noclone)) void
52 f7 (int *a, int bit)
54 unsigned int mask = (1u << bit);
55 if ((__sync_fetch_and_xor (a, mask) & mask) != 0)
56 bar ();
59 __attribute__((noinline, noclone)) void
60 f8 (int *a, int bit)
62 unsigned int mask = (1u << bit);
63 if ((__atomic_fetch_xor (a, mask, __ATOMIC_RELAXED) & mask) == 0)
64 bar ();
67 __attribute__((noinline, noclone)) int
68 f9 (int *a, int bit)
70 unsigned int mask = (1u << bit);
71 return (__atomic_fetch_xor (a, mask, __ATOMIC_SEQ_CST) & mask) != 0;
74 __attribute__((noinline, noclone)) int
75 f10 (int *a)
77 unsigned int mask = (1u << 7);
78 return (__sync_fetch_and_xor (a, mask) & mask) != 0;
81 __attribute__((noinline, noclone)) int
82 f11 (int *a)
84 unsigned int mask = (1u << 13);
85 return (__atomic_fetch_xor (a, mask, __ATOMIC_RELAXED) & mask) != 0;
88 __attribute__((noinline, noclone)) int
89 f12 (int *a)
91 unsigned int mask = (1u << 0);
92 return (__atomic_fetch_xor (a, mask, __ATOMIC_SEQ_CST) & mask) != 0;
95 __attribute__((noinline, noclone)) int
96 f13 (int *a, int bit)
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
117 f16 (int *a)
119 unsigned int mask = (1u << 7);
120 return (__sync_fetch_and_and (a, ~mask) & mask) != 0;
123 __attribute__((noinline, noclone)) int
124 f17 (int *a)
126 unsigned int mask = (1u << 13);
127 return (__atomic_fetch_and (a, ~mask, __ATOMIC_RELAXED) & mask) != 0;
130 __attribute__((noinline, noclone)) int
131 f18 (int *a)
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 } } */