| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-dom2-stats -fdump-tree-thread2-stats -fdump-tree-dom3-stats -fno-guess-branch-probability" } */ |
| 3 |
|
| 4 |
/* { dg-final { scan-tree-dump-not "Jumps threaded" "dom2" } } */ |
| 5 |
|
| 6 |
/* We were previously checking for no threads in vrp-thread2, but now |
| 7 |
that we have merged the post and pre threaders, we get a dozen |
| 8 |
threads before VRP2. */ |
| 9 |
|
| 10 |
/* aarch64 has the highest CASE_VALUES_THRESHOLD in GCC. It's high enough |
| 11 |
to change decisions in switch expansion which in turn can expose new |
| 12 |
jump threading opportunities. Skip the later tests on aarch64. */ |
| 13 |
/* { dg-final { scan-tree-dump-not "Jumps threaded" "dom3" { target { ! aarch64*-*-* } } } } */ |
| 14 |
/* { dg-final { scan-tree-dump "Jumps threaded: 9" "thread2" { target { ! aarch64*-*-* } } } } */ |
| 15 |
/* { dg-final { scan-tree-dump "Jumps threaded: 17" "thread2" { target { aarch64*-*-* } } } } */ |
| 16 |
|
| 17 |
enum STATE { |
| 18 |
S0=0, |
| 19 |
SI, |
| 20 |
S1, |
| 21 |
S2, |
| 22 |
S3, |
| 23 |
S4, |
| 24 |
S5, |
| 25 |
S6 |
| 26 |
}; |
| 27 |
|
| 28 |
int bar (enum STATE s); |
| 29 |
|
| 30 |
enum STATE foo (unsigned char **y, unsigned *c) |
| 31 |
{ |
| 32 |
unsigned char *x = *y; |
| 33 |
unsigned char n; |
| 34 |
enum STATE s = S0; |
| 35 |
|
| 36 |
for( ; *x && s != SI; x++ ) |
| 37 |
{ |
| 38 |
n = *x; |
| 39 |
if (n == 'x') |
| 40 |
{ |
| 41 |
x++; |
| 42 |
break; |
| 43 |
} |
| 44 |
switch(s) |
| 45 |
{ |
| 46 |
case S0: |
| 47 |
if(bar(n)) |
| 48 |
s = S3; |
| 49 |
else if( n == 'a' || n == 'b' ) |
| 50 |
s = S1; |
| 51 |
else if( n == 'c' ) |
| 52 |
s = S4; |
| 53 |
else |
| 54 |
{ |
| 55 |
s = SI; |
| 56 |
c[SI]++; |
| 57 |
} |
| 58 |
c[S0]++; |
| 59 |
break; |
| 60 |
case S1: |
| 61 |
if(bar(n)) |
| 62 |
{ |
| 63 |
s = S3; |
| 64 |
c[S1]++; |
| 65 |
} |
| 66 |
else if( n == 'c' ) |
| 67 |
{ |
| 68 |
s = S4; |
| 69 |
c[S1]++; |
| 70 |
} |
| 71 |
else |
| 72 |
{ |
| 73 |
s = SI; |
| 74 |
c[S1]++; |
| 75 |
} |
| 76 |
break; |
| 77 |
case S3: |
| 78 |
if( n == 'c' ) |
| 79 |
{ |
| 80 |
s = S4; |
| 81 |
c[S3]++; |
| 82 |
} |
| 83 |
else if(!bar(n)) |
| 84 |
{ |
| 85 |
s = SI; |
| 86 |
c[S3]++; |
| 87 |
} |
| 88 |
break; |
| 89 |
case S4: |
| 90 |
if( n == 'E' || n == 'e' ) |
| 91 |
{ |
| 92 |
s = S2; |
| 93 |
c[S4]++; |
| 94 |
} |
| 95 |
else if(!bar(n)) |
| 96 |
{ |
| 97 |
s = SI; |
| 98 |
c[S4]++; |
| 99 |
} |
| 100 |
break; |
| 101 |
case S2: |
| 102 |
if( n == 'a' || n == 'b' ) |
| 103 |
{ |
| 104 |
s = S5; |
| 105 |
c[S2]++; |
| 106 |
} |
| 107 |
else |
| 108 |
{ |
| 109 |
s = SI; |
| 110 |
c[S2]++; |
| 111 |
} |
| 112 |
break; |
| 113 |
case S5: |
| 114 |
if(bar(n)) |
| 115 |
{ |
| 116 |
s = S6; |
| 117 |
c[S5]++; |
| 118 |
} |
| 119 |
else |
| 120 |
{ |
| 121 |
s = SI; |
| 122 |
c[S5]++; |
| 123 |
} |
| 124 |
break; |
| 125 |
case S6: |
| 126 |
if(!bar(n)) |
| 127 |
{ |
| 128 |
s = SI; |
| 129 |
c[SI]++; |
| 130 |
} |
| 131 |
break; |
| 132 |
default: |
| 133 |
break; |
| 134 |
} |
| 135 |
} |
| 136 |
*y=x; |
| 137 |
return s; |
| 138 |
} |