1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-thread1-details -fdump-tree-thread2-details" } */
3
4 /* All the threads in the thread1 dump start on a X->BB12 edge, as can
5 be seen in the dump:
6
7 Registering FSM jump thread: (x, 12) incoming edge; ...
8 etc
9 etc
10
11 Before the new evrp, we were threading paths that started at the
12 following edges:
13
14 Registering FSM jump thread: (10, 12) incoming edge
15 Registering FSM jump thread: (6, 12) incoming edge
16 Registering FSM jump thread: (9, 12) incoming edge
17
18 This was because the PHI at BB12 had constant values coming in from
19 BB10, BB6, and BB9:
20
21 # state_10 = PHI <state_11(7), 0(10), state_11(5), 1(6), state_11(8), 2(9), state_11(11)>
22
23 Now with the new evrp, we get:
24
25 # state_10 = PHI <0(7), 0(10), state_11(5), 1(6), 0(8), 2(9), 1(11)>
26
27 Thus, we have 3 more paths that are known to be constant and can be
28 threaded. Which means that by the second threading pass, we can
29 only find one profitable path.
30
31 For the record, all these extra constants are better paths coming
32 out of switches. For example:
33
34 SWITCH_BB -> BBx -> BBy -> BBz -> PHI
35
36 We now know the value of the switch index at PHI. */
37 /* { dg-final { scan-tree-dump-times "FSM" 6 "thread1" } } */
38 /* { dg-final { scan-tree-dump-times "FSM" 1 "thread2" } } */
39
40 int sum0, sum1, sum2, sum3;
foo(char * s,char ** ret)41 int foo (char *s, char **ret)
42 {
43 int state=0;
44 char c;
45
46 for (; *s && state != 4; s++)
47 {
48 c = *s;
49 if (c == '*')
50 {
51 s++;
52 break;
53 }
54 switch (state)
55 {
56 case 0:
57 if (c == '+')
58 state = 1;
59 else if (c != '-')
60 sum0+=c;
61 break;
62 case 1:
63 if (c == '+')
64 state = 2;
65 else if (c == '-')
66 state = 0;
67 else
68 sum1+=c;
69 break;
70 default:
71 break;
72 }
73
74 }
75 *ret = s;
76 return state;
77 }
78