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

Ban projecting into repr(simd) types #838

Open
1 of 3 tasks
scottmcm opened this issue Feb 16, 2025 · 2 comments
Open
1 of 3 tasks

Ban projecting into repr(simd) types #838

scottmcm opened this issue Feb 16, 2025 · 2 comments
Labels
final-comment-period The FCP has started, most (if not all) team members are in agreement major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@scottmcm
Copy link
Member

Proposal

Projecting into SIMD types is awkward, because the field is an array, which is passed by pointer, but the vector itself is an immediate.

That means it needs special-case code that writes the vector out to an alloca so the pointer can be used, which is awkward at best. It caused rust-lang/rust#105439 and I just noticed today that it's still broken in other cases, see rust-lang/rust#137108. I recall hearing it was awkward for cranelift too.

It not even particularly useful, because the right way to do it is to do something different anyway:

  • For single items, the correct thing to do is to use the insert/extract intrinsics, not index into the array field.
  • If you want the whole thing as an array, it's better to just cast the &Simd<T, N> to &[T; N], like Simd::as(_mut)_array does, and which bypasses the whole operand representation issue because the & means it's already in memory anyway.

So I propose we just ban field-projecting into repr(simd) types altogether -- treat them like integers and pointers as not having fields -- and thus decide to intentionally not fix rust-lang/rust#137108 .

Portable SIMD is already not projecting into their types: https://github.com/rust-lang/rust/blob/e72df78268bafbfe28366aa0e382713f55a491e7/library/portable-simd/crates/core_simd/src/vector.rs#L98-L101

Mentors or Reviewers

Most changes here will be fairly-straight-forward changes to stdarch tests.

Banning the things that aren't used there (like 3 x i32) and already don't work is pretty simple and can likely be reviewed by anyone, especially since repr(simd) is likely staying internal so per #620 it doesn't need to be reported elegantly.

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.

@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 Feb 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 16, 2025

Important

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.

Concerns or objections to the proposal should be discussed on Zulip and formally registered here by adding a comment with the following syntax:

@rfcbot concern reason-for-concern 
<description of the concern> 

Concerns can be lifted with:

@rfcbot resolve reason-for-concern 

See documentation at https://forge.rust-lang.org

cc @rust-lang/compiler

@oli-obk
Copy link
Contributor

oli-obk commented Feb 16, 2025

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Feb 16, 2025
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Feb 21, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 21, 2025
…errors

Refactor `OperandRef::extract_field` to prep for MCP838

cc rust-lang/compiler-team#838

This still supports exactly the same cases as it did before, just rearranged a bit to better emphasize what doesn't work.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 21, 2025
Rollup merge of rust-lang#137361 - scottmcm:mcp-838-prep, r=compiler-errors

Refactor `OperandRef::extract_field` to prep for MCP838

cc rust-lang/compiler-team#838

This still supports exactly the same cases as it did before, just rearranged a bit to better emphasize what doesn't work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
final-comment-period The FCP has started, most (if not all) team members are in agreement major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

4 participants