| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -marm" } */ |
| 3 |
/* { dg-require-effective-target arm_arch_v7a_ok } */ |
| 4 |
/* { dg-add-options arm_arch_v7a } */ |
| 5 |
|
| 6 |
/* Make sure that RTL optimizers don't do any unexpected transformations |
| 7 |
on the compare_exchange loop. */ |
| 8 |
|
| 9 |
#include <stdatomic.h> |
| 10 |
|
| 11 |
atomic_uint foo; |
| 12 |
atomic_uint bar; |
| 13 |
int glob; |
| 14 |
|
| 15 |
int |
| 16 |
main (void) |
| 17 |
{ |
| 18 |
glob = atomic_compare_exchange_strong (&foo, &bar, 0); |
| 19 |
return glob; |
| 20 |
} |
| 21 |
|
| 22 |
/* { dg-final { scan-assembler-times "dmb\tish" 2 } } */ |
| 23 |
/* { dg-final { scan-assembler-times "ldrex\t" 1 } } */ |
| 24 |
/* { dg-final { scan-assembler-times "strex\t" 1 } } */ |