1 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-O2 -fdump-rtl-loop2_invariant" } */
3 /* NOTE: The target list above could be extended to other targets that have
4 conditional moves, but don't have zero registers. */
5
6 enum test_type
7 {
8 TYPE0,
9 TYPE1
10 };
11
12 struct type_node
13 {
14 enum test_type type;
15 };
16
17 struct test_ref
18 {
19 struct type_node *referring;
20 };
21
22 struct test_node
23 {
24 struct test_node *next;
25 };
26
27 int iterate (struct test_node *, unsigned, struct test_ref **);
28
29 int
30 loop_invar (struct test_node *node)
31 {
32 struct test_ref *ref;
33
34 for (unsigned i = 0; iterate (node, i, &ref); i++)
35 if (loop_invar ((ref->referring && ref->referring->type == TYPE0)
36 ? ((struct test_node *) (ref->referring)) : 0))
37 return 1;
38
39 return 0;
40 }
41
42 /* { dg-final { scan-rtl-dump "Decided to move invariant" "loop2_invariant" } } */