Merge from mainline
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / loadpre6.c
blob28a71a8e63ffcee1186608fbca270a39a40fc96f
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-pre-stats" } */
4 union tree_node;
5 typedef union tree_node *tree;
7 struct tree_common
9 tree chain;
12 struct tree_list
14 struct tree_common common;
15 tree value;
18 union tree_node
21 struct tree_common common;
22 struct tree_list list;
25 extern void abort (void) __attribute__((noreturn));
27 void __attribute__((noinline))
28 foo (void)
30 abort ();
33 /* There are some reloaded loads of *cell, and cell->common.chain on various
34 branches. */
35 void __attribute__((noinline))
36 remove_useless_vars (tree *unexpanded_var_list, int dump_file)
38 tree var, *cell;
39 int c = 0;
40 for (cell = unexpanded_var_list; *cell; )
42 var = (*cell)->list.value;
43 if (var)
45 if (dump_file)
46 foo ();
48 *cell = ((*cell)->common.chain);
49 continue;
52 cell = &((*cell)->common.chain);
55 extern void *malloc (__SIZE_TYPE__) __attribute__ ((malloc));
57 int
58 main (void)
60 int i;
61 tree unexpanded_var_list, last = (tree) 0;
63 for (i = 0; i < 2; i++)
65 unexpanded_var_list = malloc (sizeof (struct tree_list));
66 unexpanded_var_list->list.value = (tree) (long unsigned) (i & 1);
67 unexpanded_var_list->common.chain = last;
68 last = unexpanded_var_list;
71 remove_useless_vars (&unexpanded_var_list, 0);
72 return 0;
74 /* { dg-final { scan-tree-dump-times "Eliminated: 2" 1 "pre" } } */
75 /* { dg-final { cleanup-tree-dump "pre" } } */