Performance regression: rustc failed to optimize specific x86-64 SIMD intrinsics after 1.75.0
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
I tried this code:
https://rust.godbolt.org/z/KG4cT6aPK
use std::arch::x86_64::*;
#[target_feature(enable = "avx2")]
pub unsafe fn decode(
x: __m256i,
ch: __m256i,
ct: __m256i,
dh: __m256i,
dt: __m256i,
) -> Result<__m256i, ()> {
let shr3 = _mm256_srli_epi32::<3>(x);
let h1 = _mm256_avg_epu8(shr3, _mm256_shuffle_epi8(ch, x));
let h2 = _mm256_avg_epu8(shr3, _mm256_shuffle_epi8(dh, x));
let o1 = _mm256_shuffle_epi8(ct, h1);
let o2 = _mm256_shuffle_epi8(dt, h2);
let c1 = _mm256_adds_epi8(x, o1);
let c2 = _mm256_add_epi8(x, o2);
if _mm256_movemask_epi8(c1) != 0 {
return Err(());
}
Ok(c2)
}
I expected to see this happen: This code should emit two vpavgb instructions.
Instead, this happened: One of the vpavgb instructions is missing.
https://github.com/Nugine/simd/issues/43
Version it worked on
It most recently worked on: 1.74.1
Version with regression
1.75.0 ~ nightly
rustc 1.79.0-nightly (dbce3b43b 2024-04-20)
binary: rustc
commit-hash: dbce3b43b6cb34dd3ba12c3ec6f708fe68e9c3df
commit-date: 2024-04-20
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.4
@rustbot modify labels: +regression-from-stable-to-stable -regression-untriaged
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked rust.godbolt.org example and compare rustc 1.74.1 with 1.75.0 or the referenced nightly, checking the generated x86-64 assembly for both vpavgb instructions. Trace the compiler or LLVM change responsible and add a regression test; done means both instructions are emitted for the provided SIMD code.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100