1 /* { dg-do compile } */
2 /* { dg-require-effective-target bswap } */
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 static inline unsigned short
48 get_unaligned_16_le (unsigned char *p
)
50 return p
[0] | (p
[1] << 8);
53 get_unaligned_32_le (unsigned char *p
)
55 return get_unaligned_16_le (p
) | (get_unaligned_16_le (p
+ 2) << 16);
58 static inline unsigned short
59 get_unaligned_16_be (unsigned char *p
)
61 return p
[1] | (p
[0] << 8);
64 get_unaligned_32_be (unsigned char *p
)
66 return get_unaligned_16_be (p
+ 2) | (get_unaligned_16_be (p
) << 16);
69 /* { dg-final { scan-tree-dump-times "32 bit load in target endianness found at" 4 "bswap" } } */
70 /* { dg-final { scan-tree-dump-times "32 bit bswap implementation found at" 4 "bswap" } } */