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

Precise liveness for LCL_FLD-s #49199

Closed
sandreenko opened this issue Mar 5, 2021 · 2 comments
Closed

Precise liveness for LCL_FLD-s #49199

sandreenko opened this issue Mar 5, 2021 · 2 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI optimization
Milestone

Comments

@sandreenko
Copy link
Contributor

sandreenko commented Mar 5, 2021

For the following test:

 struct S
    {
        public int i1;
        public int i2;
        public int i3;
        public int i4;
        public int i5;
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    static void Test(S s)
    {}


    [MethodImpl(MethodImplOptions.NoInlining)]
    public static int Main()
    {
        S s;//= new S();
        s.i1 = 1;
        s.i2 = 2;
        s.i3 = 3;
        s.i4 = 4;
        s.i5 = 5;
        Test(s);
        return 100;
    }

we will have must-init flag on 's' because our liveness (in fgPerNodeLocalVarLiveness) does not see

STORE fld1
STORE fld2
STORE fld3
STORE fld4
STORE fld5

as a full def, so JIT thinks that s value is used before defined:

BB01
use def in out
{V00}
{V00 V03}
{V00}
{}
Var=Reg beg of BB01: none
Var=Reg end of BB01: none

so "conservative" liveness prevents some optimizations, like mentioned zero-init elimination, dead store removals etc.
dumpForIssue.txt

I don't see a cheap solution, maybe mark "good" structs (no holes, overlaps, not address taken, not too many fields) with a new flag and track their liveness by fields using some "pseudo" numbers in fgCurUseSet instead of the parent lcl.

Marking as future unless we see benchmarks where it could improve CQ, cc @dotnet/jit-contrib

category:cq
theme:liveness
skill-level:intermediate
cost:medium
impact:medium

@sandreenko sandreenko added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI optimization labels Mar 5, 2021
@sandreenko sandreenko added this to the Future milestone Mar 5, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 5, 2021
@sandreenko
Copy link
Contributor Author

@erozenfeld this is my analysis that we discussed for #48797

@sandreenko sandreenko removed the untriaged New issue has not been triaged by the area owner label Mar 5, 2021
@jakobbotsch
Copy link
Member

I think physical promotion closes this gap.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2024
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 optimization
Projects
None yet
Development

No branches or pull requests

2 participants