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