summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr86314.c
blob: 8962a3cf2ff7a89a19854773f5f6eece0950922e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// PR target/86314
// { dg-do run { target sync_int_long } }
// { dg-options "-O2" }

__attribute__((noinline, noclone)) unsigned long
foo (unsigned long *p)
{
  unsigned long m = 1UL << ((*p & 1) ? 1 : 0);
  unsigned long n = __atomic_fetch_or (p, m, __ATOMIC_SEQ_CST);
  return (n & m) == 0;
}

int
main ()
{
  unsigned long v = 1;
  if (foo (&v) != 1)
    __builtin_abort ();
  return 0;
}