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