given that the underlying API isn’t really strongly typed in the same way (e.g. a zmm register can be interpreted as 64 u8s or as 32 u16s, I would expect std::simd to expose “reinterpret casts” between Simd types with the same total size. However I don’t see any such functions, and also it does seem kind of tricky to implement. Here is an attempt:
pub fn reinterpret_cast_le<
T1: SimdElement,
T2: SimdElement,
const N1: usize,
const N2: usize,
>(
x: Simd<T1, N1>,
) -> Simd<T2, N2>
where
LaneCount<N1>: SupportedLaneCount,
LaneCount<N2>: SupportedLaneCount,
Simd<T1, N1>: ToBytes,
Simd<T2, N2>: ToBytes,
{
Simd::from_le_bytes(x.to_le_bytes())
}
does this already exist and/or (how) can it be implemented?