llvm / llvm/llvm-project

Codegen for switch of `llvm.ucmp` could be optimised

Open
#176,492 5 comments 0 reactions 0 assignees View on GitHub
llvm:codegen missed-optimization
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

> https://godbolt.org/z/6dP4je7Eb
>
> Looks like LLVM's middle-end optimizes that perfectly well -- it gives exactly the `llvm.ucmp.i8.i8` intrinsic and the `switch` as you'd expect -- but LLVM's x64 backend doesn't optimize it as well as it could.

_Originally posted by @scottmcm in [#5354](https://github.com/rust-lang/rust-clippy/issues/5354#issuecomment-3761928995)_

Contributor guide

Open the contributing guide

Research direction

Start with the Godbolt example at https://godbolt.org/z/6dP4je7Eb and compare the generated x64 code for the llvm.ucmp intrinsic and switch. Read the LLVM x64 backend codegen path involved in this case; done means the switch is lowered to the more efficient code expected from the example.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.