summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/aarch64/atomic-op-relaxed.c
blob: 065ccf533064306989e1fb312bc53e9030184cac (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
/* { dg-do compile } */
/* { dg-options "-O2" } */

int v = 0;

int
atomic_fetch_add_RELAXED (int a)
{
  return __atomic_fetch_add (&v, a, __ATOMIC_RELAXED);
}

int
atomic_fetch_sub_RELAXED (int a)
{
  return __atomic_fetch_sub (&v, a, __ATOMIC_RELAXED);
}

int
atomic_fetch_and_RELAXED (int a)
{
  return __atomic_fetch_and (&v, a, __ATOMIC_RELAXED);
}

int
atomic_fetch_nand_RELAXED (int a)
{
  return __atomic_fetch_nand (&v, a, __ATOMIC_RELAXED);
}

int
atomic_fetch_xor_RELAXED (int a)
{
  return __atomic_fetch_xor (&v, a, __ATOMIC_RELAXED);
}

int
atomic_fetch_or_RELAXED (int a)
{
  return __atomic_fetch_or (&v, a, __ATOMIC_RELAXED);
}

/* { dg-final { scan-assembler-times "ldxr\tw\[0-9\]+, \\\[x\[0-9\]+\\\]" 6 } } */
/* { dg-final { scan-assembler-times "stxr\tw\[0-9\]+, w\[0-9\]+, \\\[x\[0-9\]+\\\]" 6 } } */