[RS6000] Tests that use int128_t and -m32
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / p9-xxbr-3.c
blob62a946fd2b3f26555b40e612d227b5b8465cae52
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. */
9 unsigned short
10 do_bswap16_mem (unsigned short *p)
12 return __builtin_bswap16 (*p); /* LHBRX. */
15 unsigned short
16 do_bswap16_reg (unsigned short a)
18 return __builtin_bswap16 (a); /* gpr sequences. */
21 void
22 do_bswap16_store (unsigned short *p, unsigned short a)
24 *p = __builtin_bswap16 (a); /* STHBRX. */
27 unsigned short
28 do_bswap16_vect (unsigned short a)
30 __asm__ (" # %x0" : "+v" (a));
31 return __builtin_bswap16 (a); /* XXBRW. */
34 unsigned int
35 do_bswap32_mem (unsigned int *p)
37 return __builtin_bswap32 (*p); /* LWBRX. */
40 unsigned int
41 do_bswap32_reg (unsigned int a)
43 return __builtin_bswap32 (a); /* gpr sequences. */
46 void
47 do_bswap32_store (unsigned int *p, unsigned int a)
49 *p = __builtin_bswap32 (a); /* STWBRX. */
52 unsigned int
53 do_bswap32_vect (unsigned int a)
55 __asm__ (" # %x0" : "+v" (a));
56 return __builtin_bswap32 (a); /* XXBRW. */
59 unsigned long
60 do_bswap64_mem (unsigned long *p)
62 return __builtin_bswap64 (*p); /* LDBRX. */
65 unsigned long
66 do_bswap64_reg (unsigned long a)
68 return __builtin_bswap64 (a); /* gpr sequences. */
71 void
72 do_bswap64_store (unsigned long *p, unsigned int a)
74 *p = __builtin_bswap64 (a); /* STDBRX. */
77 double
78 do_bswap64_double (unsigned long a)
80 return (double) __builtin_bswap64 (a); /* XXBRD. */
83 unsigned long
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 } } */