Skip to content

Inefficient code generated for state machine #73811

@Plecra

Description

@Plecra

While trying to implement a parser using a state machine, I found that it isn't optimised very well. I've made a comparison on godbolt: https://godbolt.org/z/NJ9HM5

I'd expect the match statement to be replaced with jumps since the state should be statically known at the end of each branch

(Side note: I'd hope that the Normal loop got auto-vectorized in the fast version since it's performing the same check over and over)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-enhancementCategory: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions