Improved SIMD in Rust


An overview of my work on SIMD in Rust.


Good fun! I’d love to see the cross-platform layer made truly portable by means of a scalar implementation that is selected if there is no SIMD option. That would enable “worry-free” use of simd types in data structures, which sounds highly appealing to me for cases where they make a particularly good fit.


Having a cross-platform library that calls the appropriate instruction on ARM/x86/… or fall-backing to a scalar version would be great. I don’t think I want that to be part of simd (at least, not yet), but it should be possible to do in a zero-overhead way in a wrapper lib.


Which instruction sets are supported? (does it start at SSE2 or way back at MMX?)


At the moment there’s no MMX intrinsics, but I’m fairly sure it is just a matter of adding them.


MMX in particular is is bit complicated because we would need to expose the LLVM type x86_mmx to Rust code somehow. Also, emms is a complete mess: LLVM can’t automatically insert emms calls, so you have to insert them yourself. But if you insert them yourself, you have to be very careful because the LLVM optimizer doesn’t understand the relationship between MMX operations, x87 operations, and emms, and therefore can reorder instructions incorrectly. Overall, it’s probably not worth the trouble.