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

put the idx arguments of simd_insert and simd_extract into const blocks #1530

Merged
merged 2 commits into from
Feb 17, 2024

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Feb 17, 2024

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.

@rustbot
Copy link
Collaborator

rustbot commented Feb 17, 2024

r? @Amanieu

rustbot has assigned @Amanieu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@bors
Copy link
Contributor

bors commented Feb 17, 2024

☔ The latest upstream changes (presumably 4d9c0bb) made this pull request unmergeable. Please resolve the merge conflicts.

#[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 {
Copy link
Member Author

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.

@Amanieu Amanieu merged commit a79a8de into rust-lang:master Feb 17, 2024
27 checks passed
@RalfJung RalfJung deleted the simd-extrac-insert-const-idx branch February 17, 2024 18:13
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants