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