Skip to content

XARCH: Eliminate redundant mov to/from mem.#59780

Merged
kunalspathak merged 3 commits into
dotnet:mainfrom
DeepakRajendrakumaran:#53
Oct 27, 2021
Merged

XARCH: Eliminate redundant mov to/from mem.#59780
kunalspathak merged 3 commits into
dotnet:mainfrom
DeepakRajendrakumaran:#53

Conversation

@DeepakRajendrakumaran

@DeepakRajendrakumaran DeepakRajendrakumaran commented Sep 29, 2021

Copy link
Copy Markdown
Contributor

Optimize redundant mov instructions like:

IN002f: 000141 mov qword ptr [V08 rsp+78H], rax
IN0030: 000146 mov rax, qword ptr [V08 rsp+78H]
see comment (link)

This commit will essentially mirror what we do for Register->Register movs but with slight modifications to customize it for mem<->reg mov.
There are a couple of further optimizations to be revisited for both this and the existing IsRedundantMov() implementation(These are already mentioned as comments in existing impl)

  1. Neither will work for sse on targets with avx encoding since it cannot be determined the current way it's implemented if the upper bits have been modified.
  2. Currently, we check if both instructions(curr and predecessor) are equivalent. We can extend it for some other cases like aligned/unaligned(movups/movaps for eg.)

An example code snippet to reproduce this
`
[MethodImpl(MethodImplOptions.AggressiveOptimization)]

static unsafe double fmaTest4()

{
    vec b;

   var a = Vector256.AsDouble(Vector256.Create(3f));

    var c = Vector256.AsDouble(Vector256.Create(2f));

    var d = Vector256.AsDouble(Vector256.Create(3f));

    c = Fma.MultiplyAdd(Avx.LoadVector256((double*)&a), Avx.LoadVector256((double*)&b), Avx.LoadVector256((double*)&c));

    return Avx.Add(Avx.LoadVector256((double*)&c), Avx.LoadVector256((double*)&d)).ToScalar();

}`

@ghost ghost added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member labels Sep 29, 2021
@ghost

ghost commented Sep 29, 2021

Copy link
Copy Markdown

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

Issue Details

Optimize redundant mov instructions like:

IN002f: 000141 mov qword ptr [V08 rsp+78H], rax
IN0030: 000146 mov rax, qword ptr [V08 rsp+78H]
see comment (link)

This commit will essentially mirror what we do for Register->Register movs but with slight modifications to customize it for mem<->reg mov.
There are a couple of further optimizations to be revisited for both this and the existing IsRedundantMov() implementation(These are already mentioned as comments in existing impl)

  1. Neither will work for sse on targets with avx encoding since it cannot be determined the current way it's implemented if the upper bits have been modified.
  2. Currently, we check if both instructions(curr and predecessor) are equivalent. We can extend it for some other cases like aligned/unaligned(movups/movaps for eg.)

An example code snippet to reproduce this
`[MethodImpl(MethodImplOptions.AggressiveOptimization)]
static unsafe double fmaTest4()
{
vec b;
var a = Vector256.AsDouble(Vector256.Create(3f));
var c = Vector256.AsDouble(Vector256.Create(2f));
var d = Vector256.AsDouble(Vector256.Create(3f));

    c = Fma.MultiplyAdd(Avx.LoadVector256((double*)&a), Avx.LoadVector256((double*)&b), Avx.LoadVector256((double*)&c));

    return Avx.Add(Avx.LoadVector256((double*)&c), Avx.LoadVector256((double*)&d)).ToScalar();
}`
Author: DeepakRajendrakumaran
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@DeepakRajendrakumaran

Copy link
Copy Markdown
Contributor Author

@tannergooding Can you please add the right person to review this change?

@tannergooding

Copy link
Copy Markdown
Member

CC. @JulieLeeMSFT, @dotnet/jit-contrib

// vmovapd xmmword ptr [V01 rbp-20H], xmm0 # <-- last instruction
// vmovapd xmmword ptr [V01 rbp-20H], xmm0 # <-- current instruction can be omitted.
//
// 2. Opposite Move as that of last instruction emitted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't this case *_R_S rather than *_S_R?

@DeepakRajendrakumaran DeepakRajendrakumaran Oct 5, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It covers both R_S and S_R. I'm open to naming it something else for clarity

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we could call this IsRedundantStackMov or similar?

Someone on the JIT team may have a better suggestion or convention we could use here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This handles the following cases

  1. mov reg mem
    mov reg mem // identical instructions mem ->reg
  2. mov mem reg
    mov mem reg // identical instructions reg ->mem
  3. mov mem reg
    mov reg mem // reg->mem followed by same mem ->reg
  4. mov reg mem
    mov mem reg // mem->reg followed by same reg-> mem

@SingleAccretion SingleAccretion Oct 5, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wanted to note that the back to back moves can have the side effect of changing the GC-ness of a location/register.

For example, in this case:

//         vmovupd  ymmword ptr[V01 rbp-50H], ymm0  # <-- last instruction
//         vmovupd  ymm0, ymmword ptr[V01 rbp-50H]  # <-- current instruction can be omitted.

(Let's pretend vectors can store GC refs, this obviously only applies to GPRs)

If V01 was a non-GC variable, and ymm0 in the first instruction held a non-GC value, but then the load was to a GC variable (ymm0 would become GC-live), we cannot eliminate it.

Does the logic here handle this case already?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Superpmi

What do the diffs look like?

Think this is good to go?

The change looks good to me, but someone from the team will have the final say.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Diff looks like this-

Found 53 files with textual diffs.

Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 111144
Total bytes of diff: 110600
Total bytes of delta: -544 (-0.489% of base)
Total relative delta: -0.51
diff is an improvement.
relative diff is an improvement.

Top file improvements (bytes):
-105 : 22240.dasm (-1.113% of base)
-55 : 20577.dasm (-1.168% of base)
-28 : 20558.dasm (-0.897% of base)
-24 : 17628.dasm (-0.610% of base)
-16 : 4252.dasm (-0.789% of base)
-16 : 19812.dasm (-0.381% of base)
-14 : 20322.dasm (-0.271% of base)
-14 : 3120.dasm (-0.307% of base)
-14 : 6361.dasm (-0.627% of base)
-12 : 15710.dasm (-1.309% of base)
-12 : 4886.dasm (-0.722% of base)
-12 : 21805.dasm (-0.721% of base)
-8 : 1205.dasm (-0.666% of base)
-8 : 5003.dasm (-1.117% of base)
-8 : 24037.dasm (-0.324% of base)
-8 : 6376.dasm (-0.748% of base)
-8 : 23196.dasm (-0.331% of base)
-8 : 1289.dasm (-1.538% of base)
-8 : 8810.dasm (-1.000% of base)
-8 : 18225.dasm (-0.460% of base)

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

@DeepakRajendrakumaran DeepakRajendrakumaran Oct 19, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For the motivating example given in PR description

With Change-
G_M36146_IG01: ;; offset=0000H
55 push rbp
4881EC90000000 sub rsp, 144
C5F877 vzeroupper
488DAC2490000000 lea rbp, [rsp+90H]
C4413857C0 vxorps xmm8, xmm8
C5797F45E0 vmovdqa xmmword ptr [rbp-20H], xmm8
C5797F45F0 vmovdqa xmmword ptr [rbp-10H], xmm8
;; bbWeight=1 PerfScore 7.08
G_M36146_IG02: ;; offset=0022H
C5FD100556000000 vmovupd ymm0, ymmword ptr[reloc @rwd00]
C5FD1145B0 vmovupd ymmword ptr[rbp-50H], ymm0
C5FD100D69000000 vmovupd ymm1, ymmword ptr[reloc @RWD32]
C5FD114D90 vmovupd ymmword ptr[rbp-70H], ymm1
C5FD118570FFFFFF vmovupd ymmword ptr[rbp-90H], ymm0
C5FD1045B0 vmovupd ymm0, ymmword ptr[rbp-50H]
C5FD104DE0 vmovupd ymm1, ymmword ptr[rbp-20H]
C4E2F5A84590 vfmadd213pd ymm0, ymm1, ymmword ptr[rbp-70H]
C5FD114590 vmovupd ymmword ptr[rbp-70H], ymm0
C5FD588570FFFFFF vaddpd ymm0, ymm0, ymmword ptr[rbp-90H]

Without change
G_M36146_IG01: ;; offset=0000H
55 push rbp
4881EC90000000 sub rsp, 144
C5F877 vzeroupper
488DAC2490000000 lea rbp, [rsp+90H]
C4413857C0 vxorps xmm8, xmm8
C5797F45E0 vmovdqa xmmword ptr [rbp-20H], xmm8
C5797F45F0 vmovdqa xmmword ptr [rbp-10H], xmm8
;; bbWeight=1 PerfScore 7.08
G_M36146_IG02: ;; offset=0022H
C5FD100556000000 vmovupd ymm0, ymmword ptr[reloc @rwd00]
C5FD1145B0 vmovupd ymmword ptr[rbp-50H], ymm0
C5FD100D69000000 vmovupd ymm1, ymmword ptr[reloc @RWD32]
C5FD114D90 vmovupd ymmword ptr[rbp-70H], ymm1
C5FD118570FFFFFF vmovupd ymmword ptr[rbp-90H], ymm0
C5FD1045B0 vmovupd ymm0, ymmword ptr[rbp-50H]
C5FD104DE0 vmovupd ymm1, ymmword ptr[rbp-20H]
C4E2F5A84590 vfmadd213pd ymm0, ymm1, ymmword ptr[rbp-70H]
C5FD114590 vmovupd ymmword ptr[rbp-70H], ymm0
C5FD104590 vmovupd ymm0, ymmword ptr[rbp-70H]
C5FD588570FFFFFF vaddpd ymm0, ymm0, ymmword ptr[rbp-90H]

@DeepakRajendrakumaran DeepakRajendrakumaran Oct 19, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I ran the tests again with latest changes and I seem to have an additional failure-
artifacts/tests/coreclr/Linux.x64.Release/tracing/eventpipe/gcdump/gcdump/gcdump.sh

Looking into this

Edit - false alarm. Not a failure

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note - I'm currently just waiting for further comments/ or get this resolved as I do not have anything new to add.

Comment thread src/coreclr/jit/emitxarch.cpp
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
Comment thread src/coreclr/jit/emitxarch.cpp Outdated
1. Changing name to IsRedundantStackMov.
2. Add assert for format.
3. Move common code to helper.
@AndyAyersMS

Copy link
Copy Markdown
Member

@kunalspathak this is a new peephole -- you should take a look.

Also I'd be interested in seeing what this does to our un-optimized codegen. Seems like it could do a lot of good there. We could for instance enable this in Tier0.

I'd even entertain the idea of enabling it for debug codegen, if we can be confident it won't adversely impact the debugging experience.

@kunalspathak

Copy link
Copy Markdown
Contributor

I will take a look.

@kunalspathak

Copy link
Copy Markdown
Contributor

I ran this PR through superpmi and will double check the assembly differences for some of them.

Benchmarks


Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 105561
Total bytes of diff: 104952
Total bytes of delta: -609 (-0.58 % of base)
Total relative delta: -0.61
    diff is an improvement.
    relative diff is an improvement.
Detail diffs


Top file improvements (bytes):
        -120 : 20506.dasm (-1.50% of base)
         -53 : 18579.dasm (-1.10% of base)
         -24 : 9416.dasm (-0.62% of base)
         -24 : 19791.dasm (-1.49% of base)
         -20 : 18560.dasm (-0.69% of base)
         -16 : 18159.dasm (-0.72% of base)
         -16 : 4543.dasm (-0.84% of base)
         -16 : 17813.dasm (-0.43% of base)
         -14 : 2756.dasm (-1.65% of base)
         -14 : 1969.dasm (-0.67% of base)
         -14 : 18323.dasm (-0.27% of base)
         -12 : 13911.dasm (-1.40% of base)
         -12 : 2626.dasm (-0.71% of base)
         -10 : 7223.dasm (-1.25% of base)
          -8 : 18203.dasm (-0.07% of base)
          -8 : 18522.dasm (-0.09% of base)
          -8 : 1984.dasm (-0.79% of base)
          -8 : 25656.dasm (-0.36% of base)
          -8 : 12225.dasm (-0.83% of base)
          -8 : 12180.dasm (-0.84% of base)

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

Top method improvements (bytes):
        -120 (-1.50% of base) : 20506.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.ParameterHelpers:CheckParameterModifiers(Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax,Microsoft.CodeAnalysis.DiagnosticBag)
         -53 (-1.10% of base) : 18579.dasm - Microsoft.CodeAnalysis.CSharp.Binder:CheckValueKind(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.CSharp.BoundExpression,ushort,bool,Microsoft.CodeAnalysis.DiagnosticBag):bool:this
         -24 (-0.62% of base) : 9416.dasm - <ConnectAsync>d__96:MoveNext():this
         -24 (-1.49% of base) : 19791.dasm - Newtonsoft.Json.Serialization.JsonSerializerInternalReader:PopulateDictionary(System.Collections.IDictionary,Newtonsoft.Json.JsonReader,Newtonsoft.Json.Serialization.JsonDictionaryContract,Newtonsoft.Json.Serialization.JsonProperty,System.String):System.Object:this
         -20 (-0.69% of base) : 18560.dasm - Microsoft.CodeAnalysis.CSharp.Binder:BindReturn(Microsoft.CodeAnalysis.CSharp.Syntax.ReturnStatementSyntax,Microsoft.CodeAnalysis.DiagnosticBag):Microsoft.CodeAnalysis.CSharp.BoundStatement:this
         -16 (-0.43% of base) : 17813.dasm - Microsoft.CodeAnalysis.CSharp.Imports:Validate():this
         -16 (-0.72% of base) : 18159.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamedTypeSymbol:PostDecodeWellKnownAttributes(System.Collections.Immutable.ImmutableArray`1[[Microsoft.CodeAnalysis.CSharp.Symbols.CSharpAttributeData, Microsoft.CodeAnalysis.CSharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]],System.Collections.Immutable.ImmutableArray`1[[Microsoft.CodeAnalysis.CSharp.Syntax.AttributeSyntax, Microsoft.CodeAnalysis.CSharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]],Microsoft.CodeAnalysis.DiagnosticBag,short,Microsoft.CodeAnalysis.WellKnownAttributeData):this
         -16 (-0.84% of base) : 4543.dasm - System.Diagnostics.ActivitySource:CreateActivity(System.String,int,System.Diagnostics.ActivityContext,System.String,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.IEnumerable`1[ActivityLink],System.DateTimeOffset,bool,int):System.Diagnostics.Activity:this
         -14 (-1.65% of base) : 2756.dasm - ILStubClass:IL_STUB_PInvoke(System.Runtime.CompilerServices.QCallModule,int,bool,System.Byte[],int,System.Byte[],int,int,System.Reflection.Emit.ExceptionHandler[],int,System.Int32[],int)
         -14 (-0.27% of base) : 18323.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceOrdinaryMethodSymbol:MethodChecks(Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax,Microsoft.CodeAnalysis.CSharp.Binder,Microsoft.CodeAnalysis.DiagnosticBag):this
         -14 (-0.67% of base) : 1969.dasm - Newtonsoft.Json.Serialization.JsonSerializerInternalReader:PopulateObject(System.Object,Newtonsoft.Json.JsonReader,Newtonsoft.Json.Serialization.JsonObjectContract,Newtonsoft.Json.Serialization.JsonProperty,System.String):System.Object:this
         -12 (-1.40% of base) : 13911.dasm - System.IO.Pipelines.Pipe:ReadAsync(System.Threading.CancellationToken):System.Threading.Tasks.ValueTask`1[ReadResult]:this
         -12 (-0.71% of base) : 2626.dasm - System.Reflection.Emit.ModuleBuilder:GetMethodTokenNoLock(System.Reflection.MethodInfo,bool):int:this
         -10 (-1.25% of base) : 7223.dasm - System.Xml.XmlUtf8RawTextWriter:WriteElementTextBlock(long,long):this
          -8 (-0.48% of base) : 16179.dasm - <Parse_SequentialAsync>d__15:MoveNext():this
          -8 (-0.36% of base) : 25656.dasm - <ReadAsync>d__7:MoveNext():this
          -8 (-0.34% of base) : 26453.dasm - <ReadAsyncWithCancellationToken>d__11:MoveNext():this
          -8 (-1.06% of base) : 20355.dasm - CscBench:GetSpanBetweenMarkers(Microsoft.CodeAnalysis.SyntaxTree):Microsoft.CodeAnalysis.Text.TextSpan
          -8 (-0.09% of base) : 18522.dasm - Microsoft.CodeAnalysis.CSharp.Imports:FromSyntax(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode,Microsoft.CodeAnalysis.CSharp.InContainerBinder,Roslyn.Utilities.ConsList`1[[Microsoft.CodeAnalysis.CSharp.Symbol, Microsoft.CodeAnalysis.CSharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]],bool):Microsoft.CodeAnalysis.CSharp.Imports
          -8 (-0.07% of base) : 18203.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceMemberContainerTypeSymbol:AddNonTypeMembers(MembersAndInitializersBuilder,Microsoft.CodeAnalysis.SyntaxList`1[[Microsoft.CodeAnalysis.CSharp.Syntax.MemberDeclarationSyntax, Microsoft.CodeAnalysis.CSharp, Version=2.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]],Microsoft.CodeAnalysis.DiagnosticBag):this

Top method improvements (percentages):
          -5 (-6.85% of base) : 20564.dasm - Microsoft.CodeAnalysis.SyntaxNode:GetLocation():Microsoft.CodeAnalysis.Location:this
          -5 (-5.62% of base) : 21258.dasm - System.Runtime.Serialization.CodeGenerator:Ldelema(System.Type):this
          -5 (-2.81% of base) : 8288.dasm - System.Runtime.Serialization.CodeGenerator:If(int):this
          -6 (-2.65% of base) : 892.dasm - SelectListIterator`2[Measurement,Double][BenchmarkDotNet.Reports.Measurement,System.Double]:MoveNext():bool:this
          -6 (-2.49% of base) : 19256.dasm - Microsoft.CodeAnalysis.PEModule:HasFixedBufferAttribute(System.Reflection.Metadata.EntityHandle,byref,byref):bool:this
          -5 (-2.28% of base) : 11600.dasm - System.Runtime.Serialization.CodeGenerator:Ldobj(System.Type):this
          -5 (-2.15% of base) : 3554.dasm - System.Runtime.Serialization.CodeGenerator:Ldelem(System.Type):this
          -5 (-2.15% of base) : 8318.dasm - System.Runtime.Serialization.CodeGenerator:Stelem(System.Type):this
          -5 (-1.81% of base) : 8290.dasm - System.Runtime.Serialization.CodeGenerator:ElseIfIsEmptyString(System.Reflection.Emit.LocalBuilder):this
         -14 (-1.65% of base) : 2756.dasm - ILStubClass:IL_STUB_PInvoke(System.Runtime.CompilerServices.QCallModule,int,bool,System.Byte[],int,System.Byte[],int,int,System.Reflection.Emit.ExceptionHandler[],int,System.Int32[],int)
        -120 (-1.50% of base) : 20506.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.ParameterHelpers:CheckParameterModifiers(Microsoft.CodeAnalysis.CSharp.Syntax.ParameterSyntax,Microsoft.CodeAnalysis.DiagnosticBag)
         -24 (-1.49% of base) : 19791.dasm - Newtonsoft.Json.Serialization.JsonSerializerInternalReader:PopulateDictionary(System.Collections.IDictionary,Newtonsoft.Json.JsonReader,Newtonsoft.Json.Serialization.JsonDictionaryContract,Newtonsoft.Json.Serialization.JsonProperty,System.String):System.Object:this
          -6 (-1.46% of base) : 18861.dasm - Microsoft.CodeAnalysis.CodeGen.ReferenceDependencyWalker:VisitReference(Microsoft.Cci.IReference,Microsoft.CodeAnalysis.Emit.EmitContext)
         -12 (-1.40% of base) : 13911.dasm - System.IO.Pipelines.Pipe:ReadAsync(System.Threading.CancellationToken):System.Threading.Tasks.ValueTask`1[ReadResult]:this
          -5 (-1.33% of base) : 18616.dasm - Microsoft.CodeAnalysis.CSharp.Binder:IsDivisionByZero(int,Microsoft.CodeAnalysis.ConstantValue):bool
          -6 (-1.26% of base) : 4553.dasm - System.Diagnostics.ActivityCreationOptions`1[ActivityContext][System.Diagnostics.ActivityContext]:.ctor(System.Diagnostics.ActivitySource,System.String,System.Diagnostics.ActivityContext,int,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.IEnumerable`1[ActivityLink],int):this
         -10 (-1.25% of base) : 7223.dasm - System.Xml.XmlUtf8RawTextWriter:WriteElementTextBlock(long,long):this
         -53 (-1.10% of base) : 18579.dasm - Microsoft.CodeAnalysis.CSharp.Binder:CheckValueKind(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.CSharp.BoundExpression,ushort,bool,Microsoft.CodeAnalysis.DiagnosticBag):bool:this
          -8 (-1.06% of base) : 20355.dasm - CscBench:GetSpanBetweenMarkers(Microsoft.CodeAnalysis.SyntaxTree):Microsoft.CodeAnalysis.Text.TextSpan
          -6 (-0.87% of base) : 18442.dasm - Microsoft.CodeAnalysis.CSharp.ClsComplianceChecker:GetDeclaredCompliance(Microsoft.CodeAnalysis.CSharp.Symbol,byref):System.Nullable`1[Boolean]:this

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


Libraries


Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 45593092 (overridden on cmd)
Total bytes of diff: 45586498 (overridden on cmd)
Total bytes of delta: -6594 (-0.01 % of base)
    diff is an improvement.
    relative diff is an improvement.
Detail diffs


Top file improvements (bytes):
        -213 : 43032.dasm (-3.47% of base)
        -213 : 41410.dasm (-8.89% of base)
        -211 : 51175.dasm (-8.76% of base)
        -201 : 53513.dasm (-4.10% of base)
        -165 : 54079.dasm (-3.67% of base)
        -147 : 43739.dasm (-6.73% of base)
        -141 : 53527.dasm (-11.07% of base)
        -141 : 43050.dasm (-10.96% of base)
        -105 : 43169.dasm (-4.53% of base)
         -90 : 53927.dasm (-1.29% of base)
         -75 : 43581.dasm (-5.05% of base)
         -70 : 49924.dasm (-0.73% of base)
         -69 : 23970.dasm (-1.36% of base)
         -57 : 43319.dasm (-3.15% of base)
         -56 : 50027.dasm (-0.98% of base)
         -52 : 77253.dasm (-1.77% of base)
         -48 : 50213.dasm (-0.40% of base)
         -45 : 121846.dasm (-1.81% of base)
         -42 : 49888.dasm (-0.58% of base)
         -40 : 54147.dasm (-0.67% of base)

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

Top method improvements (bytes):
        -213 (-8.89% of base) : 41410.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.CSharpAttributeData:ShouldEmitAttribute(Microsoft.CodeAnalysis.CSharp.Symbol,bool,bool):bool:this
        -213 (-3.47% of base) : 43032.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceAssemblySymbol:DecodeWellKnownAttribute(byref,int,bool):this
        -211 (-8.76% of base) : 51175.dasm - Microsoft.CodeAnalysis.VisualBasic.Symbols.VisualBasicAttributeData:ShouldEmitAttribute(Microsoft.CodeAnalysis.VisualBasic.Symbol,bool,bool):bool:this
        -201 (-4.10% of base) : 53513.dasm - Microsoft.CodeAnalysis.VisualBasic.Symbols.SourceAssemblySymbol:DecodeWellKnownAttribute(byref):this
        -165 (-3.67% of base) : 54079.dasm - Microsoft.CodeAnalysis.VisualBasic.Symbols.SourceNamedTypeSymbol:DecodeWellKnownAttribute(byref):this
        -147 (-6.73% of base) : 43739.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceNamedTypeSymbol:DecodeWellKnownAttribute(byref):this
        -141 (-10.96% of base) : 43050.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceAssemblySymbol:IsKnownAssemblyAttribute(Microsoft.CodeAnalysis.CSharp.Symbols.CSharpAttributeData):bool:this
        -141 (-11.07% of base) : 53527.dasm - Microsoft.CodeAnalysis.VisualBasic.Symbols.SourceAssemblySymbol:IsKnownAssemblyAttribute(Microsoft.CodeAnalysis.VisualBasic.Symbols.VisualBasicAttributeData):bool:this
        -105 (-4.53% of base) : 43169.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceComplexParameterSymbol:DecodeWellKnownAttribute(byref):this
         -90 (-1.29% of base) : 53927.dasm - Microsoft.CodeAnalysis.VisualBasic.Symbols.SourceMethodSymbol:DecodeWellKnownAttributeAppliedToMethod(byref):this
         -75 (-5.05% of base) : 43581.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceMethodSymbol:DecodeWellKnownAttributeAppliedToMethod(byref):this
         -70 (-0.73% of base) : 49924.dasm - Microsoft.CodeAnalysis.VisualBasic.Binder:DecodeModifiers(Microsoft.CodeAnalysis.SyntaxTokenList,int,int,int,Microsoft.CodeAnalysis.DiagnosticBag):Microsoft.CodeAnalysis.VisualBasic.MemberModifiers:this
         -69 (-1.36% of base) : 23970.dasm - Microsoft.CodeAnalysis.CSharp.Binder:CheckConstantBounds(byte,System.Decimal):bool
         -57 (-3.15% of base) : 43319.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceFieldSymbol:DecodeWellKnownAttribute(byref):this
         -56 (-0.98% of base) : 50027.dasm - Microsoft.CodeAnalysis.VisualBasic.Binder:DecodeLocalModifiersAndReportErrors(Microsoft.CodeAnalysis.SyntaxTokenList,Microsoft.CodeAnalysis.DiagnosticBag):this
         -52 (-1.77% of base) : 77253.dasm - Microsoft.CodeAnalysis.Compilation:SerializeToPeStream(Microsoft.CodeAnalysis.Emit.CommonPEModuleBuilder,EmitStreamProvider,EmitStreamProvider,System.Func`1[[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]],Microsoft.CodeAnalysis.DiagnosticBag,bool,System.Threading.CancellationToken):bool:this
         -48 (-0.40% of base) : 50213.dasm - Microsoft.CodeAnalysis.VisualBasic.Binder:BindFieldAndPropertyInitializers(Microsoft.CodeAnalysis.VisualBasic.Symbols.SourceMemberContainerTypeSymbol,System.Collections.Immutable.ImmutableArray`1[ImmutableArray`1],Microsoft.CodeAnalysis.VisualBasic.Symbols.SynthesizedInteractiveInitializerMethod,Microsoft.CodeAnalysis.DiagnosticBag):System.Collections.Immutable.ImmutableArray`1[[Microsoft.CodeAnalysis.VisualBasic.BoundInitializer, Microsoft.CodeAnalysis.VisualBasic, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]
         -45 (-1.81% of base) : 121846.dasm - System.Linq.Expressions.Compiler.ILGen:EmitDecimal(System.Reflection.Emit.ILGenerator,System.Decimal)
         -42 (-0.58% of base) : 49888.dasm - Microsoft.CodeAnalysis.VisualBasic.Binder:DecodeParameterList(Microsoft.CodeAnalysis.VisualBasic.Symbol,bool,int,Microsoft.CodeAnalysis.SeparatedSyntaxList`1[[Microsoft.CodeAnalysis.VisualBasic.Syntax.ParameterSyntax, Microsoft.CodeAnalysis.VisualBasic, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]],Microsoft.CodeAnalysis.ArrayBuilder`1[[Microsoft.CodeAnalysis.VisualBasic.Symbols.ParameterSymbol, Microsoft.CodeAnalysis.VisualBasic, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]],CheckParameterModifierDelegate,Microsoft.CodeAnalysis.DiagnosticBag):this
         -40 (-0.67% of base) : 54147.dasm - Microsoft.CodeAnalysis.VisualBasic.Symbols.SourceNamedTypeSymbol:CheckDeclarationNameAndTypeParameters(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode,Microsoft.CodeAnalysis.VisualBasic.Binder,Microsoft.CodeAnalysis.DiagnosticBag,byref):this

Top method improvements (percentages):
          -4 (-25.00% of base) : 709.dasm - Microsoft.FSharp.Core.FSharpValueOption`1[Byte][System.Byte]:get_None():Microsoft.FSharp.Core.FSharpValueOption`1[Byte]
          -4 (-25.00% of base) : 696.dasm - Microsoft.FSharp.Core.FSharpValueOption`1[Byte][System.Byte]:get_ValueNone():Microsoft.FSharp.Core.FSharpValueOption`1[Byte]
          -4 (-22.22% of base) : 11987.dasm - Microsoft.FSharp.Core.Operators:Snd(System.Tuple`2[__Canon,Nullable`1]):System.Nullable`1[Int32]
          -4 (-22.22% of base) : 11988.dasm - Microsoft.FSharp.Core.Operators:Snd(System.Tuple`2[Byte,Nullable`1]):System.Nullable`1[Int32]
          -5 (-13.16% of base) : 114420.dasm - System.Data.SqlTypes.SqlByte:op_Explicit(System.Data.SqlTypes.SqlDecimal):System.Data.SqlTypes.SqlByte
          -5 (-13.16% of base) : 113859.dasm - System.Data.SqlTypes.SqlInt16:op_Explicit(System.Data.SqlTypes.SqlDecimal):System.Data.SqlTypes.SqlInt16
         -10 (-13.16% of base) : 116061.dasm - System.Windows.Forms.DpiHelper:CreateScaledBitmap(System.Drawing.Bitmap):System.Drawing.Bitmap
        -141 (-11.07% of base) : 53527.dasm - Microsoft.CodeAnalysis.VisualBasic.Symbols.SourceAssemblySymbol:IsKnownAssemblyAttribute(Microsoft.CodeAnalysis.VisualBasic.Symbols.VisualBasicAttributeData):bool:this
        -141 (-10.96% of base) : 43050.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.SourceAssemblySymbol:IsKnownAssemblyAttribute(Microsoft.CodeAnalysis.CSharp.Symbols.CSharpAttributeData):bool:this
        -213 (-8.89% of base) : 41410.dasm - Microsoft.CodeAnalysis.CSharp.Symbols.CSharpAttributeData:ShouldEmitAttribute(Microsoft.CodeAnalysis.CSharp.Symbol,bool,bool):bool:this
        -211 (-8.76% of base) : 51175.dasm - Microsoft.CodeAnalysis.VisualBasic.Symbols.VisualBasicAttributeData:ShouldEmitAttribute(Microsoft.CodeAnalysis.VisualBasic.Symbol,bool,bool):bool:this
          -5 (-7.81% of base) : 153137.dasm - System.Text.Json.JsonDocument:Parse(System.ReadOnlyMemory`1[Byte],System.Text.Json.JsonDocumentOptions):System.Text.Json.JsonDocument
          -6 (-7.69% of base) : 13939.dasm - ListEnumerator`1[Vector`1][System.Numerics.Vector`1[System.Single]]:System.Collections.Generic.IEnumerator<'T>.get_Current():System.Numerics.Vector`1[Single]:this
          -5 (-7.46% of base) : 7972.dasm - Map@611-3[__Canon,Nullable`1][System.__Canon,System.Nullable`1[System.Int32]]:Invoke(Microsoft.FSharp.Collections.SetTree`1[Nullable`1],System.__Canon):Microsoft.FSharp.Collections.SetTree`1[Nullable`1]:this
          -5 (-7.46% of base) : 7977.dasm - Map@611-3[Int32,Nullable`1][System.Int32,System.Nullable`1[System.Int32]]:Invoke(Microsoft.FSharp.Collections.SetTree`1[Nullable`1],int):Microsoft.FSharp.Collections.SetTree`1[Nullable`1]:this
          -5 (-7.46% of base) : 7980.dasm - Map@611-3[Int64,Nullable`1][System.Int64,System.Nullable`1[System.Int32]]:Invoke(Microsoft.FSharp.Collections.SetTree`1[Nullable`1],long):Microsoft.FSharp.Collections.SetTree`1[Nullable`1]:this
          -5 (-7.46% of base) : 7979.dasm - Map@611-3[Vector`1,Nullable`1][System.Numerics.Vector`1[System.Single],System.Nullable`1[System.Int32]]:Invoke(Microsoft.FSharp.Collections.SetTree`1[Nullable`1],System.Numerics.Vector`1[Single]):Microsoft.FSharp.Collections.SetTree`1[Nullable`1]:this
          -5 (-7.35% of base) : 7974.dasm - Map@611-3[Byte,Nullable`1][System.Byte,System.Nullable`1[System.Int32]]:Invoke(Microsoft.FSharp.Collections.SetTree`1[Nullable`1],ubyte):Microsoft.FSharp.Collections.SetTree`1[Nullable`1]:this
          -5 (-7.35% of base) : 7976.dasm - Map@611-3[Int16,Nullable`1][System.Int16,System.Nullable`1[System.Int32]]:Invoke(Microsoft.FSharp.Collections.SetTree`1[Nullable`1],short):Microsoft.FSharp.Collections.SetTree`1[Nullable`1]:this
         -10 (-7.30% of base) : 201102.dasm - System.Linq.CachingComparer`2[__Canon,Nullable`1][System.__Canon,System.Nullable`1[System.Int32]]:Compare(System.__Canon,bool):int:this

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


Coreclr.tests


Summary of Code Size diffs:
(Lower is better)

Total bytes of base: 127278515 (overridden on cmd)
Total bytes of diff: 127274315 (overridden on cmd)
Total bytes of delta: -4200 (-0.00 % of base)
    diff is an improvement.
    relative diff is an improvement.
Detail diffs


Top file improvements (bytes):
        -224 : 190984.dasm (-0.10% of base)
        -224 : 190909.dasm (-0.10% of base)
        -208 : 218598.dasm (-1.69% of base)
        -208 : 218499.dasm (-1.69% of base)
         -84 : 246475.dasm (-2.58% of base)
         -81 : 169061.dasm (-1.85% of base)
         -81 : 169222.dasm (-1.86% of base)
         -55 : 226112.dasm (-0.16% of base)
         -55 : 226136.dasm (-0.15% of base)
         -55 : 226154.dasm (-0.16% of base)
         -55 : 226157.dasm (-0.16% of base)
         -55 : 226142.dasm (-0.15% of base)
         -55 : 226145.dasm (-0.16% of base)
         -55 : 226147.dasm (-0.16% of base)
         -55 : 226149.dasm (-0.17% of base)
         -47 : 168833.dasm (-2.04% of base)
         -47 : 169203.dasm (-2.08% of base)
         -47 : 168700.dasm (-2.04% of base)
         -47 : 169210.dasm (-2.08% of base)
         -25 : 168415.dasm (-1.97% of base)

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

Top method improvements (bytes):
        -224 (-0.10% of base) : 190909.dasm - decimaldiv:Main():int
        -224 (-0.10% of base) : 190984.dasm - decimalrem:Main():int
        -208 (-1.69% of base) : 218598.dasm - TestApp:Main():int
        -208 (-1.69% of base) : 218499.dasm - TestApp:Main():int
         -84 (-2.58% of base) : 246475.dasm - X:SetDirect(System.String,bool):bool
         -81 (-1.85% of base) : 169061.dasm - NullableTest44:Run()
         -81 (-1.86% of base) : 169222.dasm - NullableTest44:Run()
         -55 (-0.16% of base) : 226112.dasm - byteMDArrTest:Main():int
         -55 (-0.15% of base) : 226136.dasm - intMDArrTest:Main():int
         -55 (-0.15% of base) : 226142.dasm - longMDArrTest:Main():int
         -55 (-0.16% of base) : 226145.dasm - sbyteMDArrTest:Main():int
         -55 (-0.16% of base) : 226147.dasm - shortMDArrTest:Main():int
         -55 (-0.17% of base) : 226149.dasm - uintMDArrTest:Main():int
         -55 (-0.16% of base) : 226154.dasm - ulongMDArrTest:Main():int
         -55 (-0.16% of base) : 226157.dasm - ushortMDArrTest:Main():int
         -47 (-2.08% of base) : 169203.dasm - NullableTest23:Run()
         -47 (-2.04% of base) : 168700.dasm - NullableTest23:Run()
         -47 (-2.04% of base) : 168833.dasm - NullableTest30:Run()
         -47 (-2.08% of base) : 169210.dasm - NullableTest30:Run()
         -25 (-1.91% of base) : 168472.dasm - NullableTest11:Run()

Top method improvements (percentages):
          -4 (-20.00% of base) : 89052.dasm - Test:CopyAStructUsingAddressOfASmallField(long):B
          -5 (-15.62% of base) : 251532.dasm - Test:test4():int
          -5 (-15.62% of base) : 251571.dasm - Test:test4():int
          -5 (-14.71% of base) : 241136.dasm - Test:test4():byte
          -5 (-14.71% of base) : 251551.dasm - Test:test4():long
          -5 (-14.71% of base) : 251586.dasm - Test:test4():long
          -5 (-14.71% of base) : 251534.dasm - Test:test6(byref)
          -5 (-13.89% of base) : 241138.dasm - Test:test6(byref)
          -5 (-13.51% of base) : 251553.dasm - Test:test6(byref)
          -5 (-11.36% of base) : 87951.dasm - AA:Main():int
          -5 (-10.64% of base) : 241154.dasm - Test:test22():ushort
          -5 (-10.20% of base) : 251538.dasm - Test:test14(System.Int32[],int)
          -5 (-10.20% of base) : 251575.dasm - Test:test14(System.UInt32[],int)
          -5 (-9.62% of base) : 251558.dasm - Test:test14(System.Int64[],long)
          -5 (-9.62% of base) : 251590.dasm - Test:test14(System.UInt64[],long)
          -5 (-9.09% of base) : 241146.dasm - Test:test14(System.SByte[],byte)
          -5 (-7.14% of base) : 241142.dasm - Test:test10()
          -5 (-6.85% of base) : 230757.dasm - Helper:Compare(System.Nullable`1[NotEmptyStructConstrainedGenQ`1],NotEmptyStructConstrainedGenQ`1[Int32]):bool
          -5 (-6.85% of base) : 231648.dasm - Helper:Compare(System.Nullable`1[NotEmptyStructConstrainedGenQ`1],NotEmptyStructConstrainedGenQ`1[Int32]):bool
          -5 (-6.85% of base) : 230832.dasm - Helper:Compare(System.Nullable`1[NotEmptyStructConstrainedGenQ`1],NotEmptyStructConstrainedGenQ`1[Int32]):bool

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


@DeepakRajendrakumaran

Copy link
Copy Markdown
Contributor Author

@kunalspathak Let me know if you see anything that needs reworking or is failing.

@kunalspathak kunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I verified some of the asmdiffs and they looks good. Thank you for your contribution!

@kunalspathak kunalspathak merged commit ffa122a into dotnet:main Oct 27, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Nov 26, 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 community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants