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

Remove multi-field repr(simd) #621

Closed
1 of 3 tasks
scottmcm opened this issue Apr 22, 2023 · 3 comments
Closed
1 of 3 tasks

Remove multi-field repr(simd) #621

scottmcm opened this issue Apr 22, 2023 · 3 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@scottmcm
Copy link
Member

Proposal

Originally, repr(simd) supported only multi-field form:

#[repr(simd)]
pub struct u8x32(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8);

https://github.com/rust-lang/stdarch/blob/5f5ddf8f9a404d1f12b531095b13bccce97357ea/crates/core_arch/src/x86/mod.rs#L324-L329

But with const generics showing up (and because counting fields like that isn't the most fun thing in the world), an array-based version was added:

#[repr(simd)]
pub struct u8x32([u8; 32]);

Unsurprisingly, portable-simd uses that form:

https://github.com/rust-lang/portable-simd/blob/ceb26115928c5c69b10268fd2f9e500865c142d6/crates/core_simd/src/vector.rs#L80

That was a great addition, but came with the cost that we now need to handle both kinds everywhere that looks at simd.

For example, this test needs to check both

https://github.com/rust-lang/rust/blob/0fd50f3e019dddc47d1d6dbe35c4c1542098d9c5/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs#L14-L20

And, even more interestingly, it demonstrates that things don't necessarily work the same way between the different approaches.

I propose that we remove the multi-field form.

repr(simd) is not on a stabilization track, the array form is more readable, and nightly users (including core arch) can easily migrate to the array-based form.

By only having one way to do it, we'll simplify things that need to handle or test simd types, like this code that currently has to check for empty simd types twice:

https://github.com/rust-lang/rust/blob/0fd50f3e019dddc47d1d6dbe35c4c1542098d9c5/compiler/rustc_hir_analysis/src/check/check.rs#L890-L910

Mentors or Reviewers

Removing code is generally the easier side of things, so no mentoring should be needed.

@workingjubilee or other portable-simd folks would likely make good reviewers.

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@scottmcm scottmcm added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Apr 22, 2023
@rustbot
Copy link
Collaborator

rustbot commented Apr 22, 2023

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Apr 22, 2023
@wesleywiser
Copy link
Member

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Apr 22, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 22, 2023
…e-asm, r=workingjubilee

allow array-style simd in inline asm

Required for [MCP#621](rust-lang/compiler-team#621) to be implemented.

r? `@workingjubilee`
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 24, 2023
…asm, r=workingjubilee

allow array-style simd in inline asm

Required for [MCP#621](rust-lang/compiler-team#621) to be implemented.

r? `@workingjubilee`
RalfJung pushed a commit to RalfJung/miri that referenced this issue Apr 26, 2023
…rkingjubilee

allow array-style simd in inline asm

Required for [MCP#621](rust-lang/compiler-team#621) to be implemented.

r? `@workingjubilee`
@apiraino
Copy link
Contributor

apiraino commented May 4, 2023

@rustbot label -final-comment-period +major-change-accepted

@apiraino apiraino closed this as completed May 4, 2023
@rustbot rustbot added major-change-accepted A major change proposal that was accepted and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels May 4, 2023
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label May 25, 2023
celinval added a commit to model-checking/kani that referenced this issue Jul 31, 2023
Originally, repr(simd) supported only multi-field form. An array based version was later added and it's likely to become the only supported way (rust-lang/compiler-team#621).

The array-based version is currently used in the standard library, and it is used to implement `portable-simd`. This change adds support to instantiating and using the array-based version.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 20, 2024
…rkingjubilee

allow array-style simd in inline asm

Required for [MCP#621](rust-lang/compiler-team#621) to be implemented.

r? `@workingjubilee`
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this issue Apr 27, 2024
…rkingjubilee

allow array-style simd in inline asm

Required for [MCP#621](rust-lang/compiler-team#621) to be implemented.

r? `@workingjubilee`
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 9, 2024
Update stdarch submodule

To pick up rust-lang/stdarch#1624 and unblock removing support for non-array-based-simd (rust-lang/compiler-team#621).

try-job: dist-aarch64-linux
try-job: dist-armv7-linux
try-job: dist-x86_64-linux
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 13, 2024
Update stdarch submodule

To pick up rust-lang/stdarch#1624 and unblock removing support for non-array-based-simd (rust-lang/compiler-team#621).

try-job: dist-aarch64-linux
try-job: dist-armv7-linux
try-job: dist-x86_64-linux
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 21, 2024
Update stdarch submodule

To pick up rust-lang/stdarch#1624 and unblock removing support for non-array-based-simd (rust-lang/compiler-team#621).
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 26, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Aug 28, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Aug 30, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 31, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 8, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 10, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 10, 2024
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

4 participants