@rkruppe in a nutshell (live example):
// Given a SIMD vector type:
#[repr(simd)]
struct f32x8(f32, f32, f32, f32,
f32, f32, f32, f32);
// and the following two functions:
#[target_feature(enable = "avx")]
fn foo() -> f32x8; // f32x8 will be a 256bit vector
#[target_feature(enable = "sse3")]
fn bar(arg: f32x8); // f32x8 will be 2x128bit vectors
// what are the semantics of the following when
// executing on a machine that supports AVX?
fn main() { bar(foo()); }
The compiler will compile bar for SSE3 and foo for AVX. Even if you run this on a machine that supports AVX, the calling conventions / ABIs of these two functions are different. On nightly, this produces no warning, and bar will get passed garbage. Some C++ compilers warn about this in some cases.
First, this problem is solvable: we just haven’t chosen a solution yet. Second, independently of whether we stabilize repr(simd) or not, we need to solve this anyways to make SIMD types sound. Third, this is a pure repr(simd) issue. I used target_feature for simplicity, but if you put the functions in different crates, compile for different --target-cpus (AVX, SSE3), and then link them and run them on a CPU that is a superset (e.g. AVX2), you reproduce this without using target_feature.
This problem is basically that portable vector types (which is what repr(simd) introduces) have a different layout depending on the features enabled for a particular piece of code, and this layout is not part of the type.
So what I am wondering is whether we should nail down the semantics of repr(simd) first, and then discuss what we actually want to stabilize (e.g. repr(simd) or some subset of std::f32x8 types), or whether we should pursue the fixed sub-set of vector types directly, and clear these issues in that RFC.
EDIT: this post is only about how to follow the roadmap, if there is interest in discussing possible solutions to the repr(simd) issues we should open a different thread for that.
EDIT2: I’ve filled an issue so that those interested can discuss this there.