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

Allow inlining for ldsfld + value-type #78736

Merged
merged 1 commit into from
Feb 2, 2023

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Nov 22, 2022

It turns out that JIT used to always give up on inlining methods with ldsfld inside for fields of struct type, e.g:

static DateTime Foo { get; } = DateTime.Now;

static DateTime Test() => Foo;

Current Tier1 codegen for Test:

; Assembly listing for method Prog:Test():System.DateTime
; Tier-1 compilation
       4883EC28             sub      rsp, 40
       FF159E210E00         call     [Prog:get_Foo():System.DateTime]
       90                   nop      
       4883C428             add      rsp, 40
       C3                   ret      
; Total bytes of code 16
Inlines into Prog:Test():System.DateTime:
  [FAILED: ldsfld of value class] Prog:get_Foo():System.DateTime

New codegen:

; Assembly listing for method Prog:Test():System.DateTime
; Tier-1 compilation
       48B8D6105720E4CCDA88 mov      rax, 0x88DACCE4205710D6
       C3                   ret      
; Total bytes of code 11

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 22, 2022
@ghost ghost assigned EgorBo Nov 22, 2022
@ghost
Copy link

ghost commented Nov 22, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

It turns out that JIT used to always give up on inlining methods with ldsfld inside for fields of struct type, e.g:

static DateTime Foo { get; } = DateTime.Now;

static DateTime Test() => Foo;

Current Tier1 codegen for Test:

; Assembly listing for method Prog:Test():System.DateTime
; Tier-1 compilation
       4883EC28             sub      rsp, 40
       FF159E210E00         call     [Prog:get_Foo():System.DateTime]
       90                   nop      
       4883C428             add      rsp, 40
       C3                   ret      
; Total bytes of code 16

New codegen:

; Assembly listing for method Prog:Test():System.DateTime
; Tier-1 compilation
       48B8D6105720E4CCDA88 mov      rax, 0x88DACCE4205710D6
       C3                   ret      
; Total bytes of code 11
Author: EgorBo
Assignees: EgorBo
Labels:

area-CodeGen-coreclr

Milestone: -

@EgorBo
Copy link
Member Author

EgorBo commented Nov 26, 2022

It triggered too many inlinings some of them do not look profitable 😞 will see if I can narrow it down to cases I was interested in

@ghost ghost closed this Dec 26, 2022
@ghost
Copy link

ghost commented Dec 26, 2022

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@ghost
Copy link

ghost commented Jan 25, 2023

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@EgorBo EgorBo reopened this Feb 1, 2023
@EgorBo EgorBo marked this pull request as ready for review February 1, 2023 20:25
@EgorBo
Copy link
Member Author

EgorBo commented Feb 1, 2023

@AndyAyersMS @jakobbotsch PTAL, this PR does two things:

First, it slightly relaxes the limitation we had "if we start the actual inlining and meet a static field load/store/addr of a struct type --> reject due to possible helper calls" - I relaxed it with "if field is static readonly and initied - allow". Example:

static DateTime Foo { get; } = DateTime.Now;

static DateTime Test() => Foo;

get_Foo() getter is now inlined into Test() where previously it wasn't. The final Test() codegen is now:

; Assembly listing for method Prog:Test():System.DateTime
; Tier-1 compilation
       48B8D6105720E4CCDA88 mov      rax, 0x88DACCE4205710D6
       C3                   ret      
; Total bytes of code 11

Second, always allow inlining for cases where we currently give up due to potential helper calls (e.g. TLS field) if we have PGO data and the callsite is hot.

[ThreadStatic]
private static int TLS;

static int GetTLS() => TLS;

[MethodImpl(MethodImplOptions.NoInlining)]
static int Test() => GetTLS();

GetTLS() is now inlineable into Test() if we have PGO (dynamic or static). Previously it never inlined.
Codegen:

; Assembly listing for method Prog:Test():int
G_M6836_IG01:
       sub      rsp, 40
G_M6836_IG02:
       mov      rcx, 0xD1FFAB1E
       mov      edx, 3
       call     CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR
       mov      eax, dword ptr [rax+1CH]
G_M6836_IG03:
       add      rsp, 40
       ret      
; Total bytes of code 32

Example of a size improvement: https://www.diffchecker.com/XzMrjiah (https://www.diffchecker.com/XzMrjiah is inlined).
example of a "regression": https://www.diffchecker.com/C8s8qK81/ (more inlinees)

jit-diffs (--cctors)
PMI CodeSize Diffs for System.Private.CoreLib.dll [invoking .cctors] for  default jit

Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 5946724
Total bytes of diff: 5949700
Total bytes of delta: 2976 (0.05 % of base)
Total relative delta: 53.36
    diff is a regression.
    relative diff is a regression.


Top file regressions (bytes):
        2976 : System.Private.CoreLib.dasm (0.05% of base)

1 total files with Code Size differences (0 improved, 1 regressed), 0 unchanged.

Top method regressions (bytes):
         504 (3,360.00% of base) : System.Private.CoreLib.dasm - System.String:System.IConvertible.ToDecimal(System.IFormatProvider):System.Decimal:this
         354 (25.36% of base) : System.Private.CoreLib.dasm - System.TimeZoneInfo+StringSerializer:GetNextAdjustmentRuleValue():System.TimeZoneInfo+AdjustmentRule:this
         259 (134.20% of base) : System.Private.CoreLib.dasm - System.TimeZoneInfo+StringSerializer:GetNextDateTimeValue(System.String):System.DateTime:this
         237 (14.89% of base) : System.Private.CoreLib.dasm - System.TimeZoneInfo+StringSerializer:GetNextTransitionTimeValue():System.TimeZoneInfo+TransitionTime:this
         205 (35.16% of base) : System.Private.CoreLib.dasm - System.TimeZoneInfo:ValidateTimeZoneInfo(System.String,System.TimeSpan,System.TimeZoneInfo+AdjustmentRule[],byref)
         179 (223.75% of base) : System.Private.CoreLib.dasm - System.DateTime:TryParse(System.String,byref):bool
         179 (89.50% of base) : System.Private.CoreLib.dasm - System.DateTimeOffset:TryParse(System.String,byref):bool
         177 (218.52% of base) : System.Private.CoreLib.dasm - System.DateTime:TryParse(System.String,System.IFormatProvider,byref):bool
         169 (101.20% of base) : System.Private.CoreLib.dasm - System.DateTimeOffset:TryParse(System.ReadOnlySpan`1[ushort],byref):bool
         161 (383.33% of base) : System.Private.CoreLib.dasm - System.DateTime:TryParse(System.ReadOnlySpan`1[ushort],byref):bool
         140 (212.12% of base) : System.Private.CoreLib.dasm - System.DateTime:TryParse(System.ReadOnlySpan`1[ushort],System.IFormatProvider,byref):bool
         131 (385.29% of base) : System.Private.CoreLib.dasm - System.Decimal:System.IConvertible.ToBoolean(System.IFormatProvider):bool:this
         117 (43.49% of base) : System.Private.CoreLib.dasm - System.Reflection.Emit.DynamicMethod:LoadParameters():System.Reflection.RuntimeParameterInfo[]:this
          44 (68.75% of base) : System.Private.CoreLib.dasm - System.Reflection.Emit.DynamicMethod:get_ReturnParameter():System.Reflection.ParameterInfo:this
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[double](System.ReadOnlyMemory`1[double],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[int](System.ReadOnlyMemory`1[int],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[long](System.ReadOnlyMemory`1[long],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[short](System.ReadOnlyMemory`1[short],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[System.Nullable`1[int]](System.ReadOnlyMemory`1[System.Nullable`1[int]],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[System.Numerics.Vector`1[float]](System.ReadOnlyMemory`1[System.Numerics.Vector`1[float]],byref):bool

Top method improvements (bytes):
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[double]:ToArray():double[]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[int]:ToArray():int[]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[long]:ToArray():long[]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[short]:ToArray():short[]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[System.Nullable`1[int]]:ToArray():System.Nullable`1[int][]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[System.Numerics.Vector`1[float]]:ToArray():System.Numerics.Vector`1[float][]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[ubyte]:ToArray():ubyte[]:this

Top method regressions (percentages):
         504 (3,360.00% of base) : System.Private.CoreLib.dasm - System.String:System.IConvertible.ToDecimal(System.IFormatProvider):System.Decimal:this
         131 (385.29% of base) : System.Private.CoreLib.dasm - System.Decimal:System.IConvertible.ToBoolean(System.IFormatProvider):bool:this
         161 (383.33% of base) : System.Private.CoreLib.dasm - System.DateTime:TryParse(System.ReadOnlySpan`1[ushort],byref):bool
         179 (223.75% of base) : System.Private.CoreLib.dasm - System.DateTime:TryParse(System.String,byref):bool
         177 (218.52% of base) : System.Private.CoreLib.dasm - System.DateTime:TryParse(System.String,System.IFormatProvider,byref):bool
         140 (212.12% of base) : System.Private.CoreLib.dasm - System.DateTime:TryParse(System.ReadOnlySpan`1[ushort],System.IFormatProvider,byref):bool
         259 (134.20% of base) : System.Private.CoreLib.dasm - System.TimeZoneInfo+StringSerializer:GetNextDateTimeValue(System.String):System.DateTime:this
         169 (101.20% of base) : System.Private.CoreLib.dasm - System.DateTimeOffset:TryParse(System.ReadOnlySpan`1[ushort],byref):bool
         179 (89.50% of base) : System.Private.CoreLib.dasm - System.DateTimeOffset:TryParse(System.String,byref):bool
          44 (68.75% of base) : System.Private.CoreLib.dasm - System.Reflection.Emit.DynamicMethod:get_ReturnParameter():System.Reflection.ParameterInfo:this
         117 (43.49% of base) : System.Private.CoreLib.dasm - System.Reflection.Emit.DynamicMethod:LoadParameters():System.Reflection.RuntimeParameterInfo[]:this
         205 (35.16% of base) : System.Private.CoreLib.dasm - System.TimeZoneInfo:ValidateTimeZoneInfo(System.String,System.TimeSpan,System.TimeZoneInfo+AdjustmentRule[],byref)
         354 (25.36% of base) : System.Private.CoreLib.dasm - System.TimeZoneInfo+StringSerializer:GetNextAdjustmentRuleValue():System.TimeZoneInfo+AdjustmentRule:this
         237 (14.89% of base) : System.Private.CoreLib.dasm - System.TimeZoneInfo+StringSerializer:GetNextTransitionTimeValue():System.TimeZoneInfo+TransitionTime:this
           8 (12.31% of base) : System.Private.CoreLib.dasm - System.TimeZone:IsDaylightSavingTime(System.DateTime):bool:this
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[double](System.ReadOnlyMemory`1[double],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[int](System.ReadOnlyMemory`1[int],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[long](System.ReadOnlyMemory`1[long],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[short](System.ReadOnlyMemory`1[short],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[System.Nullable`1[int]](System.ReadOnlyMemory`1[System.Nullable`1[int]],byref):bool

Top method improvements (percentages):
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[double]:ToArray():double[]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[int]:ToArray():int[]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[long]:ToArray():long[]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[short]:ToArray():short[]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[System.Nullable`1[int]]:ToArray():System.Nullable`1[int][]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[System.Numerics.Vector`1[float]]:ToArray():System.Numerics.Vector`1[float][]:this
          -6 (-5.00% of base) : System.Private.CoreLib.dasm - System.ArraySegment`1[ubyte]:ToArray():ubyte[]:this

29 total methods with Code Size differences (7 improved, 22 regressed), 49415 unchanged

@AndyAyersMS
Copy link
Member

Can you run pmi over all the framework assemblies too (-f option)?

@EgorBo

This comment was marked as outdated.

@EgorBo
Copy link
Member Author

EgorBo commented Feb 2, 2023

@AndyAyersMS ok i've pushed a change and made it conservative:

PMI CodeSize Diffs for System.Private.CoreLib.dll, framework assemblies [invoking .cctors] for  default jit

Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 58915677
Total bytes of diff: 58915793
Total bytes of delta: 116 (0.00 % of base)
Total relative delta: NaN
    diff is a regression.
    relative diff is a regression.


Total byte diff includes 103 bytes from reconciling methods
        Base had    1 unique methods,        5 unique bytes
        Diff had    2 unique methods,      108 unique bytes

Top file regressions (bytes):
         314 : Microsoft.CodeAnalysis.CSharp.dasm (0.01% of base)
         132 : Microsoft.CodeAnalysis.dasm (0.01% of base)
         112 : System.Private.CoreLib.dasm (0.00% of base)
          70 : System.Threading.Tasks.Dataflow.dasm (0.01% of base)
          23 : System.ComponentModel.TypeConverter.dasm (0.01% of base)
           8 : Microsoft.Diagnostics.Tools.RuntimeClient.dasm (0.08% of base)

Top file improvements (bytes):
        -487 : System.Runtime.Numerics.dasm (-0.39% of base)
         -56 : System.Collections.Immutable.dasm (-0.00% of base)

8 total files with Code Size differences (2 improved, 6 regressed), 267 unchanged.

Top method regressions (bytes):
         103 (     ∞ of base) : Microsoft.CodeAnalysis.dasm - Microsoft.CodeAnalysis.SmallDictionary`2[System.__Canon,int]:LeftComplex(Microsoft.CodeAnalysis.SmallDictionary`2+AvlNode[System.__Canon,int]):Microsoft.CodeAnalysis.SmallDictionary`2+AvlNode[System.__Canon,int] (0 base, 1 diff methods)
          77 (285.19% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxNormalizer:GetSpace():Microsoft.CodeAnalysis.SyntaxTrivia:this
          55 ( 1.34% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxNormalizer:RewriteTrivia(Microsoft.CodeAnalysis.SyntaxTriviaList,int,bool,bool,bool,int):Microsoft.CodeAnalysis.SyntaxTriviaList:this
          34 (566.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.IBinaryNumber<System.Numerics.BigInteger>.get_AllBitsSet():System.Numerics.BigInteger
          34 (566.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.IMultiplicativeIdentity<System.Numerics.BigInteger,System.Numerics.BigInteger>.get_MultiplicativeIdentity():System.Numerics.BigInteger
          34 (566.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.ISignedNumber<System.Numerics.BigInteger>.get_NegativeOne():System.Numerics.BigInteger
          27 ( 2.08% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:op_UnsignedRightShift(System.Numerics.BigInteger,int):System.Numerics.BigInteger
          25 ( 0.91% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxNodeRemover+SyntaxRemover:AddTrivia(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.SyntaxToken):this
          25 ( 1.29% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxNodeRemover+SyntaxRemover:AddTrivia(Microsoft.CodeAnalysis.SyntaxNode):this
          25 ( 0.92% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxNodeRemover+SyntaxRemover:AddTrivia(Microsoft.CodeAnalysis.SyntaxToken,Microsoft.CodeAnalysis.SyntaxNode):this
          24 ( 1.51% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:op_RightShift(System.Numerics.BigInteger,int):System.Numerics.BigInteger
          23 ( 1.48% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.ReflectTypeDescriptionProvider:GetExtenders(System.Collections.ICollection,System.Object,System.Collections.IDictionary):System.ComponentModel.IExtenderProvider[]
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[double](System.ReadOnlyMemory`1[double],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[int](System.ReadOnlyMemory`1[int],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[long](System.ReadOnlyMemory`1[long],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[short](System.ReadOnlyMemory`1[short],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[System.Nullable`1[int]](System.ReadOnlyMemory`1[System.Nullable`1[int]],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[System.Numerics.Vector`1[float]](System.ReadOnlyMemory`1[System.Numerics.Vector`1[float]],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[ubyte](System.ReadOnlyMemory`1[ubyte],byref):bool
          20 (11.11% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Microsoft.CodeAnalysis.CSharp.SyntaxFactory:Identifier(System.String):Microsoft.CodeAnalysis.SyntaxToken

Top method improvements (bytes):
        -104 (-19.05% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:MaxMagnitude(System.Numerics.BigInteger,System.Numerics.BigInteger):System.Numerics.BigInteger
        -104 (-19.05% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:MinMagnitude(System.Numerics.BigInteger,System.Numerics.BigInteger):System.Numerics.BigInteger
         -89 (-20.27% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.INumberBase<System.Numerics.BigInteger>.MaxMagnitudeNumber(System.Numerics.BigInteger,System.Numerics.BigInteger):System.Numerics.BigInteger
         -89 (-20.27% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.INumberBase<System.Numerics.BigInteger>.MinMagnitudeNumber(System.Numerics.BigInteger,System.Numerics.BigInteger):System.Numerics.BigInteger
         -35 (-22.88% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:CreateSaturating[double](double):System.Numerics.BigInteger
         -35 (-22.88% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:CreateTruncating[double](double):System.Numerics.BigInteger
         -32 (-26.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.INumberBase<System.Numerics.BigInteger>.TryConvertFromSaturating[double](double,byref):bool
         -32 (-26.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.INumberBase<System.Numerics.BigInteger>.TryConvertFromTruncating[double](double,byref):bool
         -32 (-26.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:TryConvertFromSaturating[double](double,byref):bool
         -32 (-26.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:TryConvertFromTruncating[double](double,byref):bool
         -24 (-14.04% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:Abs(System.Numerics.BigInteger):System.Numerics.BigInteger
         -13 (-4.23% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:op_Decrement(System.Numerics.BigInteger):System.Numerics.BigInteger
         -13 (-4.23% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:op_Increment(System.Numerics.BigInteger):System.Numerics.BigInteger
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[double]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[double]:this
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[long]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[long]:this
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[short]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[short]:this
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[System.Nullable`1[int]]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[System.Nullable`1[int]]:this

Top method regressions (percentages):
         103 (     ∞ of base) : Microsoft.CodeAnalysis.dasm - Microsoft.CodeAnalysis.SmallDictionary`2[System.__Canon,int]:LeftComplex(Microsoft.CodeAnalysis.SmallDictionary`2+AvlNode[System.__Canon,int]):Microsoft.CodeAnalysis.SmallDictionary`2+AvlNode[System.__Canon,int] (0 base, 1 diff methods)
           5 (     ∞ of base) : System.DirectoryServices.Protocols.dasm - System.DirectoryServices.Protocols.LdapConnection:get_Timeout():System.TimeSpan:this (0 base, 1 diff methods)
          34 (566.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.IBinaryNumber<System.Numerics.BigInteger>.get_AllBitsSet():System.Numerics.BigInteger
          34 (566.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.IMultiplicativeIdentity<System.Numerics.BigInteger,System.Numerics.BigInteger>.get_MultiplicativeIdentity():System.Numerics.BigInteger
          34 (566.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.ISignedNumber<System.Numerics.BigInteger>.get_NegativeOne():System.Numerics.BigInteger
          77 (285.19% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Microsoft.CodeAnalysis.CSharp.Syntax.SyntaxNormalizer:GetSpace():Microsoft.CodeAnalysis.SyntaxTrivia:this
           7 (116.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.IAdditiveIdentity<System.Numerics.BigInteger,System.Numerics.BigInteger>.get_AdditiveIdentity():System.Numerics.BigInteger
          12 (70.59% of base) : Microsoft.CodeAnalysis.dasm - Roslyn.Utilities.ImmutableArrayExtensions:ToImmutableArrayOrEmpty[System.Nullable`1[int]](System.Collections.Generic.IEnumerable`1[System.Nullable`1[int]]):System.Collections.Immutable.ImmutableArray`1[System.Nullable`1[int]]
          20 (11.17% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Microsoft.CodeAnalysis.CSharp.SyntaxFactory:Token(ushort):Microsoft.CodeAnalysis.SyntaxToken
          20 (11.11% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Microsoft.CodeAnalysis.CSharp.SyntaxFactory:Identifier(System.String):Microsoft.CodeAnalysis.SyntaxToken
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[double](System.ReadOnlyMemory`1[double],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[int](System.ReadOnlyMemory`1[int],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[long](System.ReadOnlyMemory`1[long],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[short](System.ReadOnlyMemory`1[short],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[System.Nullable`1[int]](System.ReadOnlyMemory`1[System.Nullable`1[int]],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[System.Numerics.Vector`1[float]](System.ReadOnlyMemory`1[System.Numerics.Vector`1[float]],byref):bool
          22 ( 8.98% of base) : System.Private.CoreLib.dasm - System.Runtime.InteropServices.MemoryMarshal:TryGetArray[ubyte](System.ReadOnlyMemory`1[ubyte],byref):bool
          10 ( 5.78% of base) : System.Threading.Tasks.Dataflow.dasm - System.Threading.Tasks.Dataflow.Internal.ImmutableArray`1[int]:Remove(int):System.Threading.Tasks.Dataflow.Internal.ImmutableArray`1[int]:this
          10 ( 5.78% of base) : System.Threading.Tasks.Dataflow.dasm - System.Threading.Tasks.Dataflow.Internal.ImmutableArray`1[long]:Remove(long):System.Threading.Tasks.Dataflow.Internal.ImmutableArray`1[long]:this
          10 ( 5.68% of base) : System.Threading.Tasks.Dataflow.dasm - System.Threading.Tasks.Dataflow.Internal.ImmutableArray`1[double]:Remove(double):System.Threading.Tasks.Dataflow.Internal.ImmutableArray`1[double]:this

Top method improvements (percentages):
          -5 (-100.00% of base) : System.DirectoryServices.Protocols.dasm -
         -32 (-26.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.INumberBase<System.Numerics.BigInteger>.TryConvertFromSaturating[double](double,byref):bool
         -32 (-26.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.INumberBase<System.Numerics.BigInteger>.TryConvertFromTruncating[double](double,byref):bool
         -32 (-26.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:TryConvertFromSaturating[double](double,byref):bool
         -32 (-26.67% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:TryConvertFromTruncating[double](double,byref):bool
         -35 (-22.88% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:CreateSaturating[double](double):System.Numerics.BigInteger
         -35 (-22.88% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:CreateTruncating[double](double):System.Numerics.BigInteger
         -89 (-20.27% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.INumberBase<System.Numerics.BigInteger>.MaxMagnitudeNumber(System.Numerics.BigInteger,System.Numerics.BigInteger):System.Numerics.BigInteger
         -89 (-20.27% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:System.Numerics.INumberBase<System.Numerics.BigInteger>.MinMagnitudeNumber(System.Numerics.BigInteger,System.Numerics.BigInteger):System.Numerics.BigInteger
        -104 (-19.05% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:MaxMagnitude(System.Numerics.BigInteger,System.Numerics.BigInteger):System.Numerics.BigInteger
        -104 (-19.05% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:MinMagnitude(System.Numerics.BigInteger,System.Numerics.BigInteger):System.Numerics.BigInteger
         -24 (-14.04% of base) : System.Runtime.Numerics.dasm - System.Numerics.BigInteger:Abs(System.Numerics.BigInteger):System.Numerics.BigInteger
          -2 (-6.90% of base) : Microsoft.CodeAnalysis.dasm - Roslyn.Utilities.ImmutableArrayExtensions:ToImmutableArrayOrEmpty[System.Nullable`1[int]](System.Collections.Immutable.ImmutableArray`1[System.Nullable`1[int]]):System.Collections.Immutable.ImmutableArray`1[System.Nullable`1[int]]
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[double]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[double]:this
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[int]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[int]:this
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[long]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[long]:this
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[short]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[short]:this
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[System.Nullable`1[int]]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[System.Nullable`1[int]]:this
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[System.Numerics.Vector`1[float]]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[System.Numerics.Vector`1[float]]:this
          -8 (-6.50% of base) : System.Collections.Immutable.dasm - System.Collections.Immutable.ImmutableArray`1[ubyte]:System.Collections.Immutable.IImmutableList<T>.Clear():System.Collections.Immutable.IImmutableList`1[ubyte]:this

74 total methods with Code Size differences (33 improved, 41 regressed), 377041 unchanged.

103 ( ∞ of base) : Microsoft.CodeAnalysis.dasm is a jit-diff artifacts (appears randomly) so overall jit-diff is around zero. Some "regression" examples:

https://www.diffchecker.com/VOLamS3D/
https://www.diffchecker.com/yxFeiVHj/
https://www.diffchecker.com/LZxKOlzk/
https://www.diffchecker.com/pLjPkLmH/

@EgorBo
Copy link
Member Author

EgorBo commented Feb 2, 2023

The main motivation for this is that I need it for RuntimeInformation.IsOSPlatform(OSPlatform.Windows) to be folded.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@EgorBo EgorBo merged commit 9e5d843 into dotnet:main Feb 2, 2023
@EgorBo EgorBo deleted the allow-inlining-ldsfld-vt branch February 2, 2023 22:11
@ghost ghost locked as resolved and limited conversation to collaborators Mar 5, 2023
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants