Repository navigation
Closed
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-miscompileIssue: Correct Rust code lowers to incorrect machine codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
Description
Compiler Explorer: https://godbolt.org/z/3nPG3e51e
small.rs
pub fn f(count: u16, seed: u8, q: i8) -> i128 {
let mut score: i128 = -1;
for k in 0..(count as usize).min(16) {
match k % 8 {
0 => {
if (k as u16).is_power_of_two() {
match (q.rem_euclid(3), matches!(count, 17..=21 | 26)) {
(0, true) => {}
_ => score += k as i128 + i128::from(q),
}
}
}
_ => score = score.wrapping_add(seed as i128 + 1198),
}
}
score
}Reproduce:
Correct:
$ rustc --edition 2024 --crate-type=lib -C opt-level=2 -C target-cpu=x86-64-v3 small.rs
Crash:
$ rustc --edition 2024 --crate-type=lib -C opt-level=3 -C target-cpu=x86-64-v3 small.rs
ReplaceNodeResults: t62: v1i128 = X86ISD::VSHLI t67, TargetConstant:i8<1>
Do not know how to custom type legalize this operation!
UNREACHABLE executed at /data/x27zhou/compiler-nightly/src/rust/src/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:34649!
Stable 1.99.0 dies with SIGILL on the same command; 1.98.0 compiles it. The LLVM bug is llvm/llvm-project#228829, fixed on LLVM main by llvm/llvm-project#228840, which is not in Rust's LLVM yet.
Meta
rustc --version --verbose:
rustc 1.101.0-nightly (91e426a05 2026-10-13)
binary: rustc
commit-hash: 91e426a0518d5bb3672330c5238ccda6fd26fb54
commit-date: 2026-10-13
host: x86_64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.3
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-miscompileIssue: Correct Rust code lowers to incorrect machine codeT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
Activity
nikic commentedon Oct 14, 2026
I assume that this is a fuzzer generated issue? If so, please do mention that in the PR description (also for all your other issues).
Auto merge of #164743 - nikic:llvm-23.1.4, r=cuviper