Skip to content

Canonicalize unused field addresses and length reads - #136738

Open
NinoFloris wants to merge 5 commits into
dotnet:mainfrom
NinoFloris:jit/discard-unused-local-addresses
Open

NinoFloris wants to merge 5 commits into
dotnet:mainfrom
NinoFloris:jit/discard-unused-local-addresses

Conversation

@NinoFloris

@NinoFloris NinoFloris commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Canonicalize unused instance field addresses and array/string length reads to receiver null checks in gtExtractSideEffectsFromUnusedNode, sharing the existing GetType handling. This preserves operand evaluation and exceptions, and lets local morph discard checks on known local addresses before they cause address exposure.

Unblocks switching to the subtraction-based Slice check discussed in #119689. Adds disassembly coverage for redundant Slice bounds-check elimination and unused array-length normalization, plus null-exception tests for field, array, and string reads.

@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 30, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 30, 2026
@azure-pipelines

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

@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.

@EgorBo

EgorBo commented Oct 31, 2026

Copy link
Copy Markdown
Member

I think we can just handle FIELD_ADDR in gtExtractSideEffectsFromUnusedNode to convert it into a nullcheck - same diffs (even more slightly)

@NinoFloris
NinoFloris force-pushed the jit/discard-unused-local-addresses branch from 608d8d1 to 896d307 Compare October 31, 2026 18:30
@NinoFloris NinoFloris changed the title Discard unused local addresses during local morph Canonicalize unused field addresses and length reads Oct 31, 2026
@NinoFloris

Copy link
Copy Markdown
Contributor Author

Missed context on linux x64 btw. I don't have an x64 machine ready to check what caused it.

Comment thread src/coreclr/jit/gentree.cpp Resolved
@NinoFloris

Copy link
Copy Markdown
Contributor Author

@JulieLeeMSFT gentle nudge. I can't merge this myself.

@jakobbotsch

Copy link
Copy Markdown
Member

This looks like it results in overall regressions on arm64 in the non-test collections. Have you investigated some of those cases?

@NinoFloris

This comment was marked as outdated.

Reduce unused instance FIELD_ADDR and ARR_LENGTH nodes to their receiver
null checks during side-effect extraction, sharing the existing GetType
handling and preserving operand evaluation.

This lets local morph discard checks on known local addresses before they
cause address exposure. Add Slice bounds-check and unused-length codegen
coverage, along with null-exception tests.
@NinoFloris
NinoFloris force-pushed the jit/discard-unused-local-addresses branch from 2823739 to 34638c8 Compare November 23, 2026 11:37
Track null checks on a local plus a constant offset during early propagation. A load or store at the same offset from the same SSA local can take the fault when the existing ordering checks allow it.
Set the dword width when lowering selects a register-addressed null check. Codegen can then emit the comparison using the node type.
A byte probe only needs to fault. Zero-extension lets Thumb use its 16-bit immediate-offset load when the registers and offset fit.
@NinoFloris
NinoFloris force-pushed the jit/discard-unused-local-addresses branch from fd9cedd to 85a2174 Compare November 24, 2026 10:52

This branch has not been deployed

No deployments
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 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.

4 participants