Open
Description
Code
I tried this code (godbolt, from this video):
#[no_mangle]
pub fn f(a: &[u16; 8]) -> u16 {
a.iter().copied().min().unwrap()
}
I expected to see this happen: compiles to vphminposuw
x86 instruction (+avx feature)
Instead, this happened: compiles to unrolled cmp + cmov
Note that a manual min
loop is unaffected, even with the slice iterator:
#[no_mangle]
pub fn f(a: &[u16; 8]) -> u16 {
let mut min = u16::MAX;
for &x in a {
if x < min {
min = x;
}
}
min
}
Version it worked on
It most recently worked on: 1.86
Version with regression
rustc --version --verbose
:
rustc 1.88.0-nightly (6bc57c6bf 2025-04-22)
binary: rustc
commit-hash: 6bc57c6bf7d0024ad9ea5a2c112f3fc9c383c8a4
commit-date: 2025-04-22
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
@rustbot modify labels: +regression-from-stable-to-nightly -regression-untriaged
searched nightlies: from nightly-2025-02-15 to nightly-2025-04-23
regressed nightly: nightly-2025-04-16
searched commit range: 2da29db...38c560a
regressed commit: 58c2dd9
Weirdly: #139745 cc @thaliaarchi
bisected with cargo-bisect-rustc v0.6.9
Host triple: x86_64-unknown-linux-gnu
Reproduce with:
cargo bisect-rustc --start 1.86.0 -vv --without-cargo --script ./asm.sh