-
Notifications
You must be signed in to change notification settings - Fork 269
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
put the idx arguments of simd_insert and simd_extract into const blocks #1530
Merged
Amanieu
merged 2 commits into
rust-lang:master
from
RalfJung:simd-extrac-insert-const-idx
Feb 17, 2024
Merged
put the idx arguments of simd_insert and simd_extract into const blocks #1530
Amanieu
merged 2 commits into
rust-lang:master
from
RalfJung:simd-extrac-insert-const-idx
Feb 17, 2024
Conversation
This file contains 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
RalfJung
force-pushed
the
simd-extrac-insert-const-idx
branch
5 times, most recently
from
February 17, 2024 09:20
d1013a2
to
a2f32c8
Compare
☔ The latest upstream changes (presumably 4d9c0bb) made this pull request unmergeable. Please resolve the merge conflicts. |
RalfJung
force-pushed
the
simd-extrac-insert-const-idx
branch
from
February 17, 2024 12:52
1c42b00
to
b754cf2
Compare
RalfJung
commented
Feb 17, 2024
#[allow(non_camel_case_types, dead_code)] | ||
struct $elem_name; | ||
value | ||
}),*) | ||
} | ||
|
||
/// Extract the element at position `index`. | ||
/// `index` is not a constant so this is not efficient! | ||
/// Use for testing only. | ||
// FIXME: Workaround rust@60637 | ||
#[inline(always)] | ||
pub(crate) fn extract(self, index: usize) -> $ety { |
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.
FWIW the function should have been unsafe since it performed unchecked indexing.
I made it safe by adding an assert.
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Feb 22, 2024
…dx, r=oli-obk,Amanieu require simd_insert, simd_extract indices to be constants As discussed in rust-lang#77477 (see in particular [here](rust-lang#77477 (comment))). This PR doesn't touch codegen yet -- the first step is to ensure that the indices are always constants; the second step is to then make use of this fact in backends. Blocked on rust-lang/stdarch#1530 propagating to the rustc repo.
bors
added a commit
to rust-lang/miri
that referenced
this pull request
Feb 25, 2024
…-obk,Amanieu require simd_insert, simd_extract indices to be constants As discussed in rust-lang/rust#77477 (see in particular [here](rust-lang/rust#77477 (comment))). This PR doesn't touch codegen yet -- the first step is to ensure that the indices are always constants; the second step is to then make use of this fact in backends. Blocked on rust-lang/stdarch#1530 propagating to the rustc repo.
lnicola
pushed a commit
to lnicola/rust-analyzer
that referenced
this pull request
Apr 7, 2024
…-obk,Amanieu require simd_insert, simd_extract indices to be constants As discussed in rust-lang/rust#77477 (see in particular [here](rust-lang/rust#77477 (comment))). This PR doesn't touch codegen yet -- the first step is to ensure that the indices are always constants; the second step is to then make use of this fact in backends. Blocked on rust-lang/stdarch#1530 propagating to the rustc repo.
RalfJung
pushed a commit
to RalfJung/rust-analyzer
that referenced
this pull request
Apr 27, 2024
…-obk,Amanieu require simd_insert, simd_extract indices to be constants As discussed in rust-lang/rust#77477 (see in particular [here](rust-lang/rust#77477 (comment))). This PR doesn't touch codegen yet -- the first step is to ensure that the indices are always constants; the second step is to then make use of this fact in backends. Blocked on rust-lang/stdarch#1530 propagating to the rustc repo.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In rust-lang/rust#77477 the general consensus seems to be that these arguments should always be consts. So I have a patch for rustc that enforces them to be const. This is the stdarch side of this, adding const-blocks everywhere to ensure these arguments are const. I decided to follow the same pattern as simd_shuffle and add a macro that adds the const block.
However, there's one use of non-constant indices that can't be easily ported to use inline const blocks: the
extract
method on SIMD types, which is used (at least) by PowerPC tests. Also see here.