llvm / llvm/llvm-project

Missed optimization opportunity: collapsing jump table

Open
#209,276 0 comments 0 reactions 0 assignees View on GitHub
llvm:optimizations missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

While working on a bytecode interpreter, we used the following Rust code that can be found in the attached godbolt link. It does not seem to recognize that the jump table is essentially just an identity and can be completely removed unless we remove one or two more lines from the bottom.

https://godbolt.org/z/bbdbbd595

Contributor guide

Open the contributing guide

Research direction

Start with the Rust reproducer and generated output in the linked Godbolt example. Inspect the optimization behavior around the jump table and compare it with the reduced version that removes the remaining lines. Done means identifying the missed optimization and either producing a focused compiler fix with a regression test or documenting why the jump table cannot be eliminated.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.