I have seen that it's rather simple in C to access values in a __m128
register by index. However, it is not possible to do that in rust. How can I access those values?
Concretely, I am calculating four values at once, then I compare them using _mm_cmplt_ps
. I use that return register as a mask for further computation.
There are SIMD instructions precisely for this, eg such as _mm_extract_epi32
, but they often require newer versions of SIMD than just SSE2.
I think the easiest way to do this using foolproof safe Rust is using the bytemuck
crate, in your example:
let cmp = _mm_cmplt_ps(a, b);
let cmp_arr: [u32; 4] = bytemuck::cast(cmp);
Now cmp_arr[0]
, cmp_arr[1]
, ..., contain your results.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.