Skip to content

[JIT] Rationalize: Re-run pre-order processing on identity shuffle rewrite in PreOrderVisit - #134910

Merged
adamperlin merged 8 commits into
dotnet:mainfrom
adamperlin:adamperlin/fix-rewrite-hw-intrinsic-user-call
Oct 20, 2026
Merged

adamperlin merged 8 commits into
dotnet:mainfrom
adamperlin:adamperlin/fix-rewrite-hw-intrinsic-user-call

Conversation

@adamperlin

@adamperlin adamperlin commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #133787; This case comes up with IR that looks like the following:

STOREIND simd16
├── LCL_VAR V00 RetBuf
└── HWINTRINSIC Shuffle                         [000022]
    ├── HWINTRINSIC ShiftRightLogical128BitLane [000020]
    │   ├── IND simd16
    │   │   └── LCL_VAR V01 arg0
    │   └── CAST int <- ubyte
    │       └── LCL_VAR V02 arg1
    └── CNS_VEC <0, 1, 2, ..., 15>              [000016]

The outer shuffle is the identity, so it is folded away as part of RewriteHwIntrinsicAsUserCall during PreOrderVisit. The inner ShiftRightLogical128BitLane -- which needs to be re-written back to a GT_CALL since it has a non-constant arg -- is the replacement node, but it is never processed by the preorder visitor. If we get back a different node from Rewrite*Intrinsic, we should re-do the processing logic on that new node.

adamperlin and others added 2 commits September 29, 2026 17:35
The replacement loop exits only after node and *use are equal, so the ARM64-specific reload is unnecessary. Also remove trailing whitespace from the adjacent comment.

Co-authored-by: Copilot App <[email protected]>
@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 Sep 30, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 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.

@adamperlin

adamperlin commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@dotnet/jit-contrib PTAL
cc @EgorBo

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 review overview

🟡 Changes recommended

The reported Checked-build regression needs a targeted test to prevent recurrence.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes JIT rationalization so replacement intrinsic nodes receive pre-order processing.

Changes:

  • Repeats intrinsic rewriting until the node remains unchanged.
  • Ensures nested deferred hardware intrinsics are converted to user calls.
File Description
src/​coreclr/​jit/​rationalize.cpp Reprocesses rewritten intrinsic nodes during rationalization.

Comment thread src/coreclr/jit/rationalize.cpp Resolved
Comment thread src/coreclr/jit/rationalize.cpp Resolved
@adamperlin adamperlin changed the title [JIT] Rationalize: Re-run pre-order processing if a node is re-written in PreOrderVisit [JIT] Rationalize: Re-run pre-order processing on identity shuffle rewrite in PreOrderVisit Oct 5, 2026
@adamperlin

Copy link
Copy Markdown
Contributor Author

@EgorBo can you give this one another look?

@adamperlin
adamperlin requested a review from EgorBo October 20, 2026 00:47
@adamperlin
adamperlin merged commit 8ea4383 into dotnet:main Oct 20, 2026
134 of 141 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 21, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 21, 2026
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.

JIT: (bug) Assertion failed '!node->IsUserCall()' during 'Rationalize IR' with an identity Vector128.Shuffle

5 participants