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

JIT: some small improvements to tail duplication #37038

Merged
merged 2 commits into from
May 28, 2020

Conversation

AndyAyersMS
Copy link
Member

  1. Allow duplicating when predecessor is BBJ_NONE
  2. Require that predecessor and successor reference the same local
  3. Make sure that local is not address exposed
  4. Check up to two statements in predecessor for local reference
  5. Require successor to compare local to constant, or local to local

Changes inspired by #36649 but don't actually improve CQ for that case (yet).

1. Allow duplicating when predecessor is BBJ_NONE
2. Require that predecessor and successor reference the same local
3. Make sure that local is not address exposed
4. Check up to two statements in predecessor for local reference
5. Require successor to compare local to constant, or local to local

Changes inspired by dotnet#36649 but don't actually improve CQ for that case (yet).
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 27, 2020
@AndyAyersMS
Copy link
Member Author

@dotnet/jit-contrib PTAL

Jit diffs

PMI CodeSize Diffs for System.Private.CoreLib.dll, framework assemblies for x64 default jit
Summary of Code Size diffs:
(Lower is better)
Total bytes of diff: -29953 (-0.06% of base)
    diff is an improvement.
Top file regressions (bytes):
          33 : System.Diagnostics.EventLog.dasm (0.04% of base)
          32 : System.IO.FileSystem.dasm (0.03% of base)
          27 : System.Composition.Convention.dasm (0.03% of base)
          19 : Newtonsoft.Json.Bson.dasm (0.02% of base)
           8 : Microsoft.Win32.Registry.dasm (0.04% of base)
           7 : System.Text.Encodings.Web.dasm (0.02% of base)
           6 : Microsoft.Extensions.Logging.EventLog.dasm (0.05% of base)
           6 : System.Private.Uri.dasm (0.01% of base)
           4 : Microsoft.Extensions.DependencyInjection.Abstractions.dasm (0.01% of base)
           2 : Microsoft.Extensions.Logging.TraceSource.dasm (0.04% of base)
           2 : System.Diagnostics.TextWriterTraceListener.dasm (0.02% of base)
           2 : System.IO.Pipes.dasm (0.00% of base)
Top file improvements (bytes):
       -5545 : Microsoft.CodeAnalysis.VisualBasic.dasm (-0.10% of base)
       -4218 : System.Text.Json.dasm (-0.56% of base)
       -2816 : Microsoft.CodeAnalysis.CSharp.dasm (-0.06% of base)
       -2258 : System.Private.CoreLib.dasm (-0.05% of base)
       -1959 : Microsoft.VisualBasic.Core.dasm (-0.41% of base)
       -1824 : System.Data.Common.dasm (-0.12% of base)
       -1099 : Newtonsoft.Json.dasm (-0.13% of base)
       -1014 : System.Private.Xml.dasm (-0.03% of base)
        -781 : System.Private.DataContractSerialization.dasm (-0.10% of base)
        -656 : System.Numerics.Tensors.dasm (-0.27% of base)
        -467 : Microsoft.CSharp.dasm (-0.12% of base)
        -463 : System.Collections.Concurrent.dasm (-0.14% of base)
        -379 : Microsoft.CodeAnalysis.dasm (-0.02% of base)
        -352 : System.Security.Cryptography.Pkcs.dasm (-0.08% of base)
        -338 : System.Linq.dasm (-0.03% of base)
        -302 : System.Collections.dasm (-0.05% of base)
        -283 : System.ComponentModel.TypeConverter.dasm (-0.10% of base)
        -278 : System.Threading.Tasks.Dataflow.dasm (-0.03% of base)
        -272 : System.Linq.Expressions.dasm (-0.03% of base)
        -210 : System.Configuration.ConfigurationManager.dasm (-0.06% of base)
122 total files with Code Size differences (110 improved, 12 regressed), 144 unchanged.
Top method regressions (bytes):
         157 ( 2.99% of base) : System.Private.CoreLib.dasm - CustomAttributeBuilder:InitCustomAttributeBuilder(ConstructorInfo,ref,ref,ref,ref,ref):this
         150 ( 3.84% of base) : Microsoft.CodeAnalysis.CSharp.dasm - ConstraintsHelper:ResolveBounds(TypeParameterSymbol,AssemblySymbol,ConsList`1,ImmutableArray`1,bool,CSharpCompilation,ArrayBuilder`1,byref):TypeParameterBounds
         121 ( 8.25% of base) : Microsoft.CodeAnalysis.CSharp.dasm - SourceAttributeData:GetTargetAttributeSignatureIndex(Symbol,AttributeDescription):int:this
         117 ( 4.35% of base) : System.Private.Uri.dasm - UriHelper:UnescapeString(long,int,int,byref,ushort,ushort,ushort,int,UriParser,bool)
         114 ( 6.20% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - ImportsBinder:BindMembersImportsClause(SimpleImportsClauseSyntax,Binder,ImportData,DiagnosticBag)
         109 ( 4.04% of base) : System.Private.Xml.dasm - XmlSerializationWriter:WriteTypedPrimitive(String,String,Object,bool):this
         107 ( 7.16% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - SourceAttributeData:GetTargetAttributeSignatureIndex(Symbol,AttributeDescription):int:this
         100 ( 1.48% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - Binder:ReportOverloadResolutionFailureAndProduceBoundNode(VisualBasicSyntaxNode,int,ArrayBuilder`1,ImmutableArray`1,TypeSymbol,ImmutableArray`1,ImmutableArray`1,DiagnosticBag,VisualBasicSyntaxNode,BoundMethodOrPropertyGroup,Symbol,bool,BoundTypeExpression,Symbol,Location):BoundExpression:this
          60 (10.60% of base) : System.Data.Odbc.dasm - OdbcDataReader:GetData(int,short,int,byref):bool:this
          59 ( 1.88% of base) : System.Configuration.ConfigurationManager.dasm - MgmtConfigurationRecord:CopyConfigDefinitionsRecursive(ConfigDefinitionUpdates,XmlUtil,XmlUtilWriter,bool,LocationUpdates,SectionUpdates,bool,String,int,int):bool:this
          55 ( 0.77% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - Binder:BindAwait(VisualBasicSyntaxNode,BoundExpression,DiagnosticBag,bool):BoundExpression:this
          51 ( 1.91% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Binder:AnalyzeAnonymousFunction(CSharpSyntaxNode,DiagnosticBag):Tuple`4:this
          45 ( 1.19% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - Binder:BindXmlContainerRewriterInfo(XmlNodeSyntax,BoundExpression,ImmutableArray`1,XmlElementRootInfo,DiagnosticBag):BoundXmlContainerRewriterInfo:this
          44 ( 1.89% of base) : System.Security.Cryptography.Pkcs.dasm - ManagedPkcsPal:Decode(ref,byref,byref,byref,byref,byref):DecryptorPal:this
          43 ( 1.55% of base) : Microsoft.VisualBasic.Core.dasm - LateBinding:InternalLateSet(Object,byref,String,ref,ref,bool,int)
          40 ( 3.76% of base) : System.IO.FileSystem.dasm - FileSystemEnumerableFactory:NormalizeInputs(byref,byref,int):bool
          37 ( 2.26% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - ExpressionLambdaRewriter:GetConversionHelperMethod(byte,byte):MethodSymbol:this
          37 ( 3.39% of base) : System.ComponentModel.TypeConverter.dasm - TypeDescriptor:Refresh(Object,bool)
          37 ( 1.49% of base) : System.Reflection.MetadataLoadContext.dasm - DefaultBinder:SelectMethod(int,ref,ref,ref):MethodBase:this
          35 ( 0.95% of base) : Microsoft.CodeAnalysis.CSharp.dasm - SourcePropertySymbol:.ctor(SourceMemberContainerTypeSymbol,Binder,BasePropertyDeclarationSyntax,String,Location,DiagnosticBag):this
Top method improvements (bytes):
       -1050 (-1.73% of base) : System.Text.Json.dasm - ObjectWithParameterizedConstructorConverter`1:OnTryRead(byref,Type,JsonSerializerOptions,byref,byref):bool:this (7 methods)
        -847 (-1.61% of base) : System.Text.Json.dasm - ObjectWithParameterizedConstructorConverter`1:ReadConstructorArgumentsWithContinuation(byref,byref,JsonSerializerOptions):bool:this (7 methods)
        -826 (-1.62% of base) : System.Text.Json.dasm - ObjectWithParameterizedConstructorConverter`1:ReadConstructorArguments(byref,byref,JsonSerializerOptions):this (7 methods)
        -707 (-2.04% of base) : System.Data.Common.dasm - SortExpressionBuilder`1:CloneCast():SortExpressionBuilder`1:this (49 methods)
        -602 (-1.13% of base) : System.Text.Json.dasm - ObjectDefaultConverter`1:OnTryRead(byref,Type,JsonSerializerOptions,byref,byref):bool:this (7 methods)
        -392 (-2.59% of base) : System.Text.Json.dasm - ObjectWithParameterizedConstructorConverter`1:TryLookupConstructorParameter(byref,byref,JsonSerializerOptions,byref):bool:this (7 methods)
        -214 (-3.02% of base) : System.Numerics.Tensors.dasm - Tensor`1:CompareTo(Array,IComparer):int:this (7 methods)
        -204 (-2.53% of base) : System.Numerics.Tensors.dasm - CompressedSparseTensor`1:Reshape(ReadOnlySpan`1):Tensor`1:this (7 methods)
        -188 (-5.13% of base) : System.Security.Cryptography.Pkcs.dasm - AsnValueReader:ParseGeneralizedTime(int,ReadOnlySpan`1,bool):DateTimeOffset
        -173 (-6.22% of base) : Newtonsoft.Json.dasm - JValue:Compare(int,Object,Object):int
        -145 (-3.63% of base) : System.ServiceProcess.ServiceController.dasm - ServiceController:GetServices(String,int,String,Func`2):ref (7 methods)
        -140 (-5.06% of base) : System.Linq.dasm - EnumerableSorter`2:QuickSelect(ref,int,int):int:this (7 methods)
        -138 (-3.63% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - Binder:BindUnboundLambda(UnboundLambda,TargetSignature):BoundLambda:this
        -134 (-10.45% of base) : System.Data.Common.dasm - ForeignKeyConstraint:CascadeDelete(DataRow):this
        -134 (-16.30% of base) : System.Data.Common.dasm - ForeignKeyConstraint:CascadeRollback(DataRow):this
        -130 (-16.07% of base) : Newtonsoft.Json.dasm - JValue:GetValueType(Nullable`1,Object):int
        -130 (-0.35% of base) : System.Data.Common.dasm - RBTree`1:RBDeleteX(int,int,int):int:this (7 methods)
        -122 (-3.12% of base) : System.Data.Common.dasm - SortExpressionBuilder`1:Clone():SortExpressionBuilder`1:this (7 methods)
        -114 (-5.41% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.set_Item(Object,Object):this (7 methods)
        -112 (-1.06% of base) : System.Threading.Channels.dasm - UnboundedChannelReader:ReadAsync(CancellationToken):ValueTask`1:this (14 methods)
Top method regressions (percentages):
          60 (10.60% of base) : System.Data.Odbc.dasm - OdbcDataReader:GetData(int,short,int,byref):bool:this
         121 ( 8.25% of base) : Microsoft.CodeAnalysis.CSharp.dasm - SourceAttributeData:GetTargetAttributeSignatureIndex(Symbol,AttributeDescription):int:this
           6 ( 7.89% of base) : Microsoft.CodeAnalysis.CSharp.dasm - VariableIdentifier:Equals(VariableIdentifier):bool:this
         107 ( 7.16% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - SourceAttributeData:GetTargetAttributeSignatureIndex(Symbol,AttributeDescription):int:this
         114 ( 6.20% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - ImportsBinder:BindMembersImportsClause(SimpleImportsClauseSyntax,Binder,ImportData,DiagnosticBag)
          35 ( 5.41% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - TraceEventSession:CaptureState(Guid,long,int,Object):this
          34 ( 5.27% of base) : System.Diagnostics.EventLog.dasm - EventLogEntry:ReplaceMessageParameters(String,ref):String:this
           3 ( 4.55% of base) : System.Data.Common.dasm - DataColumnMappingCollection:RangeCheck(int):this
           3 ( 4.55% of base) : System.Data.Common.dasm - DataTableMappingCollection:RangeCheck(int):this
           3 ( 4.55% of base) : System.Data.Odbc.dasm - OdbcParameterCollection:RangeCheck(int):this
           3 ( 4.55% of base) : System.Data.OleDb.dasm - OleDbParameterCollection:RangeCheck(int):this
          30 ( 4.46% of base) : System.ComponentModel.TypeConverter.dasm - TypeDescriptor:Refresh(Type)
           6 ( 4.41% of base) : System.Composition.Runtime.dasm - CompositionContract:Equals(Object):bool:this
         117 ( 4.35% of base) : System.Private.Uri.dasm - UriHelper:UnescapeString(long,int,int,byref,ushort,ushort,ushort,int,UriParser,bool)
           6 ( 4.26% of base) : Microsoft.CodeAnalysis.dasm - SemanticEdit:Equals(SemanticEdit):bool:this
           4 ( 4.26% of base) : System.Configuration.ConfigurationManager.dasm - BaseConfigurationRecord:GetSectionRecord(String,bool):SectionRecord:this
           6 ( 4.23% of base) : Microsoft.CodeAnalysis.CSharp.dasm - TypeWithModifiers:Equals(TypeWithModifiers,bool):bool:this
         109 ( 4.04% of base) : System.Private.Xml.dasm - XmlSerializationWriter:WriteTypedPrimitive(String,String,Object,bool):this
          12 ( 4.00% of base) : System.Text.RegularExpressions.dasm - RegexCharClass:CharInClassRecursive(ushort,String,int):bool (2 methods)
          35 ( 4.00% of base) : System.IO.FileSystem.dasm - DirectoryInfo:CreateSubdirectory(String):DirectoryInfo:this
Top method improvements (percentages):
          -7 (-17.07% of base) : Microsoft.VisualBasic.Core.dasm - Information:IsDBNull(Object):bool
         -85 (-16.63% of base) : System.Private.Xml.dasm - Processor:GetGlobalParameter(XmlQualifiedName):Object:this
         -49 (-16.39% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:ThrowIfInvalidObjectValue(Object) (7 methods)
        -134 (-16.30% of base) : System.Data.Common.dasm - ForeignKeyConstraint:CascadeRollback(DataRow):this
        -130 (-16.07% of base) : Newtonsoft.Json.dasm - JValue:GetValueType(Nullable`1,Object):int
         -28 (-15.22% of base) : Microsoft.VisualBasic.Core.dasm - LateBinding:GetPropertyPutFlags(Object):int
         -38 (-14.18% of base) : System.Configuration.ConfigurationManager.dasm - OverrideModeSetting:get_LocationTagXmlString():String:this
         -14 (-13.59% of base) : Microsoft.CodeAnalysis.CSharp.dasm - SyntaxNodeCache:CanBeCached(GreenNode,GreenNode,GreenNode):bool
         -14 (-13.59% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - SyntaxNodeCache:CanBeCached(GreenNode,GreenNode,GreenNode):bool
         -62 (-13.30% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - SourceMemberContainerTypeSymbol:ComputeTypeFlags(MergedTypeDeclaration,bool):ushort:this
          -7 (-11.67% of base) : Microsoft.CodeAnalysis.CSharp.dasm - SyntaxNormalizer:IsKeyword(ushort):bool
        -134 (-10.45% of base) : System.Data.Common.dasm - ForeignKeyConstraint:CascadeDelete(DataRow):this
         -46 (-10.27% of base) : Newtonsoft.Json.dasm - MiscellaneousUtils:ValueEquals(Object,Object):bool
          -7 (-10.14% of base) : Microsoft.CodeAnalysis.CSharp.dasm - SyntaxNodeCache:CanBeCached(GreenNode,GreenNode):bool
          -7 (-10.14% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - SyntaxNodeCache:CanBeCached(GreenNode,GreenNode):bool
          -9 (-10.11% of base) : System.Data.Common.dasm - XmlDataDocument:Foliate(XmlElement):this
          -9 (-10.11% of base) : System.Data.Common.dasm - XmlDataDocument:IsFoliated(XmlElement):bool:this
         -17 (-10.06% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - PENamedTypeSymbol:get_MightContainExtensionMethods():bool:this
         -13 (-9.92% of base) : System.Private.CoreLib.dasm - FastResourceComparer:CompareOrdinal(long,int,String):int
         -13 (-9.92% of base) : System.Resources.Extensions.dasm - FastResourceComparer:CompareOrdinal(long,int,String):int
3349 total methods with Code Size differences (2936 improved, 413 regressed), 241558 unchanged.

@AndyAyersMS
Copy link
Member Author

Will add some notes on regressions/improvements in a bit.

@AndyAyersMS
Copy link
Member Author

Regression in OdbcDataReader:GetData: this opt works as expected, leads to big change in block layout and different RA with more prolog/epolog saves/restores.

Regressions in VariableIdentifier:Equals and SourceAttributeData:GetTargetAttributeSignatureIndex: source block has relop on RHS which does not lead to an optimization:

BB03 (jump always to BB04)
[000011] -A--G-------              *  ASG       int   
[000010] D------N----              +--*  LCL_VAR   int    V03 tmp1         
[000009] ----G-------              \--*  EQ        int   
[000007] ------------                 +--*  LCL_VAR   ref    V06 tmp4         
[000008] ------------                 \--*  CNS_INT   ref    null

BB04
[000016] ------------              *  JTRUE     void  
[000015] ------------              \--*  EQ        int   
[000013] ------------                 +--*  LCL_VAR   int    V03 tmp1         
[000014] ------------                 \--*  CNS_INT   int    0

Tried disabling relops generally in the predecessor block screening, but that didn't pan out.

Regression in EventLogEntry:ReplaceMessageParameters(String,ref):String:this: we no longer clone a block, this modifies weights, which alters RA spill pattern.

@AndyAyersMS
Copy link
Member Author

randomly chosen improvement:

;; Assembly listing for method SyntaxNodeCache:CanBeCached(GreenNode,GreenNode):bool

;;
;; before
;;

G_M18879_IG02:
       test     rcx, rcx
       je       SHORT G_M18879_IG04

G_M18879_IG03:
       call     GreenNode:get_IsCacheable():bool:this
       movzx    rcx, al
       jmp      SHORT G_M18879_IG05

G_M18879_IG04:
       mov      ecx, 1

G_M18879_IG05:
       test     ecx, ecx
       je       SHORT G_M18879_IG10

G_M18879_IG06:
       test     rsi, rsi
       je       SHORT G_M18879_IG08
       mov      rcx, rs

;;
;; after
;;

G_M18879_IG02:
       test     rcx, rcx
       je       SHORT G_M18879_IG04

G_M18879_IG03:
       call     GreenNode:get_IsCacheable():bool:this
       movzx    rcx, al
       test     ecx, ecx
       je       SHORT G_M18879_IG08

G_M18879_IG04:
       test     rsi, rsi
       je       SHORT G_M18879_IG06
       mov      rcx, rsi

Copy link
Contributor

@CarolEidt CarolEidt left a comment

Choose a reason for hiding this comment

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

LGTM, but a few additional comments would be nice.


Statement* const prevStmt = stmt->GetPrevStmt();

if (prevStmt == lastStmt)
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be worth a comment here that GetPrevStmt() of the fist stmt returns the last stmt. I had forgotten and was initially confused.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this confuses me at times too. I suppose it saves a pointer in BasicBlock but it makes reverse iteration through statements a bit clunky.

Seems like we could have GetPrevStmt() return null for the first statement, and then have BasicBlock::LastStatement() call some other API or have friend access to the underlying field.

// returns:
// true if this block seems like a good candidate for duplication
// true if this is a good candidate, false otherwise
// if true, lclNum is set to lcl to scan for in predecessor block
Copy link
Contributor

Choose a reason for hiding this comment

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

This could use a little elaboration, e.g. explaining that good tail call duplication is predicted when we have an assignment to 'lcl' in the predecessor block that can provide information enabling optimization of a compare involving 'lcl' in the successor block, or something to that effect. There's a partial explanation in the above function, but it only tells half the story.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added some comments, see if this is better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent thanks!

@AndyAyersMS
Copy link
Member Author

For future reference, if we compare enabling vs disabling this optimization entirely (including the changes above, this is the net impact of FX

Total bytes of diff: -85917 (-0.18% of base)
    diff is an improvement.

Top file regressions (bytes):
         189 : System.Threading.Tasks.Parallel.dasm (0.12% of base)
          95 : System.DirectoryServices.Protocols.dasm (0.11% of base)
          63 : System.ServiceProcess.ServiceController.dasm (0.23% of base)
          60 : System.Linq.dasm (0.01% of base)
          55 : System.Runtime.Numerics.dasm (0.08% of base)
          28 : Microsoft.Diagnostics.FastSerialization.dasm (0.03% of base)
          15 : System.Threading.dasm (0.09% of base)
          10 : Microsoft.Extensions.Primitives.dasm (0.04% of base)
           7 : System.IO.Compression.Brotli.dasm (0.04% of base)

Top file improvements (bytes):
      -14798 : System.Private.CoreLib.dasm (-0.32% of base)
       -7051 : Microsoft.CodeAnalysis.CSharp.dasm (-0.16% of base)
       -5789 : Microsoft.CodeAnalysis.VisualBasic.dasm (-0.10% of base)
       -3893 : System.Data.Common.dasm (-0.26% of base)
       -3393 : System.Private.DataContractSerialization.dasm (-0.44% of base)
       -3299 : System.Private.Xml.dasm (-0.09% of base)
       -3204 : System.Text.Json.dasm (-0.42% of base)
       -2777 : Microsoft.CodeAnalysis.dasm (-0.16% of base)
       -2689 : System.Configuration.ConfigurationManager.dasm (-0.77% of base)
       -2334 : System.Linq.Parallel.dasm (-0.14% of base)
       -2327 : System.Linq.Expressions.dasm (-0.30% of base)
       -2133 : Newtonsoft.Json.dasm (-0.24% of base)
       -1608 : System.Net.Http.dasm (-0.22% of base)
       -1411 : Microsoft.Diagnostics.Tracing.TraceEvent.dasm (-0.05% of base)
       -1369 : System.ComponentModel.TypeConverter.dasm (-0.50% of base)
       -1272 : System.ComponentModel.Composition.dasm (-0.38% of base)
       -1160 : System.Threading.Tasks.Dataflow.dasm (-0.14% of base)
        -904 : System.Security.Cryptography.Algorithms.dasm (-0.26% of base)
        -862 : System.Reflection.MetadataLoadContext.dasm (-0.47% of base)
        -857 : Microsoft.CSharp.dasm (-0.22% of base)

160 total files with Code Size differences (151 improved, 9 regressed), 106 unchanged.

Top method regressions (bytes):
         266 (11.85% of base) : System.Collections.Immutable.dasm - Node:RemoveAt(int):Node:this (7 methods)
         253 ( 8.39% of base) : System.Private.DataContractSerialization.dasm - ReflectionJsonReader:ReadSimpleDictionary(XmlReaderDelegator,XmlObjectSerializerReadContext,CollectionDataContract,Type,Object):this
         252 ( 0.50% of base) : System.Text.Json.dasm - ObjectWithParameterizedConstructorConverter`1:ReadConstructorArguments(byref,byref,JsonSerializerOptions):this (7 methods)
         214 ( 3.11% of base) : System.Numerics.Tensors.dasm - Tensor`1:CompareTo(Array,IComparer):int:this (7 methods)
         204 ( 2.60% of base) : System.Numerics.Tensors.dasm - CompressedSparseTensor`1:Reshape(ReadOnlySpan`1):Tensor`1:this (7 methods)
         201 ( 1.37% of base) : System.Data.Common.dasm - XmlTreeGen:HandleTable(DataTable,XmlDocument,XmlElement,bool):XmlElement:this
         186 ( 5.34% of base) : System.Security.Cryptography.Pkcs.dasm - AsnValueReader:ParseGeneralizedTime(int,ReadOnlySpan`1,bool):DateTimeOffset
         176 ( 3.09% of base) : System.Collections.Immutable.dasm - Enumerator:.ctor(Node,Builder,int,int,bool):this (7 methods)
         167 ( 1.81% of base) : System.Collections.dasm - SortedSet`1:UnionWith(IEnumerable`1):this (7 methods)
         159 ( 4.44% of base) : Microsoft.CodeAnalysis.CSharp.dasm - SourceMemberContainerTypeSymbol:ComputeInterfaceImplementations(DiagnosticBag,CancellationToken):ImmutableArray`1:this
         152 ( 2.25% of base) : System.Collections.dasm - SortedSet`1:IntersectWith(IEnumerable`1):this (7 methods)
         145 ( 3.77% of base) : System.ServiceProcess.ServiceController.dasm - ServiceController:GetServices(String,int,String,Func`2):ref (7 methods)
         130 ( 0.35% of base) : System.Data.Common.dasm - RBTree`1:RBDeleteX(int,int,int):int:this (7 methods)
         118 ( 1.31% of base) : System.Threading.Tasks.Parallel.dasm - <>c__DisplayClass20_0`1:<ForWorker64>b__1(byref,int,byref):this (7 methods)
         104 ( 2.26% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - ExpressionEvaluator:PerformCompileTimeBinaryOperation(ushort,byte,CConst,CConst,ExpressionSyntax):CConst
         104 ( 2.68% of base) : System.Linq.Parallel.dasm - ReverseQueryOperatorEnumerator`1:MoveNext(byref,byref):bool:this (7 methods)
         102 ( 2.45% of base) : Microsoft.CodeAnalysis.dasm - AnalyzerDriver`1:ComputeDeclarationAnalysisData(ISymbol,SyntaxReference,SemanticModel,bool,AnalysisScope,CancellationToken):DeclarationAnalysisData:this (6 methods)
          98 ( 6.49% of base) : Microsoft.VisualBasic.Core.dasm - StringType:StrLikeBinary(String,String):bool
          97 ( 1.37% of base) : System.Linq.Parallel.dasm - OrderedExceptQueryOperatorEnumerator`1:MoveNext(byref,byref):bool:this (7 methods)
          93 ( 4.84% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - SourceMemberContainerTypeSymbol:ProcessPartialMethodsIfAny(Dictionary`2,DiagnosticBag):this

Top method improvements (bytes):
       -1549 (-4.27% of base) : System.Data.Common.dasm - SortExpressionBuilder`1:CloneCast():SortExpressionBuilder`1:this (49 methods)
        -833 (-1.56% of base) : System.Text.Json.dasm - ObjectWithParameterizedConstructorConverter`1:ReadConstructorArgumentsWithContinuation(byref,byref,JsonSerializerOptions):bool:this (7 methods)
        -763 (-23.75% of base) : System.Numerics.Tensors.dasm - Tensor`1:.ctor(Array,bool):this (7 methods)
        -693 (-1.13% of base) : System.Text.Json.dasm - ObjectWithParameterizedConstructorConverter`1:OnTryRead(byref,Type,JsonSerializerOptions,byref,byref):bool:this (7 methods)
        -550 (-1.02% of base) : System.Text.Json.dasm - ObjectDefaultConverter`1:OnTryRead(byref,Type,JsonSerializerOptions,byref,byref):bool:this (7 methods)
        -367 (-15.84% of base) : System.Private.CoreLib.dasm - SpanHelpers:IndexOfAny(byref,double,double,double,int):int
        -333 (-8.17% of base) : System.Collections.Concurrent.dasm - ConcurrentStack`1:TryPopCore(int,byref):int:this (7 methods)
        -318 (-6.55% of base) : Microsoft.CodeAnalysis.CSharp.dasm - LocalRewriter:MakeBinaryOperator(BoundBinaryOperator,CSharpSyntaxNode,int,BoundExpression,BoundExpression,TypeSymbol,MethodSymbol,bool,bool,BoundUnaryOperator):BoundExpression:this
        -312 (-7.38% of base) : System.Data.Common.dasm - SortExpressionBuilder`1:Clone():SortExpressionBuilder`1:this (7 methods)
        -310 (-18.73% of base) : System.Private.CoreLib.dasm - TypedReference:MakeTypedReference(Object,ref):TypedReference
        -287 (-1.86% of base) : System.Text.Json.dasm - ObjectWithParameterizedConstructorConverter`1:TryLookupConstructorParameter(byref,byref,JsonSerializerOptions,byref):bool:this (7 methods)
        -285 (-13.72% of base) : System.Private.CoreLib.dasm - SpanHelpers:LastIndexOfAny(byref,double,double,double,int):int
        -273 (-7.82% of base) : System.Text.Json.dasm - JsonPropertyInfo`1:Initialize(Type,Type,Type,ubyte,PropertyInfo,JsonConverter,Nullable`1,JsonSerializerOptions):this (7 methods)
        -253 (-11.16% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - MemoryProcessMemInfoTraceData:ToXml(StringBuilder):StringBuilder:this
        -250 (-15.75% of base) : System.Private.CoreLib.dasm - GenericArraySortHelper`1:PickPivotAndPartition(Span`1):int (5 methods)
        -224 (-4.20% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - SourceNamedTypeSymbol:CheckDeclarationNameAndTypeParameters(VisualBasicSyntaxNode,Binder,DiagnosticBag,byref):this
        -224 (-1.00% of base) : System.Private.CoreLib.dasm - TaskFactory`1:ContinueWhenAllImpl(ref,Func`2,Action`1,int,CancellationToken,TaskScheduler):Task`1 (56 methods)
        -224 (-0.99% of base) : System.Private.CoreLib.dasm - TaskFactory`1:ContinueWhenAnyImpl(ref,Func`2,Action`1,int,CancellationToken,TaskScheduler):Task`1 (56 methods)
        -215 (-19.78% of base) : System.Collections.Specialized.dasm - NameValueCollection:CopyTo(Array,int):this
        -214 (-4.09% of base) : System.Text.RegularExpressions.dasm - RegexParser:ScanCharClass(bool,bool):RegexCharClass:this (2 methods)

Top method regressions (percentages):
          62 (15.35% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - SourceMemberContainerTypeSymbol:ComputeTypeFlags(MergedTypeDeclaration,bool):ushort:this
         266 (11.85% of base) : System.Collections.Immutable.dasm - Node:RemoveAt(int):Node:this (7 methods)
          13 (11.02% of base) : System.Private.CoreLib.dasm - FastResourceComparer:CompareOrdinal(long,int,String):int
          13 (11.02% of base) : System.Resources.Extensions.dasm - FastResourceComparer:CompareOrdinal(long,int,String):int
          28 ( 9.89% of base) : System.Private.Xml.dasm - XmlILOptimizerVisitor:IsPrimitiveNumeric(XmlQueryType):bool:this
          28 ( 9.89% of base) : System.Private.Xml.dasm - XmlILOptimizerVisitor:MatchesContentTest(XmlQueryType):bool:this
          11 ( 9.73% of base) : System.Private.DataContractSerialization.dasm - XmlCanonicalWriter:Compare(ref,int,int,ref,int,int):int:this
           7 ( 9.59% of base) : Microsoft.VisualBasic.Core.dasm - FastList:GetNodeAtIndex(int,byref):Node:this
          87 ( 9.36% of base) : Microsoft.CodeAnalysis.CSharp.dasm - SourceMemberContainerTypeSymbol:MergeIndexersAndNonIndexers(ImmutableArray`1,ArrayBuilder`1):Dictionary`2:this
          63 ( 9.17% of base) : System.Private.CoreLib.dasm - UTF32Encoding:GetCharCount(long,int,DecoderNLS):int:this
          14 ( 9.03% of base) : System.Private.CoreLib.dasm - ObjectEqualityComparer`1:IndexOf(ref,Vector`1,int,int):int:this
          14 ( 8.92% of base) : System.Private.CoreLib.dasm - ObjectEqualityComparer`1:LastIndexOf(ref,Vector`1,int,int):int:this
          45 ( 8.67% of base) : Microsoft.CodeAnalysis.VisualBasic.dasm - SourceMemberContainerTypeSymbol:GenerateVarianceDiagnosticsForConstraints(ImmutableArray`1,byref,byref):this
          32 ( 8.42% of base) : System.Text.RegularExpressions.dasm - RegexCharClass:CharInCategory(ushort,String,int,int,int):bool
         253 ( 8.39% of base) : System.Private.DataContractSerialization.dasm - ReflectionJsonReader:ReadSimpleDictionary(XmlReaderDelegator,XmlObjectSerializerReadContext,CollectionDataContract,Type,Object):this
          40 ( 8.33% of base) : System.Private.CoreLib.dasm - HebrewNumber:Append(StringBuilder,int)
          24 ( 8.28% of base) : System.Net.WebSockets.dasm - ManagedWebSocket:WriteHeader(ubyte,ref,ReadOnlySpan`1,bool,bool):int
          24 ( 8.28% of base) : System.Net.WebSockets.WebSocketProtocol.dasm - ManagedWebSocket:WriteHeader(ubyte,ref,ReadOnlySpan`1,bool,bool):int
          40 ( 8.23% of base) : Microsoft.CodeAnalysis.CSharp.dasm - Binder:ShouldAddWinRTMembersForInterface(NamedTypeSymbol,NamedTypeSymbol,NamedTypeSymbol,NamedTypeSymbol,NamedTypeSymbol,NamedTypeSymbol,NamedTypeSymbol):bool
          25 ( 8.12% of base) : System.Security.Cryptography.Xml.dasm - Utils:DiscardWhiteSpaces(String,int,int):String

Top method improvements (percentages):
         -41 (-51.25% of base) : Microsoft.CodeAnalysis.dasm - CommandLineParser:IsOption(String):bool
         -13 (-41.94% of base) : System.Private.CoreLib.dasm - PropertyBuilder:get_CanRead():bool:this
         -13 (-41.94% of base) : System.Private.CoreLib.dasm - PropertyBuilder:get_CanWrite():bool:this
         -16 (-40.00% of base) : System.Net.Mail.dasm - BufferBuilder:Append(String):this
         -38 (-39.58% of base) : System.Configuration.ConfigurationManager.dasm - BaseConfigurationRecord:CombineConfigKey(String,String):String
         -38 (-39.58% of base) : System.Configuration.ConfigurationManager.dasm - ConfigPathUtility:Combine(String,String):String
         -13 (-39.39% of base) : System.Web.HttpUtility.dasm - HttpUtility:HtmlDecode(String):String
         -13 (-39.39% of base) : System.Web.HttpUtility.dasm - HttpUtility:HtmlEncode(String):String
         -13 (-39.39% of base) : System.Web.HttpUtility.dasm - HttpEncoder:HtmlDecode(String):String
         -13 (-39.39% of base) : System.Web.HttpUtility.dasm - HttpEncoder:HtmlEncode(String):String
         -13 (-38.24% of base) : System.Private.CoreLib.dasm - Number:FormatUInt32(int,String,IFormatProvider):String
         -13 (-37.14% of base) : System.Data.Common.dasm - Constraint:set_SchemaName(String):this
         -39 (-36.45% of base) : System.Private.Xml.dasm - BigNumber:MakeUpperBound():this
         -13 (-36.11% of base) : System.Private.CoreLib.dasm - UInt32:ToString(String,IFormatProvider):String:this
         -13 (-36.11% of base) : System.Private.CoreLib.dasm - ModuleBuilder:GetType(String,Type):Type
         -13 (-35.14% of base) : System.Configuration.ConfigurationManager.dasm - ConfigurationCollectionAttribute:set_AddItemName(String):this
         -13 (-35.14% of base) : System.Configuration.ConfigurationManager.dasm - ConfigurationCollectionAttribute:set_RemoveItemName(String):this
         -13 (-35.14% of base) : System.Configuration.ConfigurationManager.dasm - ConfigurationCollectionAttribute:set_ClearItemsName(String):this
         -13 (-35.14% of base) : System.Private.CoreLib.dasm - Byte:ToString(String,IFormatProvider):String:this
         -13 (-35.14% of base) : System.Private.CoreLib.dasm - UInt16:ToString(String,IFormatProvider):String:this

6594 total methods with Code Size differences (5570 improved, 1024 regressed), 238313 unchanged.

So roughly speaking, this impacts about 3% of all methods (as enumerated by PMI) and ratio of improvements to regressions is about 5.4.

Also, add morph to post-phase whitelist because it seems odd not
to dump the IR after morph.
@AndyAyersMS AndyAyersMS merged commit 967d216 into dotnet:master May 28, 2020
@AndyAyersMS AndyAyersMS deleted the ExploreTailDup branch May 28, 2020 16:13
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
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.

None yet

3 participants