aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/pr54087.c
blob: abb0af3d9bb36deb7e7c88bf3b4e1f579dbd19b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* PR54087.  Verify __atomic_sub (val) uses __atomic_add (-val) if there is no
             atomic_aub.  */
/* { dg-require-effective-target sync_int_long } */
/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
/* { dg-final { scan-assembler-times "xadd" 2 } } */


int a;

int f1(int p)
{
  return __atomic_sub_fetch(&a, p, __ATOMIC_SEQ_CST) == 0;
}

int f2(int p)
{
  return __atomic_fetch_sub(&a, p, __ATOMIC_SEQ_CST) - p == 0;
}