2018-01-10 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / loop-invariant.c
blob702050b5c7eb620c51f229707f35ec27d37f4ded
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. */
6 enum test_type
8 TYPE0,
9 TYPE1
12 struct type_node
14 enum test_type type;
17 struct test_ref
19 struct type_node *referring;
22 struct test_node
24 struct test_node *next;
27 int iterate (struct test_node *, unsigned, struct test_ref **);
29 int
30 loop_invar (struct test_node *node)
32 struct test_ref *ref;
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;
39 return 0;
42 /* { dg-final { scan-rtl-dump "Decided to move invariant" "loop2_invariant" } } */