Skip to content

JIT: Slow spills to stack in a loop on Linux vs Windows #58522

Description

@EgorBo

The following program (reported by @WhiteBlackGoose):

publicclassProgram{structRangeEnumerator{privatereadonlyintto;privatereadonlyintstep;privateintcurr;publicboolMoveNext(){curr+=step;returncurr!=to;}publicintCurrent=>curr;}staticintEnumerateItAll(RangeEnumeratorenumerator){vara=0;while(enumerator.MoveNext())a+=enumerator.Current;returna;}}

here is the assembly diff for EnumerateItAll method between Win-x64 and Linux-x64: https://www.diffchecker.com/NorefcMS
Windows one looks much better and there are no spills in the Loop body leading to much better performance.
I've not investigated this one yet - from my understanding RangeEnumerator is passed by stack on win-x64 ABI and via registers on lin-x64. Is there anything we can do here for Linux or it's a dup for some "first class structs promotion" issue? cc @dotnet/jit-contrib @kunalspathak

category:cq
theme:stack-allocation

Metadata

Metadata

Assignees

Labels

Priority:2Work that is important, but not critical for the releasearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMItenet-performancePerformance related issue

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions