-
Notifications
You must be signed in to change notification settings - Fork 74
Ban projecting into repr(simd) types #838
Copy link
Copy link
Closed
rust-lang/rust
#143833Labels
T-compilerAdd this label so rfcbot knows to poll the compiler teamAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was acceptedA major change proposal that was accepted
Metadata
Metadata
Assignees
Labels
T-compilerAdd this label so rfcbot knows to poll the compiler teamAdd this label so rfcbot knows to poll the compiler teammajor-changeA proposal to make a major change to rustcA proposal to make a major change to rustcmajor-change-acceptedA major change proposal that was acceptedA major change proposal that was accepted
Type
Fields
Give feedbackNo fields configured for issues without a type.
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.