Missed optimization: converting "equivalent" enum
s
#116272
Labels
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
I-slow
Issue: Problems and improvements with respect to performance of generated code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
With Rust 1.72.0:
compiles to branches (
f
) and a table-based approach (g
):However, they could simply be:
https://godbolt.org/z/Ko5cKKojh
The compiler figures it out correctly if the values are contiguous (e.g. changing
255
above to2
), or if the sizes /repr
is the same.This sort of code may happen when one is safely wrapping an automatically generated Rust
enum
from (e.g. from C code) into a betterenum
(e.g. with a smaller layout, better docs or more idiomatic variant names).The text was updated successfully, but these errors were encountered: