2018-05-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / optimize-bswapsi-4.c
blobcfcc8324c57478f5fe5bad5c366868a0ae7c143c
1 /* { dg-do compile } */
2 /* { dg-require-effective-target bswap } */
3 /* { dg-options "-O2 -fdump-tree-bswap" } */
4 /* { dg-additional-options "-march=z900" { target s390-*-* } } */
6 typedef unsigned char u8;
7 typedef unsigned int u32;
8 union __anonunion
10 u32 value;
11 u8 bytes[4];
14 u32
15 acpi_ut_dword_byte_swap (u32 value)
17 union __anonunion in;
18 in.value = value;
19 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
20 return ((in.bytes[0] << 24) | (in.bytes[1] << 16)
21 | (in.bytes[2] << 8) | in.bytes[3]);
22 #else
23 return ((in.bytes[3] << 24) | (in.bytes[2] << 16)
24 | (in.bytes[1] << 8) | in.bytes[0]);
25 #endif
28 /* { dg-final { scan-tree-dump "32 bit bswap implementation found at" "bswap" } } */