Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[RyuJIT] Unroll single-iteration loops#43947

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sandreenko merged 6 commits intodotnet:masterfromEgorBo:unroll-empty-loops
Nov 12, 2020

Conversation

@EgorBo
Copy link
Member

@EgorBoEgorBo commentedOct 28, 2020
edited
Loading

JIT is able to unroll small constant-size loops viaoptUnrollLoops, but currently it only works ifVector_.Count is used (magic) as the upper limit. This PR extends that behavior to also handle single iteration loops (thus it won't regress anything)

staticintGetCount()=>1;// e.g. static readonly field inited via an envvarstaticintTest(){intx=0;for(inti=0;i<GetCount();i++)x++;returnx;}

Current codegen forTest:

G_M58954_IG01:G_M58954_IG02:xoreax,eaxxoredx,edxG_M58954_IG03:inceaxincedxtestedx,edxjle      SHORT G_M58954_IG03G_M58954_IG04:ret

New codegen forTest:

G_M58954_IG02:moveax,1G_M58954_IG03:ret

jit-diff (-f --cctors --pmi):

(surprisingly, it's not empty)

Total bytes of delta: -352 (-0.00% of base)    diff is an improvement.Top file improvements (bytes):        -211 : System.Private.CoreLib.dasm (-0.00% of base)        -103 : Microsoft.CodeAnalysis.dasm (-0.01% of base)         -38 : Microsoft.Diagnostics.Tracing.TraceEvent.dasm (-0.00% of base)3 total files with Code Size differences (3 improved, 0 regressed), 265 unchanged.Top method improvements (bytes):        -103 (-12.50% of base) : Microsoft.CodeAnalysis.dasm - SmallDictionary`2:LeftComplex(AvlNode):AvlNode (8 base, 7 diff methods)         -66 (-12.69% of base) : System.Private.CoreLib.dasm - Vector64`1:Equals(Vector64`1):bool:this (6 methods)         -66 (-11.21% of base) : System.Private.CoreLib.dasm - Vector64`1:GetHashCode():int:this (6 methods)         -62 (-4.52% of base) : System.Private.CoreLib.dasm - Utf8Formatter:TryFormat(TimeSpan,Span`1,byref,StandardFormat):bool         -17 (-5.28% of base) : System.Private.CoreLib.dasm - Utf8Parser:TryParseByteX(ReadOnlySpan`1,byref,byref):bool         -14 (-24.56% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - FileVersionTraceData:get_FileDescription():String:this         -13 (-1.53% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - FileVersionTraceData:ToXml(StringBuilder):StringBuilder:this         -11 (-1.75% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - FileVersionTraceData:PayloadValue(int):Object:thisTop method improvements (percentages):         -14 (-24.56% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - FileVersionTraceData:get_FileDescription():String:this         -66 (-12.69% of base) : System.Private.CoreLib.dasm - Vector64`1:Equals(Vector64`1):bool:this (6 methods)        -103 (-12.50% of base) : Microsoft.CodeAnalysis.dasm - SmallDictionary`2:LeftComplex(AvlNode):AvlNode (8 base, 7 diff methods)         -66 (-11.21% of base) : System.Private.CoreLib.dasm - Vector64`1:GetHashCode():int:this (6 methods)         -17 (-5.28% of base) : System.Private.CoreLib.dasm - Utf8Parser:TryParseByteX(ReadOnlySpan`1,byref,byref):bool         -62 (-4.52% of base) : System.Private.CoreLib.dasm - Utf8Formatter:TryFormat(TimeSpan,Span`1,byref,StandardFormat):bool         -11 (-1.75% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - FileVersionTraceData:PayloadValue(int):Object:this         -13 (-1.53% of base) : Microsoft.Diagnostics.Tracing.TraceEvent.dasm - FileVersionTraceData:ToXml(StringBuilder):StringBuilder:this8 total methods with Code Size differences (8 improved, 0 regressed), 259114 unchanged.Completed analysis in 23.84

Example:Utf8Parser:TryParseByteX (ByteOverflowLengthHex = 2) - looks suspicious btw:

erozenfeld reacted with thumbs up emojitannergooding and pr8x reacted with heart emoji
@Dotnet-GitSync-BotDotnet-GitSync-Bot added the area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labelOct 28, 2020
@EgorBo
Copy link
MemberAuthor

@dotnet/jit-contrib PTAL

@AndyAyersMS
Copy link
Member

cc@BruceForstall

Copy link
Contributor

@BruceForstallBruceForstall left a comment

Choose a reason for hiding this comment

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

Question

Copy link
Contributor

@sandreenkosandreenko left a comment

Choose a reason for hiding this comment

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

LGTM, thank you.

@sandreenkosandreenko merged commit51393be intodotnet:masterNov 12, 2020
@ghostghost locked asresolvedand limited conversation to collaboratorsDec 12, 2020
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

2 more reviewers

@BruceForstallBruceForstallBruceForstall left review comments

@sandreenkosandreenkosandreenko approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@EgorBo@AndyAyersMS@BruceForstall@sandreenko@Dotnet-GitSync-Bot

[8]ページ先頭

©2009-2025 Movatter.jp