Mercurial > hg > CbC > CbC_gcc
diff gcc/testsuite/gcc.dg/optimize-bswapsi-4.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gcc/testsuite/gcc.dg/optimize-bswapsi-4.c Fri Oct 27 22:46:09 2017 +0900 @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target bswap32 } */ +/* { dg-options "-O2 -fdump-tree-bswap" } */ +/* { dg-additional-options "-march=z900" { target s390-*-* } } */ + +typedef unsigned char u8; +typedef unsigned int u32; +union __anonunion +{ + u32 value; + u8 bytes[4]; +}; + +u32 +acpi_ut_dword_byte_swap (u32 value) +{ + union __anonunion in; + in.value = value; +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + return ((in.bytes[0] << 24) | (in.bytes[1] << 16) + | (in.bytes[2] << 8) | in.bytes[3]); +#else + return ((in.bytes[3] << 24) | (in.bytes[2] << 16) + | (in.bytes[1] << 8) | in.bytes[0]); +#endif +} + +/* { dg-final { scan-tree-dump "32 bit bswap implementation found at" "bswap" } } */