aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/tree-ssa/loop-25.c
blob: c2fb74e58715d964d364131652161ec584623f8d (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
120
121
122
123
124
125
126
127
128
129
/* { dg-do compile } */
/* { dg-options "-O1 -fdump-tree-profile_estimate" } */

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

void test1 (void)
{
  unsigned i;

  /* Only one loop should be found here.  */
  i = 0;
  while (1)
    {
      i++;
      if (i == 100)
	break;

      if (foo ())
	bla ();
      else
	bar ();
    }
}

void test2 (void)
{
  unsigned i, j;

  /* Two loops should be found, in this case.  */
  i = j = 0;
  while (1)
    {
      j++;
      foo ();
      if (j < 100)
	continue;

      i++;
      j = 0;
      if (i == 100)
	break;
    }
}

void test3 (void)
{
  unsigned i, j, k;

  /* Three loops.  */
  i = j = k = 0;
  while (1)
    {
      j++;
      foo ();
      if (j < 100)
	continue;

      j = 0;
      k++;
      if (k < 100)
	continue;

      k = 0;
      i++;
      if (i == 100)
	break;
    }
}

void test4 (void)
{
  unsigned i, j, k;

  /* Two loops with a nested subloop.  */
  i = j = 0;
  while (1)
    {
      j++;
      foo ();
      for (k = 0; k < 100; k++)
	foo ();

      if (j < 100)
	continue;

      i++;
      j = 0;
      if (i == 100)
	break;
    }
}


void test5 (void)
{
  unsigned i, j;

  /* Both subloop and non-subloop back edges.  */
  i = j = 0;
  while (1)
    {
      j++;
      foo ();
      if (j < 100)
	continue;
      j = 0;

      i++;
      if (i == 100)
	break;

      if (foo ())
	bla ();
      else
	bar ();
    }
}

/* { dg-final { scan-tree-dump-times "Disambiguating loop" 5 "profile_estimate" } } */
/* For the following xfail marks, see PR35629.  */
/* { dg-final { scan-tree-dump-times "Found latch edge" 5 "profile_estimate" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "Merged latch edges" 2 "profile_estimate" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "4 loops found" 2 "profile_estimate" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "3 loops found" 2 "profile_estimate" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "2 loops found" 1 "profile_estimate" { xfail *-*-* } } } */

/* { dg-final { cleanup-tree-dump "profile_estimate" } } */