Skip to content

Wrong return type for _mm_extract_ps? #57225

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

Closed
jsgf opened this issue Dec 30, 2018 · 3 comments
Closed

Wrong return type for _mm_extract_ps? #57225

jsgf opened this issue Dec 30, 2018 · 3 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-SIMD Area: SIMD (Single Instruction Multiple Data) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@jsgf
Copy link
Contributor

jsgf commented Dec 30, 2018

std::arch::x86_64::_mm_extract_ps (and x86) is documented as

Extract a single-precision (32-bit) floating-point element from a, selected with imm8

but has the signature

pub unsafe fn _mm_extract_ps(a: __m128, imm8: i32) -> i32

Shouldn't this be returning f32? The implementation just uses mem::transmute with inferred types, so its just transmuting the result to i32 even though the implementation is using simd_transmute to make an f32.

Is this a bug or am I missing something here?

@nikic
Copy link
Contributor

nikic commented Dec 30, 2018

Relevant context, which also applies to Rust: https://stackoverflow.com/questions/5526658/intel-sse-why-does-mm-extract-ps-return-int-instead-of-float

@jsgf
Copy link
Contributor Author

jsgf commented Dec 30, 2018

OK, maybe its worth having something in the documentation about this then.

@estebank estebank added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Dec 31, 2018
@nikic nikic added the A-SIMD Area: SIMD (Single Instruction Multiple Data) label Jan 1, 2019
@jonas-schievink jonas-schievink added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Mar 6, 2020
@workingjubilee
Copy link
Member

Documented in rust-lang/stdarch#1228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-SIMD Area: SIMD (Single Instruction Multiple Data) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants