-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Description
Context: a lot of benchmarks regressed on Mono after #79461 and #80668
On CoreCLR the following snippet (compiled with the most recent Roslyn):
static int GetInt8(int index)
{
ReadOnlySpan<byte> RVA = new byte[] { 1, 2, 3, 4 };
return RVA[index];
}
static int GetInt32(int index)
{
ReadOnlySpan<int> RVA = new int[] { 1, 2, 3, 4 };
return RVA[index];
}
produces more or less the same codegen while IL is quite different - in case of ReadOnlySpan<int>
a RuntimeHelpers.CreateSpan
call is emitted by Roslyn (to handle endianness). CoreCLR has a JIT intrinsics implemented by @davidwrighton in #61079 that helps it to achieve perfect codegen here. As that PR states, Mono doesn't have that intrinsic so CreateSpan
ends up calling an icall in vm (ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetSpanDataFrom
)
srxqds