]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/tree-ssa/pr77445-2.c
eecfc4b195a9b9698e60a24aa66983d360da6f7a
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr77445-2.c
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-thread-details-blocks-stats" } */
3 typedef enum STATES {
4 START=0,
5 INVALID,
6 S1,
7 S2,
8 INT,
9 FLOAT ,
10 EXPONENT,
11 SCIENTIFIC,
12 NUM_STATES
13 } state_e ;
14
15 typedef unsigned char u8;
16 typedef unsigned int u32;
17
18 static u8 is_digit(u8 c) {
19 return (u8)((c>='0') & (c<='9')) ? 1 : 0;
20 }
21
22 enum STATES FMS( u8 **in , u32 *transitions) {
23 u8 *str = *in;
24 u8 NEXT_SYMBOL;
25 enum STATES state=START;
26 for( ; *str && state != INVALID; str++ ) {
27 NEXT_SYMBOL = *str;
28 if (NEXT_SYMBOL==',') /* end of this input */ {
29 transitions[state]++;
30 str++;
31 break;
32 }
33 switch(state) {
34 case START:
35 if(is_digit(NEXT_SYMBOL)) {
36 state = INT;
37 }
38 else if( NEXT_SYMBOL == '+' || NEXT_SYMBOL == '-' ) {
39 state = S1;
40 }
41 else if( NEXT_SYMBOL == '.' ) {
42 state = FLOAT ;
43 }
44 else {
45 state = INVALID;
46 }
47 transitions[START]++;
48 break;
49 case S1:
50 if(is_digit(NEXT_SYMBOL)) {
51 state = INT;
52 transitions[S1]++;
53 }
54 else if( NEXT_SYMBOL == '.' ) {
55 state = FLOAT ;
56 transitions[S1]++;
57 }
58 else {
59 state = INVALID;
60 transitions[S1]++;
61 }
62 break;
63 case INT:
64 if( NEXT_SYMBOL == '.' ) {
65 state = FLOAT ;
66 transitions[INT]++;
67 }
68 else if(!is_digit(NEXT_SYMBOL)) {
69 state = INVALID;
70 transitions[INT]++;
71 }
72 break;
73 case FLOAT :
74 if( NEXT_SYMBOL == 'E' || NEXT_SYMBOL == 'e' ) {
75 state = S2;
76 transitions[FLOAT ]++;
77 }
78 else if(!is_digit(NEXT_SYMBOL)) {
79 state = INVALID;
80 transitions[FLOAT ]++;
81 }
82 break;
83 case S2:
84 if( NEXT_SYMBOL == '+' || NEXT_SYMBOL == '-' ) {
85 state = EXPONENT;
86 transitions[S2]++;
87 }
88 else {
89 state = INVALID;
90 transitions[S2]++;
91 }
92 break;
93 case EXPONENT:
94 if(is_digit(NEXT_SYMBOL)) {
95 state = SCIENTIFIC;
96 transitions[EXPONENT]++;
97 }
98 else {
99 state = INVALID;
100 transitions[EXPONENT]++;
101 }
102 break;
103 case SCIENTIFIC:
104 if(!is_digit(NEXT_SYMBOL)) {
105 state = INVALID;
106 }
107 break;
108 default:
109 break;
110 }
111 }
112 if (state==INVALID)
113 transitions[INVALID]++;
114
115 *in = str;
116 return state;
117 }
118
119 /* The profile is not updated perfectly because it is inconsitent from
120 profile estimation stage. But the number of inconsistencies should not
121 increase much. */
122 /* { dg-final { scan-tree-dump "Jumps threaded: 1\[1-9\]" "thread1" } } */
123 /* { dg-final { scan-tree-dump-times "Invalid sum" 3 "thread1" } } */
124 /* { dg-final { scan-tree-dump-not "not considered" "thread1" } } */
125 /* { dg-final { scan-tree-dump-not "not considered" "thread2" } } */
126 /* { dg-final { scan-tree-dump-not "not considered" "thread3" } } */
127 /* { dg-final { scan-tree-dump-not "not considered" "thread4" } } */