Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The first commit says "Vectorization of string.Equals". It now uses SpanHelpers.SequenceEqual. How is that vectorized when it's just an unrolled loop from what I see? Does vectorization not mean using SIMD instructions? It also means improving data dependencies?

https://github.com/dotnet/coreclr/blob/48cb3fa29a63219a9669a...



char ref (managed pointer) is cast to byte ref https://github.com/dotnet/coreclr/blob/04d9b557ef8b7c60a1194...

Then it uses SpanHelpers.SequenceEqual for byte which is vectorized

https://github.com/dotnet/coreclr/blob/04d9b557ef8b7c60a1194...


>char is cast to byte

To be clear, char is not cast to byte (which would truncate). A char ref (ie a char pointer) is cast to a byte ref (ie a byte pointer).


Good point :) Updated


Oh thanks! Was looking at the wrong SequenceEqual


Maybe there is an autovectorizer in the compiler that recognizes the shape of that loop and uses SSE to do it 16 bytes at a time instead of 8 at a time?


The CLR/runtime to optimizes that code into SIMD instructions, if the hardware allows for it.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: