rust-lang / rust-lang/rust

Inefficient compiler optimization between stable versions on nightly

Open
#123,262 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-LLVM A-mir-opt C-bug I-slow P-medium T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I have been recently been working on a logic simulator that requires building on the nightly channel. With the release of Rust 1.77.1, I subsequently updated my version from nightly-2024-02-08 to nightly-2024-03-28 and instantly noticed a drastic performance impact. Upon further investigation, starting from nightly-2024-02-12 and onwards, the compiler is no longer able to optimize my multiplexor function.

The godbolt link is unintentionally misleading with its versions. Strangely, this regression does not happen on the equivalent stable channel versions (1.76.0 and 1.77.1), and the reason why this happens only on nightly is beyond my current knowledge.

rustc --version --verbose: (The first bad version, and I think the dates are shifted because of time zones)

rustc 1.78.0-nightly (1a648b397 2024-02-11)
binary: rustc
commit-hash: 1a648b397dedc98ada3dd3360f6d661ec2436c56
commit-date: 2024-02-11
host: aarch64-apple-darwin
release: 1.78.0-nightly
LLVM version: 17.0.6

I'm not sure which regression label to mark this issue with, since it's occurred between stable versions but on the nightly channel, so I'll omit one for now.

@rustbot modify labels: -regression-untriaged

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Godbolt reproducer and compare nightly-2024-02-08 through nightly-2024-02-12, then use the reported rustc commit 1a648b397 and verbose build details to narrow the regression. Done means the nightly optimization behavior is explained and corrected, while the stable 1.76.0 and 1.77.1 comparison remains understood.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.