Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect ABI when passing f32/f64 on a function with #[target_feature(enable = "sse2")] #82529

Closed
Amanieu opened this issue Feb 25, 2021 · 1 comment
Labels
C-bug Category: This is a bug. O-x86_32 Target: x86 processors, 32 bit (like i686-*)

Comments

@Amanieu
Copy link
Member

Amanieu commented Feb 25, 2021

Godbolt link

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
@Amanieu Amanieu added O-x86 C-bug Category: This is a bug. labels Feb 25, 2021
@Amanieu
Copy link
Member Author

Amanieu commented Feb 25, 2021

Seem to be a duplicate of #64609.

@Amanieu Amanieu closed this as completed Feb 25, 2021
@Noratrieb Noratrieb added O-x86_32 Target: x86 processors, 32 bit (like i686-*) and removed O-x86-all labels Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. O-x86_32 Target: x86 processors, 32 bit (like i686-*)
Projects
None yet
Development

No branches or pull requests

2 participants