libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / ipa / pr102714.c
blob8ab77a61d75bd24d1069f2909a73f9a4fec4779e
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fno-strict-aliasing -fdump-ipa-sra-details -fdump-tree-optimized" } */
4 typedef _Bool bool;
6 enum {
7 false = 0,
8 true = 1
9 };
11 struct xarray {
12 unsigned int xa_lock;
13 unsigned int xa_flags;
14 void * xa_head;
18 struct list_head {
19 struct list_head *next, *prev;
22 struct callback_head {
23 struct callback_head *next;
24 void (*func)(struct callback_head *head);
25 } __attribute__((aligned(sizeof(void *))));
27 struct xa_node {
28 unsigned char shift;
29 unsigned char offset;
30 unsigned char count;
31 unsigned char nr_values;
32 struct xa_node *parent;
33 struct xarray *array;
34 union {
35 struct list_head private_list;
36 struct callback_head callback_head;
38 void *slots[(1UL << (0 ? 4 : 6))];
39 union {
40 unsigned long tags[3][((((1UL << (0 ? 4 : 6))) + (64) - 1) / (64))];
41 unsigned long marks[3][((((1UL << (0 ? 4 : 6))) + (64) - 1) / (64))];
45 static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((no_instrument_function)) unsigned long shift_maxindex(unsigned int shift)
47 return ((1UL << (0 ? 4 : 6)) << shift) - 1;
50 static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((no_instrument_function)) unsigned long node_maxindex(const struct xa_node *node)
52 return shift_maxindex(node->shift);
55 static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((no_instrument_function)) struct xa_node *entry_to_node(void *ptr)
57 return (void *)((__UINTPTR_TYPE__)ptr & ~(__UINTPTR_TYPE__)2);
60 static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((no_instrument_function)) bool radix_tree_is_internal_node(void *ptr)
62 return ((__UINTPTR_TYPE__)ptr & 3UL) ==
63 2UL;
66 static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((no_instrument_function)) void *xa_mk_internal(__UINTPTR_TYPE__ v)
68 return (void *)((v << 2) | 2);
71 static unsigned radix_tree_load_root(const struct xarray *root,
72 struct xa_node **nodep, unsigned long *maxindex)
74 struct xa_node *node =
76 typeof(root->xa_head) ________p1 = ({(*(const volatile typeof(root->xa_head) *)&(root->xa_head)); });
77 ((typeof(*root->xa_head) *)(________p1));
78 });
80 *nodep = node;
82 if (__builtin_expect(!!(radix_tree_is_internal_node(node)), 1)) {
83 node = entry_to_node(node);
84 *maxindex = node_maxindex(node);
85 return node->shift + (0 ? 4 : 6);
88 *maxindex = 0;
89 return 0;
92 void *__radix_tree_lookup(const struct xarray *root,
93 unsigned long index, struct xa_node **nodep,
94 void ***slotp)
96 struct xa_node *node, *parent;
97 unsigned long maxindex;
99 restart:
100 parent = ((void *)0);
101 radix_tree_load_root(root, &node, &maxindex);
102 while (radix_tree_is_internal_node(node)) {
104 parent = entry_to_node(node);
105 if (node == xa_mk_internal(256))
106 goto restart;
107 if (parent->shift == 0)
108 break;
110 if (nodep)
111 *nodep = parent;
113 return node;
116 /* { dg-final { scan-ipa-dump-not "IPA_PARAM_OP_SPLIT" "sra" } } */
117 /* { dg-final { scan-tree-dump " ={v} " "optimized" } } */