Debian Codegraph @

gcc/testsuite/c-c++-common/gomp/atomic-28.c

raw
1 /* { dg-do compile } */
2 /* { dg-additional-options "-O2 -fdump-tree-ompexp" } */
3 /* { dg-final { scan-tree-dump-times "\.ATOMIC_COMPARE_EXCHANGE \\\(\[^\n\r]*, 4, 5, 5\\\);" 1 "ompexp" { target sync_int_long } } } */
4 /* { dg-final { scan-tree-dump-times "\.ATOMIC_COMPARE_EXCHANGE \\\(\[^\n\r]*, 4, 4, 2\\\);" 1 "ompexp" { target sync_int_long } } } */
5 /* { dg-final { scan-tree-dump-times "\.ATOMIC_COMPARE_EXCHANGE \\\(\[^\n\r]*, 260, 5, 0\\\);" 1 "ompexp" { target sync_int_long } } } */
6 /* { dg-final { scan-tree-dump-times "\.ATOMIC_COMPARE_EXCHANGE \\\(\[^\n\r]*, 4, 0, 0\\\);" 1 "ompexp" { target sync_int_long } } } */
7 /* { dg-final { scan-tree-dump-not "__atomic_load_4 \\\(" "ompexp" { target sync_int_long } } } */
8
9 int x;
10
11 void
12 foo (int y, int z)
13 {
14 #pragma omp atomic compare seq_cst
15 x = x == y ? z : x;
16 }
17
18 int
19 bar (int y, int z)
20 {
21 int r;
22 #pragma omp atomic compare capture acq_rel fail (acquire)
23 { r = x == y; if (r) { x = z; } }
24 return r;
25 }
26
27 int
28 baz (int y, int z)
29 {
30 int v;
31 #pragma omp atomic compare capture seq_cst fail (relaxed) weak
32 if (x == y) { x = z; } else { v = x; }
33 return v;
34 }
35
36 int
37 qux (int y, int z)
38 {
39 int v;
40 #pragma omp atomic compare capture
41 v = x = x == y ? z : x;
42 return v;
43 }