[Bug tree-optimization/54742] Switch elimination in FSM loop

spop at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Jun 28 15:45:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54742

Sebastian Pop <spop at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |spop at gcc dot gnu.org

--- Comment #37 from Sebastian Pop <spop at gcc dot gnu.org> ---
Hi Jeff, can you fix this bug, or should I give it a try?
I know some folks who would be happy to have this coremark perf bug fixed in
trunk ;-)

Thanks,
Sebastian

(In reply to jgreenhalgh from comment #27)
> Created attachment 31308 [details]
> 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