Debian Codegraph @

gcc/testsuite/gcc.dg/tree-ssa/pr103345.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-bswap-details" } */
3
4 typedef __UINT32_TYPE__ uint32_t;
5 typedef unsigned char uint8_t;
6
7 uint32_t load_le_32_or(const uint8_t *ptr)
8 {
9 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
10 return ((uint32_t)ptr[0]) |
11 ((uint32_t)ptr[1] << 8) |
12 ((uint32_t)ptr[2] << 16) |
13 ((uint32_t)ptr[3] << 24);
14 #else
15 return ((uint32_t)ptr[3]) |
16 ((uint32_t)ptr[2] << 8) |
17 ((uint32_t)ptr[1] << 16) |
18 ((uint32_t)ptr[0] << 24);
19 #endif
20 }
21
22 uint32_t load_le_32_add(const uint8_t *ptr)
23 {
24 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
25 return ((uint32_t)ptr[0]) +
26 ((uint32_t)ptr[1] << 8) +
27 ((uint32_t)ptr[2] << 16) +
28 ((uint32_t)ptr[3] << 24);
29 #else
30 return ((uint32_t)ptr[3]) +
31 ((uint32_t)ptr[2] << 8) +
32 ((uint32_t)ptr[1] << 16) +
33 ((uint32_t)ptr[0] << 24);
34 #endif
35 }
36
37 uint32_t load_le_32_xor(const uint8_t *ptr)
38 {
39 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
40 return ((uint32_t)ptr[0]) ^
41 ((uint32_t)ptr[1] << 8) ^
42 ((uint32_t)ptr[2] << 16) ^
43 ((uint32_t)ptr[3] << 24);
44 #else
45 return ((uint32_t)ptr[3]) ^
46 ((uint32_t)ptr[2] << 8) ^
47 ((uint32_t)ptr[1] << 16) ^
48 ((uint32_t)ptr[0] << 24);
49 #endif
50 }
51
52 /* { dg-final { scan-tree-dump-times "32 bit load in target endianness found" 3 "bswap" } } */
53