aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/pr49244-1.c
blob: 70ccf6e935a84e524de5bd0b3eabee5a3d6eb538 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/* PR target/49244 */
/* { dg-do compile } */
/* { dg-options "-O2" } */

void bar (void);

__attribute__((noinline, noclone)) int
f1 (int *a, int bit)
{
  unsigned int mask = (1u << bit);
  return (__sync_fetch_and_or (a, mask) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f2 (int *a, int bit)
{
  unsigned int mask = (1u << bit);
  unsigned int t1 = __atomic_fetch_or (a, mask, __ATOMIC_RELAXED);
  unsigned int t2 = t1 & mask;
  return t2 != 0;
}

__attribute__((noinline, noclone)) long int
f3 (long int *a, int bit)
{
  unsigned long int mask = (1ul << bit);
  return (__atomic_fetch_or (a, mask, __ATOMIC_SEQ_CST) & mask) == 0;
}

__attribute__((noinline, noclone)) int
f4 (int *a)
{
  unsigned int mask = (1u << 7);
  return (__sync_fetch_and_or (a, mask) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f5 (int *a)
{
  unsigned int mask = (1u << 13);
  return (__atomic_fetch_or (a, mask, __ATOMIC_RELAXED) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f6 (int *a)
{
  unsigned int mask = (1u << 0);
  return (__atomic_fetch_or (a, mask, __ATOMIC_SEQ_CST) & mask) != 0;
}

__attribute__((noinline, noclone)) void
f7 (int *a, int bit)
{
  unsigned int mask = (1u << bit);
  if ((__sync_fetch_and_xor (a, mask) & mask) != 0)
    bar ();
}

__attribute__((noinline, noclone)) void
f8 (int *a, int bit)
{
  unsigned int mask = (1u << bit);
  if ((__atomic_fetch_xor (a, mask, __ATOMIC_RELAXED) & mask) == 0)
    bar ();
}

__attribute__((noinline, noclone)) int
f9 (int *a, int bit)
{
  unsigned int mask = (1u << bit);
  return (__atomic_fetch_xor (a, mask, __ATOMIC_SEQ_CST) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f10 (int *a)
{
  unsigned int mask = (1u << 7);
  return (__sync_fetch_and_xor (a, mask) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f11 (int *a)
{
  unsigned int mask = (1u << 13);
  return (__atomic_fetch_xor (a, mask, __ATOMIC_RELAXED) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f12 (int *a)
{
  unsigned int mask = (1u << 0);
  return (__atomic_fetch_xor (a, mask, __ATOMIC_SEQ_CST) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f13 (int *a, int bit)
{
  unsigned int mask = (1u << bit);
  return (__sync_fetch_and_and (a, ~mask) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f14 (int *a, int bit)
{
  unsigned int mask = (1u << bit);
  return (__atomic_fetch_and (a, ~mask, __ATOMIC_RELAXED) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f15 (int *a, int bit)
{
  unsigned int mask = (1u << bit);
  return (__atomic_fetch_and (a, ~mask, __ATOMIC_SEQ_CST) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f16 (int *a)
{
  unsigned int mask = (1u << 7);
  return (__sync_fetch_and_and (a, ~mask) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f17 (int *a)
{
  unsigned int mask = (1u << 13);
  return (__atomic_fetch_and (a, ~mask, __ATOMIC_RELAXED) & mask) != 0;
}

__attribute__((noinline, noclone)) int
f18 (int *a)
{
  unsigned int mask = (1u << 0);
  return (__atomic_fetch_and (a, ~mask, __ATOMIC_SEQ_CST) & mask) != 0;
}

__attribute__((noinline, noclone)) unsigned long int
f19 (unsigned long int *a, int bit)
{
  unsigned long int mask = (1ul << bit);
  return (__atomic_xor_fetch (a, mask, __ATOMIC_SEQ_CST) & mask) != 0;
}

__attribute__((noinline, noclone)) unsigned long int
f20 (unsigned long int *a)
{
  unsigned long int mask = (1ul << 7);
  return (__atomic_xor_fetch (a, mask, __ATOMIC_SEQ_CST) & mask) == 0;
}

__attribute__((noinline, noclone)) int
f21 (int *a, int bit)
{
  unsigned int mask = (1u << bit);
  return (__sync_fetch_and_or (a, mask) & mask);
}

__attribute__((noinline, noclone)) unsigned long int
f22 (unsigned long int *a)
{
  unsigned long int mask = (1ul << 7);
  return (__atomic_xor_fetch (a, mask, __ATOMIC_SEQ_CST) & mask);
}

__attribute__((noinline, noclone)) unsigned long int
f23 (unsigned long int *a)
{
  unsigned long int mask = (1ul << 7);
  return (__atomic_fetch_xor (a, mask, __ATOMIC_SEQ_CST) & mask);
}

__attribute__((noinline, noclone)) unsigned short int
f24 (unsigned short int *a)
{
  unsigned short int mask = (1u << 7);
  return (__sync_fetch_and_or (a, mask) & mask) != 0;
}

__attribute__((noinline, noclone)) unsigned short int
f25 (unsigned short int *a)
{
  unsigned short int mask = (1u << 7);
  return (__atomic_fetch_or (a, mask, __ATOMIC_SEQ_CST) & mask) != 0;
}

/* { dg-final { scan-assembler-times "lock;?\[ \t\]*bts" 9 } } */
/* { dg-final { scan-assembler-times "lock;?\[ \t\]*btc" 10 } } */
/* { dg-final { scan-assembler-times "lock;?\[ \t\]*btr" 6 } } */