-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
simd intrinsics: add simd_shuffle_generic and other missing intrinsics #119213
Conversation
Failed to set assignee to
|
911c637
to
8a126eb
Compare
/// 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
8a126eb
to
a1b5879
Compare
Failed to set assignee to
|
I realized there are more intrinsics missing, so I added those as well. |
8e4c416
to
4201c0a
Compare
@workingjubilee friendly review ping :) |
'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". |
/// The stores happen in left-to-right order. | ||
/// (This is relevant in case two of the stores overlap.) |
There was a problem hiding this comment.
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. )
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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! 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope it restored the original value when the instruction is done?
uhhh probably! 😁
nope, it's defined to clear the mask register: https://www.felixcloutier.com/x86/vscatterdps:vscatterdpd:vscatterqps:vscatterqpd
There was a problem hiding this comment.
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.
4c3c2fb
to
3bc490d
Compare
Some changes occurred to the platform-builtins intrinsics. Make sure the cc @antoyo, @GuillaumeGomez, @bjorn3, @calebzulawski, @programmerjake |
cool! @bors r+ |
@@ -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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, good catch. ^^;
@bors rollup |
…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 take `llvm-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
…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 take `llvm-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
…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 take `llvm-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
…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 take `llvm-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
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`
…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`
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`
Also tweak the simd_shuffle docs a bit.
r? @calebzulawski