Skip to content

Run fgValueNumberConstLoad for invariant loads - #86154

Merged
EgorBo merged 6 commits into
dotnet:mainfrom
EgorBo:fold-more-frozen
May 15, 2023
Merged

Run fgValueNumberConstLoad for invariant loads#86154
EgorBo merged 6 commits into
dotnet:mainfrom
EgorBo:fold-more-frozen

Conversation

@EgorBo

@EgorBoEgorBo commented May 12, 2023

Copy link
Copy Markdown
Member

We have a separate path for GTF_IND_INVARIANT where we could miss some optimization opportunites defined in fgValueNumberConstLoad

jit-diff:

Total bytes of base: 58746251
Total bytes of diff: 58741799
Total bytes of delta: -4452 (-0.01 % of base)
Total relative delta: NaN
diff is an improvement.
relative diff is a regression.
Total byte diff includes 103 bytes from reconciling methods
Base had 0 unique methods, 0 unique bytes
Diff had 1 unique methods, 103 unique bytes
Top file regressions (bytes):
103 : Microsoft.CodeAnalysis.dasm (0.01% of base)
Top file improvements (bytes):
-1499 : Newtonsoft.Json.dasm (-0.16% of base)
-624 : xunit.execution.dotnet.dasm (-0.25% of base)
-612 : System.ComponentModel.TypeConverter.dasm (-0.22% of base)
-588 : xunit.runner.utility.netcoreapp10.dasm (-0.31% of base)
-320 : System.Composition.Hosting.dasm (-0.37% of base)
-261 : Microsoft.Diagnostics.Tracing.TraceEvent.dasm (-0.01% of base)
-189 : System.Composition.TypedParts.dasm (-0.38% of base)
-107 : System.Private.Xml.dasm (-0.00% of base)
-100 : System.Linq.Expressions.dasm (-0.01% of base)
-94 : System.ComponentModel.Composition.Registration.dasm (-0.10% of base)
-47 : FSharp.Core.dasm (-0.01% of base)
-41 : Microsoft.Extensions.DependencyInjection.Abstractions.dasm (-0.14% of base)
-30 : System.Configuration.ConfigurationManager.dasm (-0.01% of base)
-20 : System.ComponentModel.Composition.dasm (-0.01% of base)
-13 : Microsoft.VisualBasic.Core.dasm (-0.00% of base)
-10 : Microsoft.Diagnostics.FastSerialization.dasm (-0.00% of base)
17 total files with Code Size differences (16 improved, 1 regressed), 259 unchanged.
Top method improvements (bytes):
-261 (-8.11% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - Microsoft.Diagnostics.Tracing.Etlx.TraceLog:InitializeFromFile(System.String):this
-94 (-32.53% of base) : System.ComponentModel.Composition.Registration.dasm - System.ComponentModel.Composition.Registration.PartBuilder:MemberHasExportMetadata(System.Reflection.MemberInfo):bool
-93 (-34.83% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Nullable`1[int]]:AddNewCore():System.Object:this
-89 (-32.01% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Numerics.Vector`1[float]]:AddNewCore():System.Object:this
-87 (-2.85% of base) : System.Private.Xml.dasm - System.Xml.Serialization.XmlSerializationReader:ReadArray(System.String,System.String):System.Array:this
-86 (-41.95% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[double]:AddNewCore():System.Object:this
-86 (-43.00% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[int]:AddNewCore():System.Object:this
-86 (-42.79% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[long]:AddNewCore():System.Object:this
-86 (-42.57% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[short]:AddNewCore():System.Object:this
-86 (-42.79% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[ubyte]:AddNewCore():System.Object:this
-86 (-35.68% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[System.Nullable`1[int]](System.String):System.Nullable`1[int]:this
-86 (-35.68% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[System.Nullable`1[int]](System.String):System.Nullable`1[int]:this
-84 (-32.68% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[double](System.String):double:this
-84 (-32.68% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[double](System.String):double:this
-84 (-33.33% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[int](System.String):int:this
-84 (-33.33% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[int](System.String):int:this
-84 (-33.20% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[long](System.String):long:this
-84 (-33.20% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[long](System.String):long:this
-84 (-33.07% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[short](System.String):short:this
-84 (-33.07% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[short](System.String):short:this
Top method improvements (percentages):
-86 (-43.00% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[int]:AddNewCore():System.Object:this
-86 (-42.79% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[long]:AddNewCore():System.Object:this
-86 (-42.79% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[ubyte]:AddNewCore():System.Object:this
-86 (-42.57% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[short]:AddNewCore():System.Object:this
-86 (-41.95% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[double]:AddNewCore():System.Object:this
-86 (-35.68% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[System.Nullable`1[int]](System.String):System.Nullable`1[int]:this
-86 (-35.68% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[System.Nullable`1[int]](System.String):System.Nullable`1[int]:this
-93 (-34.83% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Nullable`1[int]]:AddNewCore():System.Object:this
-84 (-33.33% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[int](System.String):int:this
-84 (-33.33% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[int](System.String):int:this
-84 (-33.20% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[long](System.String):long:this
-84 (-33.20% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[long](System.String):long:this
-84 (-33.20% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[ubyte](System.String):ubyte:this
-84 (-33.20% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[ubyte](System.String):ubyte:this
-84 (-33.07% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[short](System.String):short:this
-84 (-33.07% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[short](System.String):short:this
-84 (-32.68% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[double](System.String):double:this
-84 (-32.68% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[double](System.String):double:this
-94 (-32.53% of base) : System.ComponentModel.Composition.Registration.dasm - System.ComponentModel.Composition.Registration.PartBuilder:MemberHasExportMetadata(System.Reflection.MemberInfo):bool
-89 (-32.01% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Numerics.Vector`1[float]]:AddNewCore():System.Object:this
109 total methods with Code Size differences (108 improved, 1 regressed), 376335 unchanged

diff example: https://www.diffchecker.com/ZF1cltJi/

@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 12, 2023
@ghostghost assigned EgorBoMay 12, 2023
@ghost

Copy link
Copy Markdown

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

Issue Details

We have a separate path for GTF_IND_INVARIANT where we could miss some optimization opportunites defined in fgValueNumberConstLoad

jit-diff:

Total bytes of base: 58746251
Total bytes of diff: 58741799
Total bytes of delta: -4452 (-0.01 % of base)
Total relative delta: NaN
diff is an improvement.
relative diff is a regression.
Total byte diff includes 103 bytes from reconciling methods
Base had 0 unique methods, 0 unique bytes
Diff had 1 unique methods, 103 unique bytes
Top file regressions (bytes):
103 : Microsoft.CodeAnalysis.dasm (0.01% of base)
Top file improvements (bytes):
-1499 : Newtonsoft.Json.dasm (-0.16% of base)
-624 : xunit.execution.dotnet.dasm (-0.25% of base)
-612 : System.ComponentModel.TypeConverter.dasm (-0.22% of base)
-588 : xunit.runner.utility.netcoreapp10.dasm (-0.31% of base)
-320 : System.Composition.Hosting.dasm (-0.37% of base)
-261 : Microsoft.Diagnostics.Tracing.TraceEvent.dasm (-0.01% of base)
-189 : System.Composition.TypedParts.dasm (-0.38% of base)
-107 : System.Private.Xml.dasm (-0.00% of base)
-100 : System.Linq.Expressions.dasm (-0.01% of base)
-94 : System.ComponentModel.Composition.Registration.dasm (-0.10% of base)
-47 : FSharp.Core.dasm (-0.01% of base)
-41 : Microsoft.Extensions.DependencyInjection.Abstractions.dasm (-0.14% of base)
-30 : System.Configuration.ConfigurationManager.dasm (-0.01% of base)
-20 : System.ComponentModel.Composition.dasm (-0.01% of base)
-13 : Microsoft.VisualBasic.Core.dasm (-0.00% of base)
-10 : Microsoft.Diagnostics.FastSerialization.dasm (-0.00% of base)
17 total files with Code Size differences (16 improved, 1 regressed), 259 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)
Top method improvements (bytes):
-261 (-8.11% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - Microsoft.Diagnostics.Tracing.Etlx.TraceLog:InitializeFromFile(System.String):this
-94 (-32.53% of base) : System.ComponentModel.Composition.Registration.dasm - System.ComponentModel.Composition.Registration.PartBuilder:MemberHasExportMetadata(System.Reflection.MemberInfo):bool
-93 (-34.83% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Nullable`1[int]]:AddNewCore():System.Object:this
-89 (-32.01% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Numerics.Vector`1[float]]:AddNewCore():System.Object:this
-87 (-2.85% of base) : System.Private.Xml.dasm - System.Xml.Serialization.XmlSerializationReader:ReadArray(System.String,System.String):System.Array:this
-86 (-41.95% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[double]:AddNewCore():System.Object:this
-86 (-43.00% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[int]:AddNewCore():System.Object:this
-86 (-42.79% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[long]:AddNewCore():System.Object:this
-86 (-42.57% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[short]:AddNewCore():System.Object:this
-86 (-42.79% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[ubyte]:AddNewCore():System.Object:this
-86 (-35.68% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[System.Nullable`1[int]](System.String):System.Nullable`1[int]:this
-86 (-35.68% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[System.Nullable`1[int]](System.String):System.Nullable`1[int]:this
-84 (-32.68% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[double](System.String):double:this
-84 (-32.68% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[double](System.String):double:this
-84 (-33.33% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[int](System.String):int:this
-84 (-33.33% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[int](System.String):int:this
-84 (-33.20% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[long](System.String):long:this
-84 (-33.20% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[long](System.String):long:this
-84 (-33.07% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[short](System.String):short:this
-84 (-33.07% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[short](System.String):short: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)
Top method improvements (percentages):
-86 (-43.00% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[int]:AddNewCore():System.Object:this
-86 (-42.79% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[long]:AddNewCore():System.Object:this
-86 (-42.79% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[ubyte]:AddNewCore():System.Object:this
-86 (-42.57% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[short]:AddNewCore():System.Object:this
-86 (-41.95% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[double]:AddNewCore():System.Object:this
-86 (-35.68% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[System.Nullable`1[int]](System.String):System.Nullable`1[int]:this
-86 (-35.68% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[System.Nullable`1[int]](System.String):System.Nullable`1[int]:this
-93 (-34.83% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Nullable`1[int]]:AddNewCore():System.Object:this
-84 (-33.33% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[int](System.String):int:this
-84 (-33.33% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[int](System.String):int:this
-84 (-33.20% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[long](System.String):long:this
-84 (-33.20% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[long](System.String):long:this
-84 (-33.20% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[ubyte](System.String):ubyte:this
-84 (-33.20% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[ubyte](System.String):ubyte:this
-84 (-33.07% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[short](System.String):short:this
-84 (-33.07% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[short](System.String):short:this
-84 (-32.68% of base) : xunit.execution.dotnet.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[double](System.String):double:this
-84 (-32.68% of base) : xunit.runner.utility.netcoreapp10.dasm - Xunit.Serialization.XunitSerializationInfo:GetValue[double](System.String):double:this
-94 (-32.53% of base) : System.ComponentModel.Composition.Registration.dasm - System.ComponentModel.Composition.Registration.PartBuilder:MemberHasExportMetadata(System.Reflection.MemberInfo):bool
-89 (-32.01% of base) : System.ComponentModel.TypeConverter.dasm - System.ComponentModel.BindingList`1[System.Numerics.Vector`1[float]]:AddNewCore():System.Object:this
109 total methods with Code Size differences (108 improved, 1 regressed), 376335 unchanged

diff example: https://www.diffchecker.com/ZF1cltJi/

Main use-case - field access for static readonly frozeObject (immutable)

Author:EgorBo
Assignees:EgorBo
Labels:

area-CodeGen-coreclr

Milestone:-

@EgorBo

Copy link
Copy Markdown
MemberAuthor

Build failure is unrelated (src/tests/JIT/opt/SSA/MemorySsa.csproj test failed to build and is fixed in #86176)

@jakobbotsch@SingleAccretion PTAL, this should produce more diffs when I enable more kinds of frozen objects

@EgorBo
EgorBo requested a review from jakobbotschMay 13, 2023 08:51
const int maxElementSize = sizeof(simd_t);

if ((varTypeIsSIMD(tree) || varTypeIsIntegral(tree) || varTypeIsFloating(tree) || tree->TypeIs(TYP_REF)) &&
if (!tree->TypeIs(TYP_BYREF, TYP_STRUCT) &&

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

reversed type checks for TP

@EgorBo
EgorBo merged commit 8995217 into dotnet:mainMay 15, 2023
@EgorBo
EgorBo deleted the fold-more-frozen branch May 15, 2023 11:15
@ghostghost locked as resolved and limited conversation to collaborators Jun 14, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR 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

@EgorBo@jakobbotsch@SingleAccretion