aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-2.c
blob: 47456be1581c1a928148eedf7c685bb87b3a0bde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* { dg-do compile } */ 
/* { dg-options "-O2 -fdump-tree-vrp-stats -fdump-tree-dom1-stats" } */

void foo();
void bla();
void bar();

/* In the following two cases, we should be able to thread edge through
   the loop header.  */

void thread_entry_through_header (void)
{
  int i;

  for (i = 0; i < 170; i++)
    bla ();
}

void thread_latch_through_header (void)
{
  int i = 0;
  int first = 1;

  do
    {
      if (first)
	foo ();

      first = 0;
      bla ();
    } while (i++ < 100);
}

/* This is a TODO -- it is correct to thread both entry and latch edge through
   the header, but we do not handle this case yet.  */

void dont_thread_1 (void)
{
  int i = 0;
  int first = 1;

  do
    {
      if (first)
	foo ();
      else
	bar ();

      first = 0;
      bla ();
    } while (i++ < 100);
}

/* Avoid threading in the following two cases, to prevent creating subloops.  */

void dont_thread_2 (int first)
{
  int i = 0;

  do
    {
      if (first)
	foo ();
      else
	bar ();

      first = 0;
      bla ();
    } while (i++ < 100);
}

void dont_thread_3 (int nfirst)
{
  int i = 0;
  int first = 0;

  do
    {
      if (first)
	foo ();
      else
	bar ();

      first = nfirst;
      bla ();
    } while (i++ < 100);
}

/* Avoid threading in this case, in order to avoid creating loop with
   multiple entries.  */

void dont_thread_4 (int a, int nfirst)
{
  int i = 0;
  int first;

  if (a)
    first = 0;
  else
    first = 1;

  do
    {
      if (first)
	foo ();
      else
	bar ();

      first = nfirst;
      bla ();
    } while (i++ < 100);
}

/* { dg-final { scan-tree-dump-times "Jumps threaded: 1" 1 "vrp"} } */
/* { dg-final { scan-tree-dump-times "Jumps threaded: 2" 0 "vrp"} } */
/* { dg-final { scan-tree-dump-times "Jumps threaded: 1" 0 "dom1"} } */
/* { dg-final { scan-tree-dump-times "Jumps threaded: 2" 1 "dom1"} } */
/* { dg-final { cleanup-tree-dump "dom1" } } */
/* { dg-final { cleanup-tree-dump "vrp" } } */