Skip to content

JIT: Preserve SIMD operand order before morph - #134634

Merged
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:tannergooding-pr-134464-feedback-fix
Sep 25, 2026
Merged

tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:tannergooding-pr-134464-feedback-fix

Conversation

@tannergooding

Copy link
Copy Markdown
Member

ConcatUpperUpper and variable-index shuffle creation swap SIMD operands to match hardware encodings. Marking those imported trees with GTF_REVERSE_OPS does not preserve source evaluation order through morph, which can use a later operand's null check to eliminate a check needed by an earlier call.

Use gtPrepareOperandsForReordering to sequence the original first operand via a temp and GT_COMMA only when reordering is observable. This also covers shuffles expanded during rationalization, before tree threading switches to LIR. Retain the existing SIMD instruction shapes and assert that HW intrinsics enter morph without a reverse flag. This is a focused follow-up to #134464.

Validation: x64, x86, and ARM64 Debug JIT builds; JIT formatting; three targeted tests pass normally, with MinOpts, AVX2 disabled, hardware intrinsics disabled, and JitStress2. The full merged regression runner reports 423 passed, 0 failed, 7 skipped. Delayed shuffle codegen matches the reverse-flag implementation instruction-for-instruction in the measured 256- and 512-bit cases.

Resolves #134334

Note

This PR description and implementation were prepared with GitHub Copilot assistance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding
tannergooding requested review from jakobbotsch and a lite review from Copilot September 25, 2026 02:43
@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 25, 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.

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

🔵 Needs a closer look

The morph-time assertion may fail when a reverse-flagged HW intrinsic is remorphed.

Review effort: Lite
Findings: None

What changed in this PR

This PR preserves SIMD operand evaluation order during JIT morphing while retaining existing instruction shapes.

Changes:

  • Sequences reordered operands with temporaries and GT_COMMA.
  • Adds a morph-time HW intrinsic invariant assertion.
  • Adds regression coverage for concat and shuffle ordering.
File Description
src/​tests/​JIT/​Regression_ro_2/​Runtime_134334.cs Adds concat and shuffle evaluation-order regressions.
src/​coreclr/​jit/​morph.cpp Adds the reverse-flag assertion for HW intrinsics.
src/​coreclr/​jit/​gentree.cpp Applies safe SIMD operand sequencing.

Allow remorph to encounter reordered intrinsics and keep CoreCLR-only regression tests off Mono.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 25, 2026 05:18

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

🔵 Needs a closer look

Add the documented GTF_REVERSE_OPS invariant assertion at morph entry.

Review effort: Lite
Findings: None

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.

JIT: morph's HW intrinsic operand walk ignores GTF_REVERSE_OPS, eliding a null check before its side effect

3 participants