Skip to content

Conversation

@AndyAyersMS
Copy link
Member

Move the redundant branch elimination out of assertion prop into its
own phase, in anticipation of future enhancements. Run it a bit earlier
(before CSE).

Move the redundant branch elimination out of assertion prop into its
own phase, in anticipation of future enhancements. Run it a bit earlier
(before CSE).
@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 Dec 19, 2020
@AndyAyersMS
Copy link
Member Author

This is the same algorithm as before, just run earlier.

cc @dotnet/jit-contrib

There are diffs. Regressions are typically additional CSEs so hopefully come with a small perf win.

Total bytes of base: 50418452
Total bytes of diff: 50416948
Total bytes of delta: -1504 (-0.00% of base)
    diff is an improvement.

Top file regressions (bytes):
         160 : System.Collections.Concurrent.dasm (0.05% of base)
         136 : System.Text.Json.dasm (0.02% of base)
          55 : System.Collections.dasm (0.01% of base)
          36 : System.ComponentModel.TypeConverter.dasm (0.01% of base)
          28 : System.CodeDom.dasm (0.01% of base)
          22 : System.Drawing.Common.dasm (0.01% of base)
          12 : System.Net.Connections.dasm (0.04% of base)
          12 : System.IO.Pipelines.dasm (0.02% of base)
          11 : System.Private.CoreLib.dasm (0.00% of base)
           6 : System.Configuration.ConfigurationManager.dasm (0.00% of base)
           4 : System.Data.OleDb.dasm (0.00% of base)
           4 : System.Security.Cryptography.Cng.dasm (0.00% of base)
           3 : System.IO.Packaging.dasm (0.00% of base)
           3 : System.IO.FileSystem.AccessControl.dasm (0.01% of base)
           2 : System.Net.Mail.dasm (0.00% of base)
           2 : System.Security.Cryptography.Pkcs.dasm (0.00% of base)

Top file improvements (bytes):
        -720 : FSharp.Core.dasm (-0.02% of base)
        -634 : System.Private.DataContractSerialization.dasm (-0.08% of base)
        -226 : System.Data.Common.dasm (-0.02% of base)
         -51 : xunit.runner.reporters.netcoreapp10.dasm (-0.10% of base)
         -49 : Microsoft.CodeAnalysis.CSharp.dasm (-0.00% of base)
         -37 : System.Diagnostics.PerformanceCounter.dasm (-0.05% of base)
         -36 : System.Private.Xml.dasm (-0.00% of base)
         -34 : Newtonsoft.Json.dasm (-0.00% of base)
         -33 : CommandLine.dasm (-0.01% of base)
         -18 : Microsoft.Diagnostics.Tracing.TraceEvent.dasm (-0.00% of base)
         -16 : System.Formats.Asn1.dasm (-0.02% of base)
         -15 : xunit.assert.dasm (-0.01% of base)
         -15 : xunit.core.dasm (-0.02% of base)
         -15 : xunit.execution.dotnet.dasm (-0.01% of base)
         -11 : System.DirectoryServices.dasm (-0.00% of base)
         -11 : System.Data.Odbc.dasm (-0.01% of base)
         -10 : System.DirectoryServices.AccountManagement.dasm (-0.00% of base)
         -10 : Microsoft.VisualBasic.Core.dasm (-0.00% of base)
          -8 : System.Net.Http.dasm (-0.00% of base)
          -8 : System.Runtime.Serialization.Formatters.dasm (-0.01% of base)

49 total files with Code Size differences (33 improved, 16 regressed), 220 unchanged.

Top method regressions (bytes):
          55 ( 1.43% of base) : System.Collections.dasm - SortedList`2:System.Collections.IDictionary.Add(Object,Object):this (7 methods)
          54 ( 2.71% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.set_Item(Object,Object):this (7 methods)
          48 ( 2.35% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.Add(Object,Object):this (7 methods)
          43 ( 3.25% of base) : FSharp.Core.dasm - HashCompare:GenericEqualityObj(bool,IEqualityComparer,Object,Object):bool
          23 ( 3.73% of base) : System.ComponentModel.TypeConverter.dasm - RectangleConverter:CreateInstance(ITypeDescriptorContext,IDictionary):Object:this
          22 ( 1.98% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.get_Item(Object):Object:this (7 methods)
          21 ( 1.72% of base) : System.Private.CoreLib.dasm - ValueTuple`1:System.Collections.IStructuralEquatable.Equals(Object,IEqualityComparer):bool:this (7 methods)
          21 ( 1.08% of base) : System.Private.CoreLib.dasm - ValueTuple`2:System.Collections.IStructuralEquatable.Equals(Object,IEqualityComparer):bool:this (7 methods)
          19 ( 3.01% of base) : System.Drawing.Common.dasm - MarginsConverter:CreateInstance(ITypeDescriptorContext,IDictionary):Object:this
          18 ( 2.00% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.Contains(Object):bool:this (7 methods)
          18 ( 2.22% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.Remove(Object):this (7 methods)
          18 ( 1.19% of base) : System.Private.CoreLib.dasm - EqualityComparer`1:System.Collections.IEqualityComparer.Equals(Object,Object):bool:this (7 methods)
          13 ( 0.58% of base) : System.Text.Json.dasm - Utf8JsonReader:UnescapeSequenceAndCompare(ReadOnlySpan`1):bool:this
          12 ( 0.53% of base) : System.Net.Connections.dasm - <ReadAsync>d__20:MoveNext():this
          12 ( 0.64% of base) : Newtonsoft.Json.dasm - JsonWriter:WriteToken(int,Object):this
          12 ( 0.63% of base) : Newtonsoft.Json.dasm - JsonWriter:WriteTokenAsync(int,Object,CancellationToken):Task:this
          12 ( 3.14% of base) : System.ComponentModel.TypeConverter.dasm - PointConverter:CreateInstance(ITypeDescriptorContext,IDictionary):Object:this
          12 ( 3.14% of base) : System.ComponentModel.TypeConverter.dasm - SizeConverter:CreateInstance(ITypeDescriptorContext,IDictionary):Object:this
          12 ( 0.56% of base) : System.IO.Pipelines.dasm - <ReadAsyncInternal>d__27:MoveNext():this
          12 ( 0.33% of base) : System.Text.Json.dasm - JsonDocument:TryParseValue(byref,byref,bool,bool):bool

Top method improvements (bytes):
        -317 (-25.50% of base) : System.Private.DataContractSerialization.dasm - XmlBaseWriter:WritePrimitiveValue(Object):this
        -317 (-24.90% of base) : System.Private.DataContractSerialization.dasm - XmlJsonWriter:WritePrimitiveValue(Object):this
         -68 (-8.76% of base) : System.Private.CoreLib.dasm - DynamicResolver:ResolveToken(int,byref,byref,byref):this
         -55 (-8.10% of base) : Newtonsoft.Json.dasm - JValue:GetValueType(Nullable`1,Object):int
         -51 (-6.48% of base) : xunit.runner.reporters.netcoreapp10.dasm - JsonExtentions:AddValue(StringBuilder,String,Object)
         -40 (-6.58% of base) : System.Data.Common.dasm - XPathNodePointer:MoveToPreviousSibling():bool:this
         -37 (-2.61% of base) : System.Diagnostics.PerformanceCounter.dasm - PerformanceCounterLib:FindCustomCategory(String,byref):bool:this
         -33 (-14.41% of base) : CommandLine.dasm - UnParserExtensions:IsEmpty(Object):bool
         -33 (-4.67% of base) : Microsoft.CodeAnalysis.CSharp.dasm - SyntaxNormalizer:GetDeclarationDepth(SyntaxNode):int
         -31 (-7.28% of base) : System.Private.Xml.dasm - Processor:GetGlobalParameter(XmlQualifiedName):Object:this
         -27 (-5.38% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkEqualsQmark(Nullable`1,Nullable`1):bool (6 methods)
         -27 (-31.76% of base) : System.Data.Common.dasm - DataPointer:IsFoliated(XmlNode):bool
         -25 (-7.06% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkGreaterEqualsQmark(Nullable`1,Nullable`1):bool (6 methods)
         -25 (-7.06% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkGreaterQmark(Nullable`1,Nullable`1):bool (6 methods)
         -25 (-7.06% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkLessEqualsQmark(Nullable`1,Nullable`1):bool (6 methods)
         -25 (-7.06% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkLessQmark(Nullable`1,Nullable`1):bool (6 methods)
         -20 (-26.67% of base) : System.Data.Common.dasm - XPathNodePointer:IsFoliated(XmlNode):bool:this
         -20 (-2.65% of base) : System.Data.Common.dasm - Select:GetLinearFilteredRecords(Range):ref:this
         -19 (-19.79% of base) : System.ComponentModel.TypeConverter.dasm - HelpKeywordAttribute:Equals(Object):bool:this
         -18 (-1.03% of base) : Microsoft.CodeAnalysis.CSharp.dasm - ConversionsBase:UniqueIndex(ImmutableArray`1,Func`2):BestIndex (7 methods)

Top method regressions (percentages):
           7 ( 4.67% of base) : System.CodeDom.dasm - VBCodeGenerator:get_IsCurrentModule():bool:this
          23 ( 3.73% of base) : System.ComponentModel.TypeConverter.dasm - RectangleConverter:CreateInstance(ITypeDescriptorContext,IDictionary):Object:this
           7 ( 3.26% of base) : System.Private.CoreLib.dasm - Double:CompareTo(Object):int:this
           7 ( 3.26% of base) : System.Private.CoreLib.dasm - Single:CompareTo(Object):int:this
          43 ( 3.25% of base) : FSharp.Core.dasm - HashCompare:GenericEqualityObj(bool,IEqualityComparer,Object,Object):bool
           6 ( 3.17% of base) : System.Security.Cryptography.Cng.dasm - CngKey:SetProperty(CngProperty):this
          12 ( 3.14% of base) : System.ComponentModel.TypeConverter.dasm - PointConverter:CreateInstance(ITypeDescriptorContext,IDictionary):Object:this
          12 ( 3.14% of base) : System.ComponentModel.TypeConverter.dasm - SizeConverter:CreateInstance(ITypeDescriptorContext,IDictionary):Object:this
          19 ( 3.01% of base) : System.Drawing.Common.dasm - MarginsConverter:CreateInstance(ITypeDescriptorContext,IDictionary):Object:this
          11 ( 2.73% of base) : Microsoft.CodeAnalysis.CSharp.dasm - TypeSymbol:IsExplicitlyImplementedViaAccessors(Symbol,TypeSymbol,byref):bool
          54 ( 2.71% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.set_Item(Object,Object):this (7 methods)
           6 ( 2.58% of base) : Microsoft.CodeAnalysis.CSharp.dasm - MemberSemanticModel:GetLambdaParameterSymbol(ParameterSyntax,ExpressionSyntax,CancellationToken):ParameterSymbol:this
          48 ( 2.35% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.Add(Object,Object):this (7 methods)
           3 ( 2.29% of base) : System.CodeDom.dasm - VBCodeGenerator:GetUserData(CodeObject,String,bool):bool:this
           3 ( 2.29% of base) : System.CodeDom.dasm - CSharpCodeGenerator:GetUserData(CodeObject,String,bool):bool:this
           3 ( 2.26% of base) : System.CodeDom.dasm - VBCodeGenerator:AllowLateBound(CodeCompileUnit):bool:this
           3 ( 2.26% of base) : System.CodeDom.dasm - VBCodeGenerator:RequireVariableDeclaration(CodeCompileUnit):bool:this
          18 ( 2.22% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.Remove(Object):this (7 methods)
          18 ( 2.00% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.Contains(Object):bool:this (7 methods)
          22 ( 1.98% of base) : System.Collections.Concurrent.dasm - ConcurrentDictionary`2:System.Collections.IDictionary.get_Item(Object):Object:this (7 methods)

Top method improvements (percentages):
         -27 (-31.76% of base) : System.Data.Common.dasm - DataPointer:IsFoliated(XmlNode):bool
         -20 (-26.67% of base) : System.Data.Common.dasm - XPathNodePointer:IsFoliated(XmlNode):bool:this
        -317 (-25.50% of base) : System.Private.DataContractSerialization.dasm - XmlBaseWriter:WritePrimitiveValue(Object):this
        -317 (-24.90% of base) : System.Private.DataContractSerialization.dasm - XmlJsonWriter:WritePrimitiveValue(Object):this
         -19 (-19.79% of base) : System.ComponentModel.TypeConverter.dasm - HelpKeywordAttribute:Equals(Object):bool:this
         -33 (-14.41% of base) : CommandLine.dasm - UnParserExtensions:IsEmpty(Object):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkGreaterEquals(Nullable`1,long):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkGreater(Nullable`1,long):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkLessEquals(Nullable`1,long):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkLess(Nullable`1,long):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkEquals(Nullable`1,long):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_GreaterEqualsQmark(long,Nullable`1):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_GreaterQmark(long,Nullable`1):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_LessEqualsQmark(long,Nullable`1):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_LessQmark(long,Nullable`1):bool
          -3 (-13.64% of base) : FSharp.Core.dasm - NullableOperators:op_EqualsQmark(long,Nullable`1):bool
          -3 (-11.54% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkGreaterEquals(Nullable`1,double):bool
          -3 (-11.54% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkGreater(Nullable`1,double):bool
          -3 (-11.54% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkLessEquals(Nullable`1,double):bool
          -3 (-11.54% of base) : FSharp.Core.dasm - NullableOperators:op_QmarkLess(Nullable`1,double):bool

315 total methods with Code Size differences (239 improved, 76 regressed), 258514 unchanged.

DoPhase(this, PHASE_VN_COPY_PROP, &Compiler::optVnCopyProp);
}

if (doBranchOpt)
Copy link
Contributor

Choose a reason for hiding this comment

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

Earlier, we would do redundant branch elimination after CSE and now we do it before. Is that the source of diff?

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

Copy link
Contributor

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

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

LGTM, with a question on why we see improvements with this change.

@AndyAyersMS AndyAyersMS merged commit c6d988f into dotnet:master Dec 19, 2020
@AndyAyersMS AndyAyersMS deleted the RedundantBranchOptPhase branch December 19, 2020 16:25
@ghost ghost locked as resolved and limited conversation to collaborators Jan 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