OSDN Git Service

2007-09-26 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / tree-ssa / ssa-dom-thread-2.c
1 /* { dg-do compile } */ 
2 /* { dg-options "-O2 -fdump-tree-vrp1-stats -fdump-tree-dom1-stats" } */
3
4 void foo();
5 void bla();
6 void bar();
7
8 /* In the following two cases, we should be able to thread edge through
9    the loop header.  */
10
11 void thread_entry_through_header (void)
12 {
13   int i;
14
15   for (i = 0; i < 170; i++)
16     bla ();
17 }
18
19 void thread_latch_through_header (void)
20 {
21   int i = 0;
22   int first = 1;
23
24   do
25     {
26       if (first)
27         foo ();
28
29       first = 0;
30       bla ();
31     } while (i++ < 100);
32 }
33
34 /* This is a TODO -- it is correct to thread both entry and latch edge through
35    the header, but we do not handle this case yet.  */
36
37 void dont_thread_1 (void)
38 {
39   int i = 0;
40   int first = 1;
41
42   do
43     {
44       if (first)
45         foo ();
46       else
47         bar ();
48
49       first = 0;
50       bla ();
51     } while (i++ < 100);
52 }
53
54 /* Avoid threading in the following two cases, to prevent creating subloops.  */
55
56 void dont_thread_2 (int first)
57 {
58   int i = 0;
59
60   do
61     {
62       if (first)
63         foo ();
64       else
65         bar ();
66
67       first = 0;
68       bla ();
69     } while (i++ < 100);
70 }
71
72 void dont_thread_3 (int nfirst)
73 {
74   int i = 0;
75   int first = 0;
76
77   do
78     {
79       if (first)
80         foo ();
81       else
82         bar ();
83
84       first = nfirst;
85       bla ();
86     } while (i++ < 100);
87 }
88
89 /* Avoid threading in this case, in order to avoid creating loop with
90    multiple entries.  */
91
92 void dont_thread_4 (int a, int nfirst)
93 {
94   int i = 0;
95   int first;
96
97   if (a)
98     first = 0;
99   else
100     first = 1;
101
102   do
103     {
104       if (first)
105         foo ();
106       else
107         bar ();
108
109       first = nfirst;
110       bla ();
111     } while (i++ < 100);
112 }
113
114 /* { dg-final { scan-tree-dump-times "Jumps threaded: 1" 1 "vrp1"} } */
115 /* { dg-final { scan-tree-dump-times "Jumps threaded: 2" 0 "vrp1"} } */
116 /* { dg-final { scan-tree-dump-times "Jumps threaded: 1" 0 "dom1"} } */
117 /* { dg-final { scan-tree-dump-times "Jumps threaded: 2" 1 "dom1"} } */
118 /* { dg-final { cleanup-tree-dump "dom1" } } */
119 /* { dg-final { cleanup-tree-dump "vrp1" } } */