Open
Description
Code
I tried this code:
pub fn find_minimum(values: &[f64]) -> f64 {
let mut min = f64::INFINITY;
for &num in values {
if num < min {
min = num
}
}
min
}
I expected to see this happen: I expect that the generated assembly will unroll the loop to a certain level.
Instead, this happened: There is no more unrolling perform by the compiler.
Version it worked on
.LCPI0_0:
.quad 0x7ff0000000000000
example::find_minimum:
test rsi, rsi
je .LBB0_1
lea rcx, [8*rsi - 8]
mov edx, ecx
shr edx, 3
add edx, 1
and rdx, 7
je .LBB0_3
neg rdx
movsd xmm1, qword ptr [rip + .LCPI0_0]
mov rax, rdi
.LBB0_5:
movsd xmm0, qword ptr [rax]
add rax, 8
minsd xmm0, xmm1
movapd xmm1, xmm0
inc rdx
jne .LBB0_5
cmp rcx, 56
jae .LBB0_7
jmp .LBB0_9
.LBB0_1:
movsd xmm0, qword ptr [rip + .LCPI0_0]
ret
.LBB0_3:
movsd xmm0, qword ptr [rip + .LCPI0_0]
mov rax, rdi
cmp rcx, 56
jb .LBB0_9
.LBB0_7:
lea rcx, [rdi + 8*rsi]
.LBB0_8:
movsd xmm1, qword ptr [rax]
minsd xmm1, xmm0
movsd xmm0, qword ptr [rax + 8]
minsd xmm0, xmm1
movsd xmm1, qword ptr [rax + 16]
minsd xmm1, xmm0
movsd xmm0, qword ptr [rax + 24]
minsd xmm0, xmm1
movsd xmm1, qword ptr [rax + 32]
minsd xmm1, xmm0
movsd xmm0, qword ptr [rax + 40]
minsd xmm0, xmm1
movsd xmm1, qword ptr [rax + 48]
minsd xmm1, xmm0
movsd xmm0, qword ptr [rax + 56]
minsd xmm0, xmm1
add rax, 64
cmp rcx, rax
jne .LBB0_8
.LBB0_9:
ret
It most recently worked on: 1.59
Version with regression
.LCPI0_0:
.quad 0x7ff0000000000000
example::find_minimum:
test rsi, rsi
je .LBB0_1
shl rsi, 3
movsd xmm1, qword ptr [rip + .LCPI0_0]
xor eax, eax
.LBB0_4:
movsd xmm0, qword ptr [rdi + rax]
minsd xmm0, xmm1
add rax, 8
movapd xmm1, xmm0
cmp rsi, rax
jne .LBB0_4
ret
.LBB0_1:
movsd xmm0, qword ptr [rip + .LCPI0_0]
ret
rustc --version --verbose
:
rustc 1.60.0-beta.3 (e5effbd0b 2022-03-07)
binary: rustc
commit-hash: e5effbd0b34c9ede216e21d3f60dcbad0b863676
commit-date: 2022-03-07
host: x86_64-unknown-linux-gnu
release: 1.60.0-beta.3
LLVM version: 14.0.0
@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged