LWG 3035. std::allocator's constructors should be constexpr
[official-gcc.git] / gcc / testsuite / gcc.dg / optimize-bswaphi-1.c
blobdcd3c2872d64d2828fdac262b50bb7b614436e5e
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-*-* } } */
7 #include <stdint.h>
9 unsigned char data[2];
11 struct uint16_st {
12 unsigned char u0, u1;
15 uint32_t read_le16_1 (void)
17 return data[0] | (data[1] << 8);
20 uint32_t read_le16_2 (struct uint16_st data)
22 return data.u0 | (data.u1 << 8);
25 uint32_t read_le16_3 (unsigned char *data)
27 return *data | (*(data + 1) << 8);
30 uint32_t read_be16_1 (void)
32 return data[1] | (data[0] << 8);
35 uint32_t read_be16_2 (struct uint16_st data)
37 return data.u1 | (data.u0 << 8);
40 uint32_t read_be16_3 (unsigned char *data)
42 return *(data + 1) | (*data << 8);
45 typedef int HItype __attribute__ ((mode (HI)));
47 /* Test that detection of significant sign extension works correctly. This
48 checks that unknown byte markers are set correctly in cast of cast. */
50 HItype
51 swap16 (HItype in)
53 return (HItype) (((in >> 0) & 0xFF) << 8)
54 | (((in >> 8) & 0xFF) << 0);
57 /* { dg-final { scan-tree-dump-times "16 bit load in target endianness found at" 3 "bswap" } } */
58 /* { dg-final { scan-tree-dump-times "16 bit bswap implementation found at" 4 "bswap" } } */