-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Inefficient code generated for state machine #73811
Copy link
Copy link
Open
Labels
A-codegenArea: Code generationArea: Code generationC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: 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.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: 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.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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
matchstatement 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
Normalloop got auto-vectorized in thefastversion since it's performing the same check over and over)