* gcc.dg/stack-check-5.c: Skip with -fstack-protector.
[official-gcc.git] / gcc / testsuite / gcc.dg / optimize-bswapsi-2.c
blob01ae3776ed3f44fbc300d001f8c67ec11625d03b
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*-*-* } } */
7 #include <stdint.h>
9 extern unsigned char data[4];
11 struct uint32_st {
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)
44 | (*data << 24);
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" } } */