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

Use SIMD equality for PartialEq on SIMD vectors #274

Merged

Conversation

sstangl
Copy link
Contributor

@sstangl sstangl commented Apr 6, 2022

A small change implementing parallel PartialEq for Simd vectors, fixing a TODO. All Simd vectors by definition support SimdPartialEq, so the logic is copied.

I currently think that the call to simd_reduce_all should indeed be round-tripped through Mask to produce a proper integer vector, to handle odd architectures. I wasn't sure if simd_reduce_all(simd_eq(x, y)) was valid, in particular because the definition in LLVM appears to be bitwise AND, and I wasn't clear on where the reduction to Rust bool takes place.

@workingjubilee
Copy link
Member

I believe currently simd_eq returns a vector of integers where the values are all -1 or 0. I suspect this is more correct code in any case, at least, relative to possible implementation variances in the future.

@clarfonthey
Copy link

It looks like this is kind of the same #274? I personally would prefer the one that uses the safe methods, rather than the intrinsics directly, but they appear to do the same thing.

@workingjubilee
Copy link
Member

Do you mean #209? Yes, it effectively is.

@workingjubilee workingjubilee merged commit 7136841 into rust-lang:master Apr 11, 2022
@sstangl sstangl deleted the sstangl/2022-04-05/simd-eq-partialeq branch April 11, 2022 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants