Open
Description
https://godbolt.org/z/Wv5bv99bb
public static short Test1(ref short searchSpace, int searchSpaceLength)
{
if (searchSpaceLength < Vector128<short>.Count)
return 42;
return Unsafe.Add(ref searchSpace, searchSpaceLength - Vector128<short>.Count);
}
public static short Test2(ref short searchSpace, int searchSpaceLength)
{
if (searchSpaceLength < Vector128<short>.Count)
return 42;
return Unsafe.Add(ref searchSpace, (uint)searchSpaceLength - (nuint)Vector128<short>.Count);
}
-add esi, -8
-movsxd rax, esi
-movsx rax, word ptr [rdi+2*rax]
+mov eax, esi
+movsx rax, word ptr [rdi+2*rax-0x10]
This occurs in practice in a bunch of places throughput our IndexOf
-like logic, e.g.