Suboptimal codegen for match from enum to almost-same-value usize (unnecessary table lookups) #136972
Labels
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
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.
Uh oh!
There was an error while loading. Please reload this page.
I tried this code:
It gives (Compiler explorer):
I expect
convert_len
to generate code likeconvert_len_optimal
. No table lookup should be generated, especially not the first identity table. Though I don't expect performance to differ a lot when the cache is hot, but wasting cache on these trivial tables does not worth it.I'm not sure if LLVM or rustc is to blame here.
Meta
Reproduced on compiler Explorer's 1.84, latest nightly, and local nightly (
rustc 1.86.0-nightly (854f22563 2025-01-31)
)The text was updated successfully, but these errors were encountered: