Skip to content

Fix SIMD primitive zero initialization - #133100

Open
tannergooding wants to merge 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-fix-issue-133085
Open

Fix SIMD primitive zero initialization#133100
tannergooding wants to merge 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-fix-issue-133085

Conversation

@tannergooding

Copy link
Copy Markdown
Member

TryPrimitiveInit created a SIMD zero node when converting a zero block initialization into a primitive local store, but the rationalized store retained its original integer-zero data node. This produced a SIMD store with an integer source, leading to invalid codegen and Tier0 compilation failures.

The missing source replacement was introduced by the assignment rationalization changes in #85585 (53b4cd0912d), where the legacy GT_ASG path updated gtOp2 but the rationalized store path did not update Data().

Before the fix, the Vector256 case encoded C4 E1 FD 6E C0 (vmovq with VEX.L=1). The corrected tree emits a SIMD zero (vxorps) in both FullOpts and Tier0. Regression coverage includes Vector128 and Vector256 in both modes.

Fixes #133085

Note

This pull request description was generated with GitHub Copilot.

Ensure block morphing replaces the integer zero source with the newly created SIMD zero node.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 2, 2026 16:05
@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 2, 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

🟢 Approval recommended

The fix is a minimal, localized correctness change (updating the store operand to match the new SIMD zero node) with targeted regression coverage added.

Review tier: Lite
Findings: None

What changed in this PR

This PR fixes a CoreCLR JIT morphing bug where TryPrimitiveInit could retarget an init-block into a SIMD-typed store but leave the store’s Data() operand pointing at the original integer zero constant, producing an invalid SIMD store source and causing Tier0/FullOpts failures. The change updates the rationalized store node to use the newly created SIMD zero constant and adds a JIT regression test covering Vector128 and Vector256 under both Tier0 and FullOpts behavior.

Changes:

  • Fix MorphInitBlockHelper::TryPrimitiveInit to replace the store’s Data() operand when creating a SIMD zero source.
  • Mark the newly created SIMD zero node as morphed to match surrounding morph-phase conventions.
  • Add a JitBlue regression test project validating Vector128<ulong> and Vector256<ulong> zero-init through Unsafe.As<,>() under tiered compilation.
File Description
src/​coreclr/​jit/​morphblock.cpp Updates primitive-init morphing to keep store Data() consistent with a newly created SIMD zero node.
src/​tests/​JIT/​Regression/​JitBlue/​Runtime_133085/​Runtime_133085.csproj Adds a new isolated JIT regression test project with tiered compilation enabled.
src/​tests/​JIT/​Regression/​JitBlue/​Runtime_133085/​Runtime_133085.cs Adds regression coverage for SIMD local zero-init via initobj-equivalent patterns for Vector128/256.

@tannergooding

Copy link
Copy Markdown
Member Author

CC. @EgorBo, @jakobbotsch for review. This will need backport to .NET 11 and 10

Fairly old issue and it likely hasn't been hit before due to the exact pattern required to trigger it being a bit unlikely.

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

2 participants