simd intrinsics: add simd_shuffle_generic and other missing intrinsics by RalfJung · Pull Request #119213 · rust-lang/rust (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation32 Commits4 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Failed to set assignee to calebzulawski
: invalid assignee
Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the library team, which will review and decide on the PR/issue.
labels
/// Returns a new vector such that element `i` is selected from `xy[IDX[i]]`, where `xy` |
---|
/// is the concatenation of `x` and `y`. It is a compile-time error if `IDX[i]` is out-of-bounds |
/// of `xy`. |
pub fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U; |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't seen this intrinsic before 🤔 this is what we need in std::simd
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an experiment to see how far we can get with the current const-generic support. I don't think std::simd can use it yet, that would need generic_const_exprs which is still a highly experimental feature.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice if we could stabilize a small enough subset of GCE that this sort of thing becomes feasible.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From talking with @lcnr that seems pretty far out currently. And in particular reference types in const generics have pretty thorny unsolved theoretical questions as well.
RalfJung changed the title
simd intrinsics: add simd_shuffle_generic simd intrinsics: add simd_shuffle_generic and other missing intrinsics
Failed to set assignee to calebzulawski
: invalid assignee
Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.
I realized there are more intrinsics missing, so I added those as well.
'sup, sorry about the delay. I had the usual holidays-induced madness and then work on shipping soundness fixes to Rust crates and then a blackout in winter! will take a look this week/after a nap.
No worries, I was just making sure this doesn't fall through the cracks. :)
it seems sometimes I have an interesting interpretation of "this week".
Comment on lines +248 to +249
/// The stores happen in left-to-right order. |
---|
/// (This is relevant in case two of the stores overlap.) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
( probably not relevant, but fun facts to know and tell: if the machine instruction gets executed, this guarantee also affects the state of the CPU during exception handling. )
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, exception handles can observe these instructions as non-atomic? Wow.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, on Intel CPUs at least, for most variants of these instructions, the operands (esp. the mask operand) get updated so that continuing with the same operands will complete the operation, completing a single store for each index.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean "get updated"? Does this change the contents of some other register, where the mask operand is stored? I hope it restored the original value when the instruction is done?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean "get updated"? Does this change the contents of some other register, where the mask operand is stored?
Yes, the mask register.
I hope it restored the original value when the instruction is done?
uhhh probably! 😁
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay... well as long as LLVM takes that into account it's all good.
@@ -204,7 +204,7 @@ extern "platform-intrinsic" { |
---|
/// |
/// `T` must be a vector. |
/// |
/// `V` must be a vector with the same element type as `T` and the same length as `IDX`. |
/// `U` must be a vector with the same element type as `T` and the same length as `IDX`. |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good catch. ^^;
📌 Commit 3bc490d has been approved by workingjubilee
It is now in the queue for this repository.
bors added S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#119213 (simd intrinsics: add simd_shuffle_generic and other missing intrinsics)
- rust-lang#120272 (Suppress suggestions in derive macro)
- rust-lang#120773 (large_assignments: Allow moves into functions)
- rust-lang#120874 (Take empty
where
bounds into account when suggesting predicates) - rust-lang#120882 (interpret/write_discriminant: when encoding niched variant, ensure the stored value matches)
- rust-lang#120883 (interpret: rename ReadExternStatic → ExternStatic)
- rust-lang#120890 (Adapt
llvm-has-rust-patches
validation to takellvm-config
into account.) - rust-lang#120895 (don't skip coercions for types with errors)
- rust-lang#120896 (Print kind of coroutine closure)
r? @ghost
@rustbot
modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#119213 (simd intrinsics: add simd_shuffle_generic and other missing intrinsics)
- rust-lang#120272 (Suppress suggestions in derive macro)
- rust-lang#120773 (large_assignments: Allow moves into functions)
- rust-lang#120874 (Take empty
where
bounds into account when suggesting predicates) - rust-lang#120882 (interpret/write_discriminant: when encoding niched variant, ensure the stored value matches)
- rust-lang#120883 (interpret: rename ReadExternStatic → ExternStatic)
- rust-lang#120890 (Adapt
llvm-has-rust-patches
validation to takellvm-config
into account.) - rust-lang#120895 (don't skip coercions for types with errors)
- rust-lang#120896 (Print kind of coroutine closure)
r? @ghost
@rustbot
modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#119213 (simd intrinsics: add simd_shuffle_generic and other missing intrinsics)
- rust-lang#120272 (Suppress suggestions in derive macro)
- rust-lang#120773 (large_assignments: Allow moves into functions)
- rust-lang#120874 (Take empty
where
bounds into account when suggesting predicates) - rust-lang#120882 (interpret/write_discriminant: when encoding niched variant, ensure the stored value matches)
- rust-lang#120883 (interpret: rename ReadExternStatic → ExternStatic)
- rust-lang#120890 (Adapt
llvm-has-rust-patches
validation to takellvm-config
into account.) - rust-lang#120895 (don't skip coercions for types with errors)
- rust-lang#120896 (Print kind of coroutine closure)
r? @ghost
@rustbot
modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request
…iaskrgr
Rollup of 9 pull requests
Successful merges:
- rust-lang#119213 (simd intrinsics: add simd_shuffle_generic and other missing intrinsics)
- rust-lang#120272 (Suppress suggestions in derive macro)
- rust-lang#120773 (large_assignments: Allow moves into functions)
- rust-lang#120874 (Take empty
where
bounds into account when suggesting predicates) - rust-lang#120882 (interpret/write_discriminant: when encoding niched variant, ensure the stored value matches)
- rust-lang#120883 (interpret: rename ReadExternStatic → ExternStatic)
- rust-lang#120890 (Adapt
llvm-has-rust-patches
validation to takellvm-config
into account.) - rust-lang#120895 (don't skip coercions for types with errors)
- rust-lang#120896 (Print kind of coroutine closure)
r? @ghost
@rustbot
modify labels: rollup
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#119213 - RalfJung:simd_shuffle, r=workingjubilee
simd intrinsics: add simd_shuffle_generic and other missing intrinsics
Also tweak the simd_shuffle docs a bit.
r? @calebzulawski
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request
…s, r=workingjubilee
Stop using unsized_const_parameters
in core/std
feature(unsized_const_parameters)
is an incomplete feature and should not be used by core/std as it makes it can make it significantly harder to evolve the feature. It also just generally opens the possibility of introducing bugs on stable through std's backdoor.
The only usage of this feature in std is the simd_shuffle_intrinsic
added in rust-lang#119213. It doesn't seem to be used anywhere as far as I can tell so it is removed in this PR. All tests and codegen logic etc have been kept however.
r? @workingjubilee
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request
Rollup merge of rust-lang#128150 - BoxyUwU:std_only_sized_const_params, r=workingjubilee
Stop using unsized_const_parameters
in core/std
feature(unsized_const_parameters)
is an incomplete feature and should not be used by core/std as it makes it can make it significantly harder to evolve the feature. It also just generally opens the possibility of introducing bugs on stable through std's backdoor.
The only usage of this feature in std is the simd_shuffle_intrinsic
added in rust-lang#119213. It doesn't seem to be used anywhere as far as I can tell so it is removed in this PR. All tests and codegen logic etc have been kept however.
r? @workingjubilee
Labels
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Relevant to the library team, which will review and decide on the PR/issue.