Quote Originally Posted by PlausiblyDamp View Post
@niya - not had chance to try this but I wonder if using a Span<int> instead of pointers would make any difference to performance.
In this particular case, I could not find a clean way to use a Span<int> that would have been beneficial. I used pointers so I could benefit from directly utilizing the Avx2 VMOVDQU instruction via the LoadVector256 function. This allows me to copy from the array to a vector register in a single instruction. This is the most direct way of doing it and any other way would add extra overhead.

Spans are very powerful performance enhancers when used correctly but when it comes to the Avx intrinsics, you wouldn't find much room for them. Many of these Avx functions in C# are mapped directly to Avx2 instructions in native code by the RyuJIT so it's lower level than Spans. A lot of these instructions take memory addresses as operands so you will be dealing with pointers quite a bit.