1 /* { dg-require-effective-target stdint_types } */ 2 /* { dg-require-effective-target lp64 } */ 3 /* { dg-options "-O2 -mcpu=power7" } */ 4 5 /* This is a clone of gcc-dg/optimize-bswapdi-1.c, redone to use load and stores 6 to test whether ldbrx/stdbrx is generated for power7. */ 7 8 #include <stdint.h> 9 #define __const_swab64(x) ((uint64_t)( \ 10 (((uint64_t)(x) & (uint64_t)0x00000000000000ffULL) << 56) | \ 11 (((uint64_t)(x) & (uint64_t)0x000000000000ff00ULL) << 40) | \ 12 (((uint64_t)(x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \ 13 (((uint64_t)(x) & (uint64_t)0x00000000ff000000ULL) << 8) | \ 14 (((uint64_t)(x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \ 15 (((uint64_t)(x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \ 16 (((uint64_t)(x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \ 17 (((uint64_t)(x) & (uint64_t)0xff00000000000000ULL) >> 56))) 18 19 20 /* This byte swap implementation is used by the Linux kernel and the 21 GNU C library. */ 22 23 uint64_t swap64_load(uint64_t * in)24swap64_load (uint64_t *in) 25 { 26 return __const_swab64 (*in); 27 } 28 29 void swap64_store(uint64_t * out,uint64_t in)30swap64_store (uint64_t *out, uint64_t in) 31 { 32 *out = __const_swab64 (in); 33 } 34 35 /* { dg-final { scan-assembler "ldbrx" } } */ 36 /* { dg-final { scan-assembler "stdbrx" } } */ 37