blob: d40a61fd725f90c3f8e4d16092640880edd52c7e (
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
130
131
132
133
134
135
136
137
138
|
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-dom2-stats -fdump-tree-thread2-stats -fdump-tree-dom3-stats -fno-guess-branch-probability" } */
/* { dg-final { scan-tree-dump-not "Jumps threaded" "dom2" } } */
/* We were previously checking for no threads in vrp-thread2, but now
that we have merged the post and pre threaders, we get a dozen
threads before VRP2. */
/* aarch64 has the highest CASE_VALUES_THRESHOLD in GCC. It's high enough
to change decisions in switch expansion which in turn can expose new
jump threading opportunities. Skip the later tests on aarch64. */
/* { dg-final { scan-tree-dump-not "Jumps threaded" "dom3" { target { ! aarch64*-*-* } } } } */
/* { dg-final { scan-tree-dump "Jumps threaded: 11" "thread2" { target { ! aarch64*-*-* } } } } */
/* { dg-final { scan-tree-dump "Jumps threaded: 18" "thread2" { target { aarch64*-*-* } } } } */
enum STATE {
S0=0,
SI,
S1,
S2,
S3,
S4,
S5,
S6
};
int bar (enum STATE s);
enum STATE foo (unsigned char **y, unsigned *c)
{
unsigned char *x = *y;
unsigned char n;
enum STATE s = S0;
for( ; *x && s != SI; x++ )
{
n = *x;
if (n == 'x')
{
x++;
break;
}
switch(s)
{
case S0:
if(bar(n))
s = S3;
else if( n == 'a' || n == 'b' )
s = S1;
else if( n == 'c' )
s = S4;
else
{
s = SI;
c[SI]++;
}
c[S0]++;
break;
case S1:
if(bar(n))
{
s = S3;
c[S1]++;
}
else if( n == 'c' )
{
s = S4;
c[S1]++;
}
else
{
s = SI;
c[S1]++;
}
break;
case S3:
if( n == 'c' )
{
s = S4;
c[S3]++;
}
else if(!bar(n))
{
s = SI;
c[S3]++;
}
break;
case S4:
if( n == 'E' || n == 'e' )
{
s = S2;
c[S4]++;
}
else if(!bar(n))
{
s = SI;
c[S4]++;
}
break;
case S2:
if( n == 'a' || n == 'b' )
{
s = S5;
c[S2]++;
}
else
{
s = SI;
c[S2]++;
}
break;
case S5:
if(bar(n))
{
s = S6;
c[S5]++;
}
else
{
s = SI;
c[S5]++;
}
break;
case S6:
if(!bar(n))
{
s = SI;
c[SI]++;
}
break;
default:
break;
}
}
*y=x;
return s;
}
|