[Bug driver/79637] missing documentation for PARAM_MAX_FSM_THREAD_LENGTH

spop at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Apr 18 13:43:00 GMT 2017


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

--- Comment #3 from Sebastian Pop <spop at gcc dot gnu.org> ---
As to why we call it a "finite state automaton" jump threading, that is because
this transform shows to be useful when the switch statement in the previous
example is contained in a loop, which is the way most people use to implement a
parser, or a finite state machine.  Some of these automata are implementing
state transitions by setting the next state in one of the cases.  To continue
the example from the previous comment, here is how a two state machine looks
like:

c = 1;
while (1)
{
  switch (c)
    {
    case 1:
      c = 5;
      break;
    case 5:
      c = 1;
      break;
    }
}

and after jump threading, it would look like this:

c = 1;
label1:
  c = 5;
  goto label2;

label2:
  c = 1;
  goto label1;

which is much faster than having to take the loop back-edge + jump from switch
to case.


More information about the Gcc-bugs mailing list