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:
You can read more about Major Change Proposals on forge.
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:
&Simd<T, N>to&[T; N], likeSimd::as(_mut)_arraydoes, 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
stdarchtests.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 sincerepr(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:
@rustbot second.-C flag, then full team check-off is required.@rfcbot fcp mergeon either the MCP or the PR.You can read more about Major Change Proposals on forge.