| 1 |
/* { dg-do run { target { powerpc*-*-* && lp64 } } } */ |
| 2 |
/* { dg-skip-if "" { powerpc*-*-darwin* } } */ |
| 3 |
/* { dg-options "-mdejagnu-cpu=power8 -O3" } */ |
| 4 |
|
| 5 |
void abort (void); |
| 6 |
|
| 7 |
typedef unsigned U_16 __attribute__((mode(TI))); |
| 8 |
|
| 9 |
extern int libat_compare_exchange_16 (U_16 *, U_16 *, U_16, int, int) |
| 10 |
__attribute__((__noinline__)); |
| 11 |
|
| 12 |
/* PR 57744: lqarx/stqcx needs even/odd register pairs. The assembler will |
| 13 |
complain if the compiler gets an odd/even register pair. Create a function |
| 14 |
which has the 16 byte compare and exchange instructions, but don't actually |
| 15 |
execute it, so that we can detect these failures on older machines. */ |
| 16 |
|
| 17 |
int |
| 18 |
libat_compare_exchange_16 (U_16 *mptr, U_16 *eptr, U_16 newval, |
| 19 |
int smodel, int fmodel __attribute__((unused))) |
| 20 |
{ |
| 21 |
if (((smodel) == 0)) |
| 22 |
return __atomic_compare_exchange_n (mptr, eptr, newval, 0, 0, 0); |
| 23 |
else if (((smodel) != 5)) |
| 24 |
return __atomic_compare_exchange_n (mptr, eptr, newval, 0, 4, 0); |
| 25 |
else |
| 26 |
return __atomic_compare_exchange_n (mptr, eptr, newval, 0, 5, 0); |
| 27 |
} |
| 28 |
|
| 29 |
U_16 a = 1, b = 1, c = -2; |
| 30 |
volatile int do_test = 0; |
| 31 |
|
| 32 |
int main (void) |
| 33 |
{ |
| 34 |
if (do_test && !libat_compare_exchange_16 (&a, &b, c, 0, 0)) |
| 35 |
abort (); |
| 36 |
|
| 37 |
return 0; |
| 38 |
} |