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

Unify set-reg-to-imm functions and optimize with LEA at runtime on x64 #60228

Merged
merged 3 commits into from
Oct 15, 2021

Conversation

jakobbotsch
Copy link
Member

While working on #59602 I noticed that we did not use lea for indirection cells at runtime in x64.
This change

  • Unifies the genSetRegToImm and instGen_Set_Reg_To_Imm functions,
    removing the former. genSetRegToImm seems to be a variant that did not
    support relocations/handles, while the latter supported both. We now
    exclusively use the emitAttr to determine this. This was only a change
    in xarch since on ARM architectures the former function just forwarded
    to the latter.
  • Generates lea more often for handle GT_CNS_INT nodes on x64.
    Previously the logic generated only lea when a relocation was
    required, which is only the case for prejit. In particular, all VSD
    calls load an indirection cell that can use lea instead of the longer
    mov encoding during runtime JIT, which results in a nice code size
    decrease.
  • Changes ARM64 and ARM to handle byref-typed GT_CNS_INT nodes. This was
    fixed for xarch a few years back in
    52a8890 but that change was not made
    to ARM architectures.

This change
* Unifies the genSetRegToImm and instGen_Set_Reg_To_Imm functions,
  removing the former. genSetRegToImm seems to be a variant that did not
  support relocations/handles, while the latter supported both. We now
  exclusively use the emitAttr to determine this. This was only a change
  in xarch since on ARM architectures the former function just forwarded
  to the latter.
* Generates lea more often for handle GT_CNS_INT nodes on x64.
  Previously the logic generated only lea when a relocation was
  *required*, which is only the case for prejit. In particular, all VSD
  calls load an indirection cell that can use lea instead of the longer
  mov encoding during runtime JIT, which results in a nice code size
  decrease.
* Changes ARM64 and ARM to handle byref-typed GT_CNS_INT nodes. This was
  fixed for xarch a few years back in
  52a8890 but that change was not made
  to ARM architectures.
@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 Oct 10, 2021
@ghost
Copy link

ghost commented Oct 10, 2021

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

Issue Details

While working on #59602 I noticed that we did not use lea for indirection cells at runtime in x64.
This change

  • Unifies the genSetRegToImm and instGen_Set_Reg_To_Imm functions,
    removing the former. genSetRegToImm seems to be a variant that did not
    support relocations/handles, while the latter supported both. We now
    exclusively use the emitAttr to determine this. This was only a change
    in xarch since on ARM architectures the former function just forwarded
    to the latter.
  • Generates lea more often for handle GT_CNS_INT nodes on x64.
    Previously the logic generated only lea when a relocation was
    required, which is only the case for prejit. In particular, all VSD
    calls load an indirection cell that can use lea instead of the longer
    mov encoding during runtime JIT, which results in a nice code size
    decrease.
  • Changes ARM64 and ARM to handle byref-typed GT_CNS_INT nodes. This was
    fixed for xarch a few years back in
    52a8890 but that change was not made
    to ARM architectures.
Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch
Copy link
Member Author

No code size diffs on ARM64, but bullet 3 above means we see some GC info diffs:

libraries.crossgen2.Linux.arm64.checked.mch:


Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 48198936 (overridden on cmd)
Total bytes of diff: 48198936 (overridden on cmd)
Total bytes of delta: 0 (0.00 % of base)
Detail diffs


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

0 total methods with Code Size differences (0 improved, 0 regressed), 31 unchanged.


For example:

             ; gcr arg pop 0
             adrp    x11, [HIGH RELOC #0xd1ffab1e]      // static handle
             add     x11, x11, [LOW RELOC #0xd1ffab1e]
+            ; byrRegs +[x11]
             lsl     x0, x0, #1
             add     x0, x0, x11
             ; byrRegs +[x0]
             ldrsh   w0, [x0]
             ; byrRegs -[x0]
             ldr     w11, [fp,#36]      // [V57 tmp46]
+            ; byrRegs -[x11]
             add     w1, w0, w11
             str     w1, [fp,#40]       // [V56 tmp45]
             mov     w0, w1
 G_M47710_IG02:        ; gcrefRegs=80000 {x19}, byrefRegs=0000 {}, byref
             adrp    x20, [HIGH RELOC #0xd1ffab1e]      // static handle
             add     x20, x20, [LOW RELOC #0xd1ffab1e]
+            ; byrRegs +[x20]
             adrp    x11, [HIGH RELOC #0xd1ffab1e]      // function address
             add     x11, x11, [LOW RELOC #0xd1ffab1e]
             ldr     x0, [x11]
             blr     x0
-            ; byrRegs +[x0 x20]
+            ; byrRegs +[x0]
             ; gcr arg pop 0
             ldr     x0, [x0,#0xd1ffab1e]
             ; gcrRegs +[x0]

For x64 we see diffs in non-crossgen2 collections only, as expected. The summary is:

aspnet.run.windows.x64.checked.mch:


Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 11960181 (overridden on cmd)
Total bytes of diff: 11895324 (overridden on cmd)
Total bytes of delta: -64857 (-0.54 % of base)
    diff is an improvement.
    relative diff is an improvement.
Detail diffs


Top file regressions (bytes):
          17 : 35354.dasm (0.75% of base)

Top file improvements (bytes):
        -360 : 26625.dasm (-6.73% of base)
        -360 : 17786.dasm (-1.52% of base)
        -360 : 36969.dasm (-3.49% of base)
        -266 : 37966.dasm (-6.44% of base)
        -262 : 27382.dasm (-6.32% of base)
        -257 : 37488.dasm (-4.78% of base)
        -254 : 26972.dasm (-4.75% of base)
        -240 : 18395.dasm (-2.10% of base)
        -237 : 18937.dasm (-2.50% of base)
        -213 : 28043.dasm (-2.55% of base)
        -213 : 38882.dasm (-2.56% of base)
        -210 : 27473.dasm (-4.07% of base)
        -210 : 38060.dasm (-4.10% of base)
        -192 : 19049.dasm (-1.90% of base)
        -172 : 27552.dasm (-3.54% of base)
        -172 : 38143.dasm (-3.55% of base)
        -165 : 37985.dasm (-6.31% of base)
        -165 : 27401.dasm (-6.42% of base)
        -153 : 20012.dasm (-1.54% of base)
        -150 : 18956.dasm (-2.38% of base)

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

Top method regressions (bytes):
          17 ( 0.75% of base) : 35354.dasm - <MultiplexingWriteLoop>d__20:MoveNext():this

Top method improvements (bytes):
        -360 (-6.73% of base) : 26625.dasm - ProviderConventionSetBuilder:CreateConventionSet():ConventionSet:this
        -360 (-1.52% of base) : 17786.dasm - ProviderConventionSetBuilder:CreateConventionSet():ConventionSet:this
        -360 (-3.49% of base) : 36969.dasm - ProviderConventionSetBuilder:CreateConventionSet():ConventionSet:this
        -266 (-6.44% of base) : 37966.dasm - ModelValidator:ValidateData(IModel,IDiagnosticsLogger`1):this
        -262 (-6.32% of base) : 27382.dasm - ModelValidator:ValidateData(IModel,IDiagnosticsLogger`1):this
        -257 (-4.78% of base) : 37488.dasm - RelationshipDiscoveryConvention:CreateRelationships(IEnumerable`1,IConventionEntityTypeBuilder):this
        -254 (-4.75% of base) : 26972.dasm - RelationshipDiscoveryConvention:CreateRelationships(IEnumerable`1,IConventionEntityTypeBuilder):this
        -240 (-2.10% of base) : 18395.dasm - RelationshipDiscoveryConvention:CreateRelationships(IEnumerable`1,IConventionEntityTypeBuilder):this
        -237 (-2.50% of base) : 18937.dasm - ModelValidator:ValidateData(IModel,IDiagnosticsLogger`1):this
        -213 (-2.55% of base) : 28043.dasm - SelectExpression:.ctor(IEntityType,ISqlExpressionFactory):this
        -213 (-2.56% of base) : 38882.dasm - SelectExpression:.ctor(IEntityType,ISqlExpressionFactory):this
        -210 (-4.07% of base) : 27473.dasm - RelationalModel:PopulateConstraints(Table)
        -210 (-4.10% of base) : 38060.dasm - RelationalModel:PopulateConstraints(Table)
        -192 (-1.90% of base) : 19049.dasm - RelationalModel:PopulateConstraints(Table)
        -172 (-3.54% of base) : 27552.dasm - SlimModelConvention:Create(IModel):SlimModel:this
        -172 (-3.55% of base) : 38143.dasm - SlimModelConvention:Create(IModel):SlimModel:this
        -165 (-6.31% of base) : 37985.dasm - RelationalModelValidator:ValidateDbFunctions(IModel,IDiagnosticsLogger`1):this
        -165 (-6.42% of base) : 27401.dasm - RelationalModelValidator:ValidateDbFunctions(IModel,IDiagnosticsLogger`1):this
        -153 (-1.54% of base) : 20012.dasm - SelectExpression:.ctor(IEntityType,ISqlExpressionFactory):this
        -150 (-2.38% of base) : 18956.dasm - RelationalModelValidator:ValidateDbFunctions(IModel,IDiagnosticsLogger`1):this

Top method regressions (percentages):
          17 ( 0.75% of base) : 35354.dasm - <MultiplexingWriteLoop>d__20:MoveNext():this

Top method improvements (percentages):
          -3 (-18.75% of base) : 39749.dasm - DbContextDependenciesExtensions:GetDependencies(ICurrentDbContext):IDbContextDependencies
          -3 (-18.75% of base) : 39548.dasm - DiagnosticsLogger`1:ShouldLog(EventDefinitionBase):bool:this
          -3 (-15.79% of base) : 27982.dasm - <>c:<.cctor>b__185_1(IGrouping`2):String:this
          -3 (-15.79% of base) : 39530.dasm - <>c:<.ctor>b__5_0(IInterceptorAggregator):Type:this
          -3 (-15.79% of base) : 26408.dasm - <>c:<.ctor>b__5_0(IInterceptorAggregator):Type:this
          -3 (-15.79% of base) : 27509.dasm - <>c:<For>b__2_1(IColumnMapping):IProperty:this
          -3 (-15.79% of base) : 28061.dasm - <>c:<GetAllPropertiesInHierarchy>b__108_0(IEntityType):IEnumerable`1:this
          -3 (-15.79% of base) : 27084.dasm - <>c:<ProcessEntityTypePrimaryKeyChanged>b__24_1(IConventionEntityType):IEnumerable`1:this
          -3 (-15.79% of base) : 27074.dasm - <>c:<ProcessKeyAdded>b__22_0(IConventionEntityType):IEnumerable`1:this
          -3 (-15.79% of base) : 27077.dasm - <>c:<ProcessKeyAdded>b__8_0(IConventionEntityType):IEnumerable`1:this
          -3 (-15.79% of base) : 27421.dasm - <>c:<ValidateIndexIncludeProperties>b__4_0(IEntityType):IEnumerable`1:this
          -3 (-15.79% of base) : 27349.dasm - <>c:<ValidateNoShadowKeys>b__11_0(IConventionProperty):bool:this
          -3 (-15.79% of base) : 27336.dasm - <>c:<ValidatePropertyMapping>b__7_3(IConventionProperty):String:this
          -3 (-15.79% of base) : 27411.dasm - <>c:<ValidateSharedForeignKeysCompatibility>b__17_0(IEntityType):IEnumerable`1:this
          -3 (-15.79% of base) : 27413.dasm - <>c:<ValidateSharedIndexesCompatibility>b__19_0(IEntityType):IEnumerable`1:this
          -3 (-15.79% of base) : 27409.dasm - <>c:<ValidateSharedKeysCompatibility>b__21_0(IEntityType):IEnumerable`1:this
          -3 (-15.79% of base) : 27587.dasm - <>c__6`2:<CreateAnnotations>b__6_0(IAnnotation):String:this
          -3 (-15.79% of base) : 27588.dasm - <>c__6`2:<CreateAnnotations>b__6_1(IAnnotation):Object:this
          -3 (-15.00% of base) : 34010.dasm - <>c__DisplayClass211_0:<GenerateDeserializerFromMap>b__0(int):String:this
          -3 (-15.00% of base) : 34024.dasm - <>c__DisplayClass211_0:<GenerateDeserializerFromMap>b__2(String):IMemberMap:this

5276 total methods with Code Size differences (5275 improved, 1 regressed), 0 unchanged.


coreclr_tests.pmi.windows.x64.checked.mch:


Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 124743316 (overridden on cmd)
Total bytes of diff: 124730707 (overridden on cmd)
Total bytes of delta: -12609 (-0.01 % of base)
    diff is an improvement.
    relative diff is an improvement.
Detail diffs


Top file regressions (bytes):
           5 : 241162.dasm (0.47% of base)

Top file improvements (bytes):
        -252 : 225136.dasm (-4.03% of base)
        -252 : 225169.dasm (-4.00% of base)
        -252 : 225137.dasm (-4.03% of base)
        -252 : 225138.dasm (-4.03% of base)
        -252 : 225167.dasm (-4.00% of base)
        -252 : 225168.dasm (-4.00% of base)
        -168 : 235691.dasm (-4.09% of base)
        -168 : 235692.dasm (-4.09% of base)
        -168 : 235693.dasm (-4.09% of base)
        -168 : 235694.dasm (-4.09% of base)
        -168 : 235695.dasm (-4.07% of base)
        -168 : 235696.dasm (-4.07% of base)
        -108 : 243676.dasm (-5.34% of base)
         -88 : 212860.dasm (-3.65% of base)
         -87 : 212859.dasm (-3.65% of base)
         -84 : 225171.dasm (-3.94% of base)
         -84 : 225172.dasm (-3.91% of base)
         -84 : 225175.dasm (-3.92% of base)
         -84 : 225141.dasm (-3.91% of base)
         -84 : 225142.dasm (-3.92% of base)

1009 total files with Code Size differences (1008 improved, 1 regressed), 2 unchanged.

Top method regressions (bytes):
           5 ( 0.47% of base) : 241162.dasm - BB:Method1(byref,byref,byref,AA`6[SByte,Byte,UInt32,UInt32,Int64,Boolean],byref,int):this

Top method improvements (bytes):
        -252 (-4.00% of base) : 225169.dasm - mainMethod:callCheckAs()
        -252 (-4.03% of base) : 225138.dasm - mainMethod:callCheckAs()
        -252 (-4.03% of base) : 225136.dasm - mainMethod:callCheckGetType()
        -252 (-4.00% of base) : 225167.dasm - mainMethod:callCheckGetType()
        -252 (-4.03% of base) : 225137.dasm - mainMethod:callCheckIs()
        -252 (-4.00% of base) : 225168.dasm - mainMethod:callCheckIs()
        -168 (-4.09% of base) : 235693.dasm - mainMethod:callCheckAs()
        -168 (-4.07% of base) : 235696.dasm - mainMethod:callCheckAsObjectCast()
        -168 (-4.09% of base) : 235691.dasm - mainMethod:callCheckGetType()
        -168 (-4.09% of base) : 235694.dasm - mainMethod:callCheckGetTypeObjectCast()
        -168 (-4.09% of base) : 235692.dasm - mainMethod:callCheckIs()
        -168 (-4.07% of base) : 235695.dasm - mainMethod:callCheckIsObjectCast()
        -108 (-5.34% of base) : 243676.dasm - Program:SingleOverride()
         -88 (-3.65% of base) : 212860.dasm - NetClient.StringTests:Marshal_LPWString():this
         -87 (-3.65% of base) : 212859.dasm - NetClient.StringTests:Marshal_LPString():this
         -84 (-3.92% of base) : 225175.dasm - mainMethod:callCheckAsIntCast()
         -84 (-3.92% of base) : 225144.dasm - mainMethod:callCheckAsIntCast()
         -84 (-3.91% of base) : 225174.dasm - mainMethod:callCheckAsStringCast()
         -84 (-3.91% of base) : 225143.dasm - mainMethod:callCheckAsStringCast()
         -84 (-3.94% of base) : 225171.dasm - mainMethod:callCheckGetTypeIntCast()

Top method regressions (percentages):
           5 ( 0.47% of base) : 241162.dasm - BB:Method1(byref,byref,byref,AA`6[SByte,Byte,UInt32,UInt32,Int64,Boolean],byref,int):this

Top method improvements (percentages):
          -3 (-18.75% of base) : 224100.dasm - IDynamicInterfaceCastableTests.BadDynamicInterfaceCastable:UseOther(IDynamicInterfaceCastableTests.IOther):int
          -3 (-18.75% of base) : 251252.dasm - MyClass:TestInterfaceMethod(IMyInterface,System.String):System.String
          -3 (-18.75% of base) : 246391.dasm - MyClass:TestInterfaceMethod(IMyInterface,System.String):System.String
          -3 (-18.75% of base) : 83749.dasm - Program:DoWork(IMyInterface`1[Byte]):int
          -3 (-18.75% of base) : 86704.dasm - RemoteBase_InSeparateAssembly:UseIProtected(IProtected_InSeparateAssembly):System.String
          -3 (-18.75% of base) : 83779.dasm - T:F(I`1[[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]):System.Object
          -3 (-18.75% of base) : 254239.dasm - Z:Hi(Iz):int
          -3 (-18.75% of base) : 254238.dasm - Z:Hz(Iz):int
          -3 (-18.75% of base) : 254231.dasm - Z:IxF(Ix):int
          -3 (-18.75% of base) : 254232.dasm - Z:IxG(Ix):int
          -3 (-15.79% of base) : 239742.dasm - <>c:<DataflowBench>b__8_0(Microsoft.CodeAnalysis.ISymbol):System.String:this
          -3 (-15.00% of base) : 223882.dasm - GCSimulator.ObjectLifeTimeManager:AddObject(GCSimulator.LifeTime,int):this
          -3 (-15.00% of base) : 223881.dasm - GCSimulator.ObjectLifeTimeManager:Init(int):this
          -3 (-15.00% of base) : 223856.dasm - LifeTimeFX.ObjectLifeTimeManager:AddObject(LifeTimeFX.LifeTime,int):this
          -3 (-15.00% of base) : 223855.dasm - LifeTimeFX.ObjectLifeTimeManager:Init(int):this
          -3 (-15.00% of base) : 252513.dasm - MyCollection`1[__Canon][System.__Canon]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-15.00% of base) : 252521.dasm - MyCollection`1[Byte][System.Byte]:get_IsReadOnly():bool:this
          -3 (-15.00% of base) : 252523.dasm - MyCollection`1[Byte][System.Byte]:GetEnumerator():System.Collections.Generic.IEnumerator`1[Byte]:this
          -3 (-15.00% of base) : 252524.dasm - MyCollection`1[Byte][System.Byte]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-15.00% of base) : 219155.dasm - System.Collections.Concurrent.IProducerConsumerCollection_DebugView`1[Byte][System.Byte]:get_Values():System.Byte[]:this

1009 total methods with Code Size differences (1008 improved, 1 regressed), 2 unchanged.


libraries.pmi.windows.x64.checked.mch:


Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 45484449 (overridden on cmd)
Total bytes of diff: 45336876 (overridden on cmd)
Total bytes of delta: -147573 (-0.32 % of base)
    diff is an improvement.
    relative diff is an improvement.
Detail diffs


Top file regressions (bytes):
           2 : 174230.dasm (0.39% of base)
           1 : 20823.dasm (0.11% of base)

Top file improvements (bytes):
        -255 : 201573.dasm (-1.50% of base)
        -189 : 201549.dasm (-1.29% of base)
        -186 : 232090.dasm (-4.20% of base)
        -183 : 231592.dasm (-4.16% of base)
        -168 : 102337.dasm (-4.77% of base)
        -160 : 83447.dasm (-6.46% of base)
        -160 : 27776.dasm (-2.22% of base)
        -159 : 78270.dasm (-3.53% of base)
        -157 : 168030.dasm (-1.45% of base)
        -155 : 140423.dasm (-3.52% of base)
        -154 : 138192.dasm (-4.01% of base)
        -153 : 83448.dasm (-5.15% of base)
        -150 : 137494.dasm (-4.17% of base)
        -147 : 204412.dasm (-3.42% of base)
        -144 : 104562.dasm (-5.08% of base)
        -141 : 201562.dasm (-0.71% of base)
        -138 : 168020.dasm (-2.09% of base)
        -138 : 108839.dasm (-2.48% of base)
        -132 : 53500.dasm (-1.57% of base)
        -132 : 201552.dasm (-1.12% of base)

17776 total files with Code Size differences (17774 improved, 2 regressed), 13 unchanged.

Top method regressions (bytes):
           2 ( 0.39% of base) : 174230.dasm - Node[Vector`1][System.Numerics.Vector`1[System.Single]]:Remove(System.Numerics.Vector`1[Single],System.Collections.Generic.IComparer`1[Vector`1],byref):Node[Vector`1]:this
           1 ( 0.11% of base) : 20823.dasm - CollectionsMarshalHelper[Int32,Nullable`1][System.Int32,System.Nullable`1[System.Int32]]:GetValueRefOrAddDefault(System.Collections.Generic.Dictionary`2[Int32,Nullable`1],int,byref):byref

Top method improvements (bytes):
        -255 (-1.50% of base) : 201573.dasm - System.Management.ManagementClassGenerator:GenerateTypeConverterClass():System.CodeDom.CodeTypeDeclaration:this
        -189 (-1.29% of base) : 201549.dasm - System.Management.ManagementClassGenerator:AddToDateTimeFunction():this
        -186 (-4.20% of base) : 232090.dasm - <AfterTestCaseStartingAsync>d__9:MoveNext():this
        -183 (-4.16% of base) : 231592.dasm - Xunit.Sdk.TheoryDiscoverer:Discover(Xunit.Abstractions.ITestFrameworkDiscoveryOptions,Xunit.Abstractions.ITestMethod,Xunit.Abstractions.IAttributeInfo):System.Collections.Generic.IEnumerable`1[[Xunit.Sdk.IXunitTestCase, xunit.core, Version=2.4.2.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c]]:this
        -168 (-4.77% of base) : 102337.dasm - Microsoft.VisualBasic.CompilerServices.ObjectType:ObjTst(System.Object,System.Object,bool):int
        -160 (-2.22% of base) : 27776.dasm - Microsoft.CodeAnalysis.CSharp.SymbolDisplayVisitor:VisitMethod(Microsoft.CodeAnalysis.IMethodSymbol):this
        -160 (-6.46% of base) : 83447.dasm - Microsoft.Diagnostics.Tracing.Etlx.TraceLog:FastSerialization.IFastSerializable.ToStream(FastSerialization.Serializer):this
        -159 (-3.53% of base) : 78270.dasm - Microsoft.CodeAnalysis.Emit.DeltaMetadataWriter:CreateIndicesForNonTypeMembers(Microsoft.Cci.ITypeDefinition):this
        -157 (-1.45% of base) : 168030.dasm - R2RTest.BuildFolderSet:WriteBuildStatistics(System.IO.StreamWriter):this
        -155 (-3.52% of base) : 140423.dasm - System.Xml.Xsl.Xslt.QilGenerator:System.Xml.Xsl.XPath.IXPathEnvironment.ResolveFunction(System.String,System.String,System.Collections.Generic.IList`1[[System.Xml.Xsl.Qil.QilNode, System.Private.Xml, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51]],System.Xml.Xsl.XPath.IFocus):System.Xml.Xsl.Qil.QilNode:this
        -154 (-4.01% of base) : 138192.dasm - System.Xml.Schema.SchemaCollectionCompiler:Compile():this
        -153 (-5.15% of base) : 83448.dasm - Microsoft.Diagnostics.Tracing.Etlx.TraceLog:FastSerialization.IFastSerializable.FromStream(FastSerialization.Deserializer):this
        -150 (-4.17% of base) : 137494.dasm - System.Xml.Schema.Compiler:Compile():bool:this
        -147 (-3.42% of base) : 204412.dasm - System.Net.Mail.MailMessage:SetContent(bool):this
        -144 (-5.08% of base) : 104562.dasm - Newtonsoft.Json.JsonValidatingReader:ValidateCurrentToken():this
        -141 (-0.71% of base) : 201562.dasm - System.Management.ManagementClassGenerator:GenerateMethods():this
        -138 (-2.09% of base) : 168020.dasm - R2RTest.BuildFolderSet:CompileFramework():bool:this
        -138 (-2.48% of base) : 108839.dasm - System.Data.XSDSchema:LoadSchema(System.Xml.Schema.XmlSchemaSet,System.Data.DataSet):this
        -132 (-1.57% of base) : 53500.dasm - Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser:ParseConditionalCompilationSymbols(System.String,byref,System.Collections.Generic.IEnumerable`1[[System.Collections.Generic.KeyValuePair`2[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]):System.Collections.Generic.IReadOnlyDictionary`2[[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]
        -132 (-1.12% of base) : 201552.dasm - System.Management.ManagementClassGenerator:AddToDMTFDateTimeFunction():this

Top method regressions (percentages):
           2 ( 0.39% of base) : 174230.dasm - Node[Vector`1][System.Numerics.Vector`1[System.Single]]:Remove(System.Numerics.Vector`1[Single],System.Collections.Generic.IComparer`1[Vector`1],byref):Node[Vector`1]:this
           1 ( 0.11% of base) : 20823.dasm - CollectionsMarshalHelper[Int32,Nullable`1][System.Int32,System.Nullable`1[System.Int32]]:GetValueRefOrAddDefault(System.Collections.Generic.Dictionary`2[Int32,Nullable`1],int,byref):byref

Top method improvements (percentages):
          -3 (-18.75% of base) : 70301.dasm - Microsoft.CodeAnalysis.VisualBasic.VisualBasicExtensions:IsMe(Microsoft.CodeAnalysis.IParameterSymbol):bool
          -3 (-18.75% of base) : 70300.dasm - Microsoft.CodeAnalysis.VisualBasic.VisualBasicExtensions:IsMustOverride(Microsoft.CodeAnalysis.ISymbol):bool
          -3 (-18.75% of base) : 70299.dasm - Microsoft.CodeAnalysis.VisualBasic.VisualBasicExtensions:IsNotOverridable(Microsoft.CodeAnalysis.ISymbol):bool
          -3 (-18.75% of base) : 70298.dasm - Microsoft.CodeAnalysis.VisualBasic.VisualBasicExtensions:IsOverridable(Microsoft.CodeAnalysis.ISymbol):bool
          -3 (-18.75% of base) : 70297.dasm - Microsoft.CodeAnalysis.VisualBasic.VisualBasicExtensions:IsOverrides(Microsoft.CodeAnalysis.ISymbol):bool
          -3 (-18.75% of base) : 70296.dasm - Microsoft.CodeAnalysis.VisualBasic.VisualBasicExtensions:IsShared(Microsoft.CodeAnalysis.ISymbol):bool
          -3 (-18.75% of base) : 10461.dasm - Microsoft.FSharp.Collections.IEnumerator:dispose(System.IDisposable)
          -3 (-18.75% of base) : 106522.dasm - Newtonsoft.Json.Linq.JToken:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 168440.dasm - System.CodeDom.CodeAttributeArgumentCollection:Add(System.CodeDom.CodeAttributeArgument):int:this
          -3 (-18.75% of base) : 168443.dasm - System.CodeDom.CodeAttributeArgumentCollection:Contains(System.CodeDom.CodeAttributeArgument):bool:this
          -3 (-18.75% of base) : 168444.dasm - System.CodeDom.CodeAttributeArgumentCollection:CopyTo(System.CodeDom.CodeAttributeArgument[],int):this
          -3 (-18.75% of base) : 168445.dasm - System.CodeDom.CodeAttributeArgumentCollection:IndexOf(System.CodeDom.CodeAttributeArgument):int:this
          -3 (-18.75% of base) : 168446.dasm - System.CodeDom.CodeAttributeArgumentCollection:Insert(int,System.CodeDom.CodeAttributeArgument):this
          -3 (-18.75% of base) : 168447.dasm - System.CodeDom.CodeAttributeArgumentCollection:Remove(System.CodeDom.CodeAttributeArgument):this
          -3 (-18.75% of base) : 168439.dasm - System.CodeDom.CodeAttributeArgumentCollection:set_Item(int,System.CodeDom.CodeAttributeArgument):this
          -3 (-18.75% of base) : 169467.dasm - System.Collections.Concurrent.BlockingCollection`1[__Canon][System.__Canon]:CopyTo(System.__Canon[],int):this
          -3 (-18.75% of base) : 169529.dasm - System.Collections.Concurrent.BlockingCollection`1[Byte][System.Byte]:CopyTo(System.Byte[],int):this
          -3 (-18.75% of base) : 169534.dasm - System.Collections.Concurrent.BlockingCollection`1[Byte][System.Byte]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 20474.dasm - System.Collections.Concurrent.ConcurrentQueue`1[Byte][System.Byte]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 180209.dasm - System.ComponentModel.Design.DesignerVerbCollection:Add(System.ComponentModel.Design.DesignerVerb):int:this

17776 total methods with Code Size differences (17774 improved, 2 regressed), 13 unchanged.


libraries_tests.pmi.windows.x64.checked.mch:


Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 114639693 (overridden on cmd)
Total bytes of diff: 114283403 (overridden on cmd)
Total bytes of delta: -356290 (-0.31 % of base)
    diff is an improvement.
    relative diff is an improvement.
Detail diffs


Top file improvements (bytes):
       -2358 : 24492.dasm (-2.82% of base)
       -2358 : 24507.dasm (-2.88% of base)
        -450 : 24500.dasm (-2.55% of base)
        -432 : 24502.dasm (-2.78% of base)
        -342 : 147588.dasm (-5.99% of base)
        -302 : 134943.dasm (-5.69% of base)
        -270 : 3446.dasm (-5.13% of base)
        -267 : 248685.dasm (-3.67% of base)
        -267 : 248899.dasm (-3.67% of base)
        -267 : 249001.dasm (-3.67% of base)
        -267 : 249157.dasm (-3.67% of base)
        -267 : 248618.dasm (-3.67% of base)
        -234 : 258991.dasm (-3.96% of base)
        -219 : 302144.dasm (-4.07% of base)
        -213 : 237028.dasm (-6.07% of base)
        -198 : 236682.dasm (-6.27% of base)
        -195 : 280736.dasm (-2.72% of base)
        -183 : 157852.dasm (-1.91% of base)
        -180 : 144713.dasm (-2.01% of base)
        -180 : 144758.dasm (-2.01% of base)

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

Top method improvements (bytes):
       -2358 (-2.88% of base) : 24507.dasm - ManagedTests.DynamicCSharp.Conformance.dynamic.statements.freach.freach001.freach001.Test:MainMethod():int
       -2358 (-2.82% of base) : 24492.dasm - ManagedTests.DynamicCSharp.Conformance.dynamic.statements.freach.freach007.freach007.Test:MainMethod():int
        -450 (-2.55% of base) : 24500.dasm - ManagedTests.DynamicCSharp.Conformance.dynamic.statements.freach.freach004.freach004.Test:MainMethod():int
        -432 (-2.78% of base) : 24502.dasm - ManagedTests.DynamicCSharp.Conformance.dynamic.statements.freach.freach003.freach003.Test:MainMethod():int
        -342 (-5.99% of base) : 147588.dasm - System.ComponentModel.Composition.CompositionServicesTests:GetDefaultContractNameTest():this
        -302 (-5.69% of base) : 134943.dasm - <EnumerateMemoryRegions>d__62:MoveNext():bool:this
        -270 (-5.13% of base) : 3446.dasm - Microsoft.CodeAnalysis.Workspace:ApplyProjectChanges(Microsoft.CodeAnalysis.ProjectChanges):this
        -267 (-3.67% of base) : 248685.dasm - Microsoft.Extensions.Configuration.Test.ConfigurationProviderTestBase:AssertConfig(Microsoft.Extensions.Configuration.IConfigurationRoot,bool,System.String):this
        -267 (-3.67% of base) : 248899.dasm - Microsoft.Extensions.Configuration.Test.ConfigurationProviderTestBase:AssertConfig(Microsoft.Extensions.Configuration.IConfigurationRoot,bool,System.String):this
        -267 (-3.67% of base) : 249001.dasm - Microsoft.Extensions.Configuration.Test.ConfigurationProviderTestBase:AssertConfig(Microsoft.Extensions.Configuration.IConfigurationRoot,bool,System.String):this
        -267 (-3.67% of base) : 249157.dasm - Microsoft.Extensions.Configuration.Test.ConfigurationProviderTestBase:AssertConfig(Microsoft.Extensions.Configuration.IConfigurationRoot,bool,System.String):this
        -267 (-3.67% of base) : 248618.dasm - Microsoft.Extensions.Configuration.Test.ConfigurationProviderTestBase:AssertConfig(Microsoft.Extensions.Configuration.IConfigurationRoot,bool,System.String):this
        -234 (-3.96% of base) : 258991.dasm - NuGet.ProjectModel.LockFileTargetLibrary:GetHashCode():int:this
        -219 (-4.07% of base) : 302144.dasm - System.Net.NetworkInformation.Tests.IPInterfacePropertiesTest_Windows:<IPInfoTest_AccessAllProperties_NoErrors>b__2_0():this
        -213 (-6.07% of base) : 237028.dasm - Grace.DependencyInjection.Impl.Expressions.ActivationExpressionBuilder:GetValueFromRequest(Grace.DependencyInjection.IInjectionScope,Grace.DependencyInjection.IActivationExpressionRequest,System.Type,System.Object):Grace.DependencyInjection.IActivationExpressionResult:this
        -198 (-6.27% of base) : 236682.dasm - Grace.DependencyInjection.Impl.InjectionScope:Configure(System.Action`1[[Grace.DependencyInjection.IExportRegistrationBlock, Grace, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b7d24c6367970497]]):this
        -195 (-2.72% of base) : 280736.dasm - System.Diagnostics.Tests.ProcessStartInfoTests:TestEnvironmentProperty():this
        -183 (-1.91% of base) : 157852.dasm - BasicEventSourceTests.TestsWriteEventToListener:Test_WriteEvent_ArgsBasicTypes():this
        -180 (-2.01% of base) : 144758.dasm - System.CodeDom.Compiler.Tests.CSharpCodeGenerationTests:RegionsSnippetsAndLinePragmas():this
        -180 (-2.01% of base) : 144713.dasm - System.CodeDom.Compiler.Tests.VBCodeGenerationTests:RegionsSnippetsAndLinePragmas():this

Top method improvements (percentages):
          -3 (-18.75% of base) : 228419.dasm - Castle.Components.DictionaryAdapter.ListProjection`1[__Canon][System.__Canon]:Replace(System.Collections.Generic.IEnumerable`1[__Canon]):this
          -3 (-18.75% of base) : 228469.dasm - Castle.Components.DictionaryAdapter.ListProjection`1[Byte][System.Byte]:Replace(System.Collections.Generic.IEnumerable`1[Byte]):this
          -3 (-18.75% of base) : 232147.dasm - DryIoc.Resolver:Resolve(DryIoc.IResolver,System.Type,int):System.Object
          -3 (-18.75% of base) : 234493.dasm - FluentAssertions.Equivalency.EquivalencyAssertionOptionsExtentions:ShouldUseRuntimeType(FluentAssertions.Equivalency.IEquivalencyAssertionOptions):bool
          -3 (-18.75% of base) : 325945.dasm - ImplementDictionary:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 67142.dasm - ImplementDictionary:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 327107.dasm - ImplementDictionary:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 348266.dasm - ImplementDictionary:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 349246.dasm - ImplementDictionary:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 198142.dasm - ImplementDictionary:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 240097.dasm - LamarCompiler.Util.LightweightCache`2[__Canon,Nullable`1][System.__Canon,System.Nullable`1[System.Int32]]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 240122.dasm - LamarCompiler.Util.LightweightCache`2[Byte,Nullable`1][System.Byte,System.Nullable`1[System.Int32]]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 242110.dasm - LightInject.ServiceRegistryExtensions:RegisterTransient(LightInject.IServiceRegistry,System.Type):LightInject.IServiceRegistry
          -3 (-18.75% of base) : 242158.dasm - LightInject.ServiceRegistryExtensions:RegisterTransient(LightInject.IServiceRegistry,System.Type,System.Type):LightInject.IServiceRegistry
          -3 (-18.75% of base) : 242111.dasm - LightInject.ServiceRegistryExtensions:RegisterTransient(LightInject.IServiceRegistry,System.Type,System.Type,System.String):LightInject.IServiceRegistry
          -3 (-18.75% of base) : 122558.dasm - Microsoft.Build.Collections.CopyOnReadEnumerable`1[Byte][System.Byte]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 244049.dasm - Microsoft.Build.Collections.CopyOnWriteDictionary`1[Byte][System.Byte]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 122607.dasm - Microsoft.Build.Collections.CopyOnWriteDictionary`1[Byte][System.Byte]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 114518.dasm - Microsoft.Build.Collections.CopyOnWriteDictionary`1[Byte][System.Byte]:System.Collections.IEnumerable.GetEnumerator():System.Collections.IEnumerator:this
          -3 (-18.75% of base) : 119201.dasm - Microsoft.Build.Evaluation.ProjectImportPathMatch:.ctor(Microsoft.Build.BackEnd.ITranslator):this

39768 total methods with Code Size differences (39768 improved, 0 regressed), 11 unchanged.


Some example diffs:

 G_M11776_IG03:        ; gcrefRegs=00000040 {rsi}, byrefRegs=00000000 {}, byref
        mov      rcx, gword ptr [rsi+32]
        ; gcrRegs +[rcx]
-       mov      r11, 0xD1FFAB1E
+       lea      r11, [(reloc)]
        call     [hackishModuleName:hackishMethodName()]
        ; gcrRegs -[rcx] +[rax]
        ; gcr arg pop 0
@@ -81,11 +81,11 @@ G_M11776_IG03:        ; gcrefRegs=00000040 {rsi}, byrefRegs=00000000 {}, byref
        call     CORINFO_HELP_ASSIGN_REF
        ; gcrRegs -[rax rdx]
        ; byrRegs -[rcx]
-                                               ;; bbWeight=0.50 PerfScore 8.00
+                                               ;; bbWeight=0.50 PerfScore 8.12
 G_M40268_IG02:        ; gcrefRegs=00000002 {rcx}, byrefRegs=00000000 {}, byref
        ; gcrRegs +[rcx]
        mov      rcx, gword ptr [rcx+8]
-       mov      r11, 0xD1FFAB1E
-                                               ;; bbWeight=1    PerfScore 2.25
+       lea      r11, [(reloc)]
+                                               ;; bbWeight=1    PerfScore 2.50
 G_M40268_IG03:        ; , epilog, nogc, extend
        tail.jmp [hackishModuleName:hackishMethodName()]
        ; gcr arg pop 0

@jakobbotsch
Copy link
Member Author

PTAL @dotnet/jit-contrib

Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

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

LGTM

@jakobbotsch jakobbotsch merged commit f40247e into dotnet:main Oct 15, 2021
@jakobbotsch jakobbotsch deleted the lea-indir-cells branch October 15, 2021 08:43
@kunalspathak
Copy link
Member

kunalspathak commented Oct 19, 2021

windows/x64 improvement dotnet/perf-autofiling-issues#1907
@jakobbotsch - Can you double check the improvement/regression that was seen in Benchstone.BenchI.BenchE?

image

@kunalspathak
Copy link
Member

another windows/x64 improvement - dotnet/perf-autofiling-issues#1934

@ghost ghost locked as resolved and limited conversation to collaborators Nov 18, 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants