PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / ssa-dom-thread-7.c
blobe395de26ec0d6c10cb1a5f56fc1a6125a3b3a771
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-thread1-stats -fdump-tree-thread2-stats -fdump-tree-dom2-stats -fdump-tree-thread3-stats -fdump-tree-dom3-stats -fdump-tree-vrp2-stats -fno-guess-branch-probability" } */
3 /* { dg-final { scan-tree-dump "Jumps threaded: 16" "thread1" } } */
4 /* { dg-final { scan-tree-dump "Jumps threaded: 9" "thread2" } } */
5 /* { dg-final { scan-tree-dump "Jumps threaded: 1" "dom2" } } */
6 /* { dg-final { scan-tree-dump-not "Jumps threaded" "dom3" } } */
7 /* { dg-final { scan-tree-dump-not "Jumps threaded" "vrp2" } } */
9 /* Most architectures get 3 threadable paths here, whereas aarch64 and
10 possibly others get 5. We really should rewrite threading tests to
11 test a specific IL sequence, not gobs of code whose IL can vary
12 from architecture to architecture. */
13 /* { dg-final { scan-tree-dump "Jumps threaded: \[35\]" "thread3" } } */
15 enum STATE {
16 S0=0,
17 SI,
18 S1,
19 S2,
20 S3,
21 S4,
22 S5,
26 int bar (enum STATE s);
28 enum STATE foo (unsigned char **y, unsigned *c)
30 unsigned char *x = *y;
31 unsigned char n;
32 enum STATE s = S0;
34 for( ; *x && s != SI; x++ )
36 n = *x;
37 if (n == 'x')
39 x++;
40 break;
42 switch(s)
44 case S0:
45 if(bar(n))
46 s = S3;
47 else if( n == 'a' || n == 'b' )
48 s = S1;
49 else if( n == 'c' )
50 s = S4;
51 else
53 s = SI;
54 c[SI]++;
56 c[S0]++;
57 break;
58 case S1:
59 if(bar(n))
61 s = S3;
62 c[S1]++;
64 else if( n == 'c' )
66 s = S4;
67 c[S1]++;
69 else
71 s = SI;
72 c[S1]++;
74 break;
75 case S3:
76 if( n == 'c' )
78 s = S4;
79 c[S3]++;
81 else if(!bar(n))
83 s = SI;
84 c[S3]++;
86 break;
87 case S4:
88 if( n == 'E' || n == 'e' )
90 s = S2;
91 c[S4]++;
93 else if(!bar(n))
95 s = SI;
96 c[S4]++;
98 break;
99 case S2:
100 if( n == 'a' || n == 'b' )
102 s = S5;
103 c[S2]++;
105 else
107 s = SI;
108 c[S2]++;
110 break;
111 case S5:
112 if(bar(n))
114 s = S6;
115 c[S5]++;
117 else
119 s = SI;
120 c[S5]++;
122 break;
123 case S6:
124 if(!bar(n))
126 s = SI;
127 c[SI]++;
129 break;
130 default:
131 break;
134 *y=x;
135 return s;