1 /* { dg-do compile } */
2 /* { dg-require-effective-target bswap32 } */
3 /* { dg-require-effective-target stdint_types } */
4 /* { dg-options "-O2 -fdump-tree-bswap" } */
5 /* { dg-additional-options "-march=z900" { target s390*-*-* } } */
9 extern unsigned char data
[4];
12 unsigned char u0
, u1
, u2
, u3
;
15 uint32_t read_le32_1 (void)
17 return data
[0] | (data
[1] << 8) | (data
[2] << 16) | (data
[3] << 24);
20 uint32_t read_le32_2 (struct uint32_st data
)
22 return data
.u0
| (data
.u1
<< 8) | (data
.u2
<< 16) | (data
.u3
<< 24);
25 uint32_t read_le32_3 (unsigned char *data
)
27 return *data
| (*(data
+ 1) << 8) | (*(data
+ 2) << 16)
28 | (*(data
+ 3) << 24);
31 uint32_t read_be32_1 (void)
33 return data
[3] | (data
[2] << 8) | (data
[1] << 16) | (data
[0] << 24);
36 uint32_t read_be32_2 (struct uint32_st data
)
38 return data
.u3
| (data
.u2
<< 8) | (data
.u1
<< 16) | (data
.u0
<< 24);
41 uint32_t read_be32_3 (unsigned char *data
)
43 return *(data
+ 3) | (*(data
+ 2) << 8) | (*(data
+ 1) << 16)
47 /* { dg-final { scan-tree-dump-times "32 bit load in target endianness found at" 3 "bswap" } } */
48 /* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 3 "bswap" } } */