How to use llvm intrinsic functions on packed simd vectors?


#1

I would like to optimize my simulation by using mathematical operations that take simd vectors as arguments and apply simd intrinsics to them. For example, I would like to have a fn sin(v: __m256d) -> __m256d.

I found that rust actually has codegen tests for such functions that come with llvm, here: https://github.com/rust-lang/rust/blob/b7c6e8f1805cd8a4b0a1c1f22f17a89e9e2cea23/src/test/codegen/simd-intrinsic-float-cos.rs

I am not sure if this is 100% what I need, but I figure those #[repr(simd)] applied to the various tuple structs would yield __m256 and __m256d and their likes.

So how do I use this? Is anything of this exposed yet? Or all highly experimental? I am fine with using nightly.


#2

You can use __mm256_sin_pd.


#3

I think you gave me the wrong link. :slight_smile: That’s __m256_min_pd.

Also, there are no intrinsics for proper trigonometric functions. There is only Intel’s SVML, which provides functions that look like intrinsics, but are not.


#4

Oh weird! I guess __mm256_min_pd is close enough to mm256_sin_pd that it pops up when you search that…