[RS6000] Tests that use int128_t and -m32
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / optimize-bswapsi-2.c
blob46d9147d1404fd299937a71684e887a5cc11f348
1 /* { dg-require-effective-target stdint_types } */
2 /* { dg-options "-O2 -mdejagnu-cpu=power5" } */
4 #include <stdint.h>
6 /* This is a clone of gcc-dg/optimize-bswapsi-1.c, redone to use load and stores
7 to test whether lwbrx/stwbrx is generated for normal power systems. */
9 #define __const_swab32(x) ((uint32_t)( \
10 (((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) | \
11 (((uint32_t)(x) & (uint32_t)0x0000ff00UL) << 8) | \
12 (((uint32_t)(x) & (uint32_t)0x00ff0000UL) >> 8) | \
13 (((uint32_t)(x) & (uint32_t)0xff000000UL) >> 24)))
15 /* This byte swap implementation is used by the Linux kernel and the
16 GNU C library. */
18 uint32_t
19 swap32_a_load (uint32_t *in)
21 return __const_swab32 (*in);
24 /* The OpenSSH byte swap implementation. */
25 uint32_t
26 swap32_b_load (uint32_t *in)
28 uint32_t a;
30 a = (*in << 16) | (*in >> 16);
31 a = ((a & 0x00ff00ff) << 8) | ((a & 0xff00ff00) >> 8);
33 return a;
36 void
37 swap32_a_store (uint32_t *out, uint32_t in)
39 *out = __const_swab32 (in);
42 /* The OpenSSH byte swap implementation. */
43 void
44 swap32_b_store (uint32_t *out, uint32_t in)
46 uint32_t a;
48 a = (in << 16) | (in >> 16);
49 a = ((a & 0x00ff00ff) << 8) | ((a & 0xff00ff00) >> 8);
51 *out = a;
54 /* { dg-final { scan-assembler-times "lwbrx" 2 } } */
55 /* { dg-final { scan-assembler-times "stwbrx" 2 } } */