annotate gcc/testsuite/gcc.dg/atomic-op-optimize.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Both these atomic operations should be optimized to an exchange operation.
kono
parents:
diff changeset
2 Test that it at happens on x86 by making sure there are 2 xchg's and no
kono
parents:
diff changeset
3 compare_exchange loop. */
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
kono
parents:
diff changeset
6 /* { dg-require-effective-target sync_int_long } */
kono
parents:
diff changeset
7 /* { dg-final { scan-assembler-times "cmpxchg" 0 } } */
kono
parents:
diff changeset
8 /* { dg-final { scan-assembler-times "xchg" 2 } } */
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 int x;
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 int f()
kono
parents:
diff changeset
13 {
kono
parents:
diff changeset
14 return __atomic_fetch_and (&x, 0, __ATOMIC_RELAXED);
kono
parents:
diff changeset
15 }
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 int g()
kono
parents:
diff changeset
18 {
kono
parents:
diff changeset
19 return __atomic_fetch_or (&x, -1, __ATOMIC_RELAXED);
kono
parents:
diff changeset
20 }