summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c
blob: cfedc9c6b765594a9b63454acdbb88a37a8c127f (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
/* { dg-options "-O2 -fdump-rtl-expand-all" } */
int g;

__attribute__((noinline)) void foo (int  n)
{
  switch (n)
    {
    case 99:
      g += 2; break;
    case 1:
      g++; break;
    case 100:
      g += 1; break;
    case 4:
      g += 3; break;
    case 5:
      g += 4; break;
    case 6:
      g += 5; break;
    case 7:
      g += 6; break;
    case 8:
      g += 7; break;
    case 9:
      g += 8; break;
    default:
      g += 8; break;
   }
}

int main ()
{
 int i;
 for (i = 0; i < 10000; i++)
   foo ((i * i) % 5);
 return 0;
}
/* autofdo cannot do that precise execution numbers: */
/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 4000" 2 "expand"} } */
/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 2000" 1 "expand"} } */