Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop Cloning is disabled on Arrays of Structs #54846

Closed
badamczewski opened this issue Jun 28, 2021 · 2 comments
Closed

Loop Cloning is disabled on Arrays of Structs #54846

badamczewski opened this issue Jun 28, 2021 · 2 comments
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration tenet-performance Performance related issue
Milestone

Comments

@badamczewski
Copy link

Tested on .NET 5

Loop Cloning is disabled on structs of arrays making it somewhat not ideal for performance scenarios:

https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIAYACY8gOgCUBXAOwwEt8YLAJI8YUCAAcAymIBuvMDFwBuGjWIBmBrgxQOYDAyk0A3jQYWmW3jwYANZZYs0AvmtpayDACpLDZ6idNJhQGAFkACikAbQBdBmwASgYApycAM2gIm0NeBgBeBjpHPIAeBnI6KpKAahrk1LSm7GjeWJY7AoZeVUCmhjc+i0GXIA===

The code in question that disables loop cloning is here and it's still on master so it will also affect .NET 6:

https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/loopcloning.cpp#L2060

Code:

public struct S
{
    public int X;     
}

public class Test {
    public void M(S[] a) {
        for(int i = 0; i < 1000; i++) {
            a[i].X = i;
        }
    }
}

X86:

    L0000: sub rsp, 0x28
    L0004: xor eax, eax
    L0006: mov ecx, [rdx+8]
    L0009: cmp eax, ecx
    L000b: jae short L0023
    L000d: movsxd r8, eax
    L0010: mov [rdx+r8*4+0x10], eax
    L0015: inc eax
    L0017: cmp eax, 0x3e8
    L001c: jl short L0009
    L001e: add rsp, 0x28
    L0022: ret
    L0023: call 0x00007ffc6346a5e0
    L0028: int3
@badamczewski badamczewski added the tenet-performance Performance related issue label Jun 28, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI untriaged New issue has not been triaged by the area owner labels Jun 28, 2021
@JulieLeeMSFT JulieLeeMSFT added needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration and removed untriaged New issue has not been triaged by the area owner labels Jun 28, 2021
@JulieLeeMSFT JulieLeeMSFT added this to the 6.0.0 milestone Jun 28, 2021
@BruceForstall
Copy link
Member

This is a dup of #48897

@BruceForstall
Copy link
Member

I'm going to close this, and track the work with #48897

@ghost ghost locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration tenet-performance Performance related issue
Projects
None yet
Development

No branches or pull requests

3 participants