Skip to content

Remove ArrLen propagation from earlyprop#116410

Merged
EgorBo merged 2 commits intodotnet:mainfrom
EgorBo:early-prop-cleanup
Jun 10, 2025
Merged

Remove ArrLen propagation from earlyprop#116410
EgorBo merged 2 commits intodotnet:mainfrom
EgorBo:early-prop-cleanup

Conversation

@EgorBo
Copy link
Copy Markdown
Member

@EgorBo EgorBo commented Jun 8, 2025

It looks unnecessary given all downstream phases are fine with just Value Numbering

Diffs

@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 Jun 8, 2025
@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.

@hez2010
Copy link
Copy Markdown
Contributor

hez2010 commented Jun 8, 2025

I remember the ArrLen early propagation also contributes to loop optimizations like unrolling, which happens before VN.

@EgorBo
Copy link
Copy Markdown
Member Author

EgorBo commented Jun 8, 2025

I remember the ArrLen early propagation also contributes to loop optimizations like unrolling, which happens before VN.

Loop unrolling happens before early prop

@EgorBo EgorBo force-pushed the early-prop-cleanup branch from c55facc to 6cb229d Compare June 8, 2025 20:27
@EgorBo EgorBo marked this pull request as ready for review June 8, 2025 22:12
Copilot AI review requested due to automatic review settings June 8, 2025 22:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes the array length propagation feature from the early propagation phase and cleans up related debugging and null-check folding logic. Key changes include:

  • Removal of the SSA-based array length propagation and associated debugging/SSA update code.
  • Updating constant range checks to use CORINFO_Array_MaxLength instead of INT32_MAX.
  • Refactoring the null-check folding functions and the signature of optCanMoveNullCheckPastTree to remove an unused parameter.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/coreclr/jit/earlyprop.cpp Removed array length propagation code and refactored debug output and null-check handling.
src/coreclr/jit/compiler.h Updated function signature for optCanMoveNullCheckPastTree to match the refactored implementation.
Comments suppressed due to low confidence (2)

src/coreclr/jit/earlyprop.cpp:217

  • The change from INT32_MAX to CORINFO_Array_MaxLength for the upper bound check is a critical update; please verify that CORINFO_Array_MaxLength is defined consistently and used appropriately across all relevant platforms.
if ((actualConstVal < 0) || (actualConstVal > CORINFO_Array_MaxLength))

src/coreclr/jit/earlyprop.cpp:262

  • The removal of the tree cloning, SSA updates, and the associated constant propagation logic in optEarlyPropRewriteTree significantly changes the propagation strategy; please ensure that the updated value numbering phase fully addresses the necessary optimizations.
JITDUMP("optEarlyProp Rewriting " FMT_BB "\n", compCurBB->bbNum);

@EgorBo
Copy link
Copy Markdown
Member Author

EgorBo commented Jun 9, 2025

PTAL @jakobbotsch @dotnet/jit-contrib a few diffs

I've removed GT_ARR_LENGTH forward substitution (SSA-based) from early-prop, the diffs imply it was not useful anyway. Also, removed a few dead vars/args.

There is still a big chunk of code in the early prop responsible for constant-folding of GT_BOUNDS_CHECK (when index is constant and the length is constant at its SSA def).

@EgorBo EgorBo requested a review from jakobbotsch June 9, 2025 06:27
@am11

This comment was marked as off-topic.

@EgorBo

This comment was marked as off-topic.

@EgorBo EgorBo merged commit efa2f54 into dotnet:main Jun 10, 2025
110 checks passed
@EgorBo EgorBo deleted the early-prop-cleanup branch June 10, 2025 14:32
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 11, 2025
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants