1 /* { dg-do compile { target lp64 } } */
2 /* { dg-require-effective-target powerpc_p9vector_ok } */
3 /* { dg-options "-mdejagnu-cpu=power9 -O2" } */
5 /* Verify that the XXBR{H,W} instructions are generated if the value is
6 forced to be in a vector register, and XXBRD is generated all of the
7 time for register bswap64's. */
10 do_bswap16_mem (unsigned short *p
)
12 return __builtin_bswap16 (*p
); /* LHBRX. */
16 do_bswap16_reg (unsigned short a
)
18 return __builtin_bswap16 (a
); /* gpr sequences. */
22 do_bswap16_store (unsigned short *p
, unsigned short a
)
24 *p
= __builtin_bswap16 (a
); /* STHBRX. */
28 do_bswap16_vect (unsigned short a
)
30 __asm__ (" # %x0" : "+v" (a
));
31 return __builtin_bswap16 (a
); /* XXBRW. */
35 do_bswap32_mem (unsigned int *p
)
37 return __builtin_bswap32 (*p
); /* LWBRX. */
41 do_bswap32_reg (unsigned int a
)
43 return __builtin_bswap32 (a
); /* gpr sequences. */
47 do_bswap32_store (unsigned int *p
, unsigned int a
)
49 *p
= __builtin_bswap32 (a
); /* STWBRX. */
53 do_bswap32_vect (unsigned int a
)
55 __asm__ (" # %x0" : "+v" (a
));
56 return __builtin_bswap32 (a
); /* XXBRW. */
60 do_bswap64_mem (unsigned long *p
)
62 return __builtin_bswap64 (*p
); /* LDBRX. */
66 do_bswap64_reg (unsigned long a
)
68 return __builtin_bswap64 (a
); /* gpr sequences. */
72 do_bswap64_store (unsigned long *p
, unsigned int a
)
74 *p
= __builtin_bswap64 (a
); /* STDBRX. */
78 do_bswap64_double (unsigned long a
)
80 return (double) __builtin_bswap64 (a
); /* XXBRD. */
84 do_bswap64_vect (unsigned long a
)
86 __asm__ (" # %x0" : "+v" (a
)); /* XXBRD. */
87 return __builtin_bswap64 (a
);
90 /* Make sure XXBR{H,W,D} is not generated by default. */
91 /* { dg-final { scan-assembler-times "xxbrd" 3 } } */
92 /* { dg-final { scan-assembler-times "xxbrh" 1 } } */
93 /* { dg-final { scan-assembler-times "xxbrw" 1 } } */
94 /* { dg-final { scan-assembler-times "ldbrx" 1 } } */
95 /* { dg-final { scan-assembler-times "lhbrx" 1 } } */
96 /* { dg-final { scan-assembler-times "lwbrx" 1 } } */
97 /* { dg-final { scan-assembler-times "stdbrx" 1 } } */
98 /* { dg-final { scan-assembler-times "sthbrx" 1 } } */
99 /* { dg-final { scan-assembler-times "stwbrx" 1 } } */