Skip to content

JIT: expand multi-dimensional array intrinsics for large and struct elements - #131750

Draft
jakobbotsch with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-ios-coreclr-performance-issue
Draft

JIT: expand multi-dimensional array intrinsics for large and struct elements#131750
jakobbotsch with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-ios-coreclr-performance-issue

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

On platforms without a JIT (e.g. iOS with R2R), a multi-dimensional array access that impArrayAccessIntrinsic declines to expand becomes a real call to the Array intrinsic method, which falls back to the interpreter. Two of those bailouts are unnecessary.

Widen gtArrElemSize

GenTreeArrElem::gtArrElemSize was an unsigned char, so the importer bailed out whenever the element size exceeded 255 bytes. The field (and the constructor parameter) is now unsigned, and the FitsIn<unsigned char> check is removed. All consumers already read it into an unsigned.

Support struct-typed NI_Array_Set

a[i, j, k] = someStruct was rejected as an implementation limitation. It is now imported the same way CEE_STOBJ is:

case NI_Array_Set:
    if (varTypeIsStruct(elemType))
    {
        arrElem = gtNewStoreValueNode(elemLayout, arrElem, val);
        arrElem = impStoreStruct(arrElem, CHECK_SPILL_ALL);
    }
    else
    {
        arrElem = gtNewStoreIndNode(elemType, arrElem, val);
    }
    break;

Value-type arrays are invariant, so the covariance check that guards the varTypeIsGC path is not needed here.

Test

JIT/Regression/JitBlue/Runtime_131371 covers get/set/address on rank-2 and rank-3 arrays for a small struct, a 304-byte struct, and a 304-byte struct containing a GC reference, plus bounds-check behavior.

For a 304-byte element type, SetLarge now imports as STORE_BLK struct<LargeStruct, 304> over an ARR_ELEM[,,] instead of emitting a call. Validated on linux-x64 under JitStress 1/2/0x1F/0x3F and GCStress=0xC; existing JIT/Methodical groups (which include the MDArray tests) pass. Not exercised on arm64 or iOS.

Copilot AI review requested due to automatic review settings August 3, 2026 14:30

Copilot AI 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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
16 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 3, 2026 14:38

Copilot AI 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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

@jkotas jkotas added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed area-VM-coreclr labels Aug 3, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

…lements

Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 3, 2026 15:00

Copilot AI 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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

Copilot AI changed the title [WIP] Fix CoreCLR performance issue causing FPS drop in iOS game JIT: expand multi-dimensional array intrinsics for large and struct elements Aug 3, 2026
Copilot AI requested a review from jakobbotsch August 3, 2026 15:01

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.

@copilot This should not be a regression test, look for another place to add this. Perhaps under src/tests/JIT/opt somewhere.

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.

Moved to src/tests/JIT/opt/MDArray/MDArrayIntrinsicExpansion.cs (with its own csproj, picked up by the JIT.opt merged wrapper) in 3d24d3d. Note: I did not rebuild/run the test after the move — no coreclr artifacts in this environment.

Note

This reply was generated by GitHub Copilot.

Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 3, 2026 15:27

Copilot AI 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.

Copilot was unable to review this pull request because there is no eligible user to bill. To allow Copilot reviews on bot-authored pull requests, enable direct organization billing in your organization's Copilot settings.

@build-analysis build-analysis Bot mentioned this pull request Aug 3, 2026
3 tasks
@AndyAyersMS

Copy link
Copy Markdown
Member

If we're going to do this we might also want to consider #129455.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

[iOS] CoreCLR R2R is dramatically slower than Mono AOT: 60 FPS drops to 7.4 FPS in real-time game rendering

5 participants