JIT: Intrinsify ClearWithoutReferences and Fill#98700
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsThis PR enables more memset-like unrollings for these APIs. Also, it fixes some potential regressions from #98623 which removes Example of what it does compared to Main/.NET 7.0: static void Test(Span<int> span)
{
span.Slice(0, 10).Fill(0);
}Current codegen:; Assembly listing for method Prog:Test(System.Span`1[int]) (FullOpts)
G_M6718_IG01:
sub rsp, 40
G_M6718_IG02:
cmp dword ptr [rcx+0x08], 10
jb SHORT G_M6718_IG04
mov rcx, bword ptr [rcx]
mov edx, 10
xor r8d, r8d
call [System.SpanHelpers:Fill[int](byref,ulong,int)]
nop
G_M6718_IG03:
add rsp, 40
ret
G_M6718_IG04:
call [System.ThrowHelper:ThrowArgumentOutOfRangeException()]
int3
; Total bytes of code 40New codegen; Assembly listing for method Prog:Test(System.Span`1[int]) (FullOpts)
G_M6718_IG01:
sub rsp, 40
G_M6718_IG02:
cmp dword ptr [rcx+0x08], 10
jb SHORT G_M6718_IG04
mov rax, bword ptr [rcx]
vxorps ymm0, ymm0, ymm0
vmovdqu ymmword ptr [rax], ymm0
vmovdqu xmmword ptr [rax+0x18], xmm0
G_M6718_IG03:
add rsp, 40
ret
G_M6718_IG04:
call [System.ThrowHelper:ThrowArgumentOutOfRangeException()]
int3
; Total bytes of code 38
|
Co-authored-by: SingleAccretion <[email protected]>
|
@jakobbotsch @dotnet/jit-contrib PTAL. This is needed to unblock #98623 which removes unrollable Unsafe.InitBlock from two places. This impl is similar to LowerMemmove that @jakobbotsch reviewed in the past |
|
@jakobbotsch I've addressed your feedback (thanks, it made it simpler!) PTAL |
|
Grr.. clicked "Update branch" instead of "Merge" 😠 |
|
Possible improvements (Only the clear related benchmarks): |
This PR enables more memset-like unrollings for these APIs. Also, it fixes some potential regressions from #98623 which removes
Unsafe.InitBlockUnalignedfromSpanHelpers.ClearWithoutReferencesandSpan.Fill.Example of what it does compared to Main/.NET 8.0:
Current codegen:
New codegen