Closed
Description
The following code passes a floating-point value using the wrong ABI:
use std::arch::x86::*;
// This function expects a in xmm0
#[target_feature(enable = "sse2")]
unsafe fn sse2(a: f64) -> __m128d {
_mm_set1_pd(a)
}
pub unsafe fn non_sse2(a: f64) -> __m128d {
// This passes a on the stack
sse2(a)
}
Assembly output:
example::sse2:
mov eax, ecx
movsd qword ptr [ecx], xmm0
movsd qword ptr [ecx + 8], xmm0
ret
example::non_sse2:
push esi
sub esp, 8
mov esi, dword ptr [esp + 16]
fld qword ptr [esp + 20]
fstp qword ptr [esp]
mov ecx, esi
call example::sse2
mov eax, esi
add esp, 8
pop esi
ret 4