Description
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]
, likeSimd::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.
- Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a
- 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.