Open Plecra opened 4 years ago
There are tons of "slow" bugs in the bugtracker, but I think most of them are not worked on.
It seems clang cannot optimise that as well. so I guess LLVM doesn't optimise state machines. https://godbolt.org/z/xaW-by
Yup, they've even got an issue for it. https://bugs.llvm.org/show_bug.cgi?id=39043
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 thefast
version since it's performing the same check over and over)