1 /* { dg-require-effective-target stdint_types } */
2 /* { dg-options "-O2 -mdejagnu-cpu=power5" } */
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
19 swap32_a_load (uint32_t *in
)
21 return __const_swab32 (*in
);
24 /* The OpenSSH byte swap implementation. */
26 swap32_b_load (uint32_t *in
)
30 a
= (*in
<< 16) | (*in
>> 16);
31 a
= ((a
& 0x00ff00ff) << 8) | ((a
& 0xff00ff00) >> 8);
37 swap32_a_store (uint32_t *out
, uint32_t in
)
39 *out
= __const_swab32 (in
);
42 /* The OpenSSH byte swap implementation. */
44 swap32_b_store (uint32_t *out
, uint32_t in
)
48 a
= (in
<< 16) | (in
>> 16);
49 a
= ((a
& 0x00ff00ff) << 8) | ((a
& 0xff00ff00) >> 8);
54 /* { dg-final { scan-assembler-times "lwbrx" 2 } } */
55 /* { dg-final { scan-assembler-times "stwbrx" 2 } } */