[Bug tree-optimization/54742] Switch elimination in FSM loop
jgreenhalgh at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Nov 27 12:11:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54742
jgreenhalgh at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jgreenhalgh at gcc dot gnu.org
--- Comment #27 from jgreenhalgh at gcc dot gnu.org ---
Created attachment 31308
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31308&action=edit
Dumps for less reduced testcase in comment 27
As of revision 205398, I'm not seeing this optimisation trigger when compiling
the benchmark in question.
I've attached the dumps from a less agressively reduced version of the testcase
given in the intial report, which we don't currently thread.
This testcase is more representative of the control structure in the benchmark
code. In particular, we have the problematic scenario of two 'joiner' blocks in
the thread path.
Looking at the dumps for this testcase I think that we would need to spot
threads like:
(17, 23) incoming edge; (23, 4) joiner; (4, 5) joiner; (5, 8) back-edge; (8,
15) switch-statement;
The testcase I am using is:
---
int sum0, sum1, sum2, sum3;
int foo(char * s, char** ret)
{
int state=0;
char c;
for (; *s && state != 4; s++)
{
c = *s;
if (c == '*')
{
s++;
break;
}
switch (state) {
case 0:
if (c == '+') state = 1;
else if (c != '-') sum0+=c;
break;
case 1:
if (c == '+') state = 2;
else if (c == '-') state = 0;
else sum1+=c;
break;
case 2:
if (c == '+') state = 3;
else if (c == '-') state = 1;
else sum2+=c;
break;
case 3:
if (c == '-') state = 2;
else if (c == 'x') state = 4;
break;
default:
break;
}
}
*ret = s;
return state;
}
More information about the Gcc-bugs
mailing list