Skip to content

JIT: Include auxiliary types in hardware intrinsic value numbering - #134518

Merged
tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-fix-intrinsic-value-numbering
Sep 23, 2026
Merged

tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-fix-intrinsic-value-numbering

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Hardware intrinsic value numbering omitted the auxiliary type even when it changes the operation's semantics. For example, AVX2 gathers using the same index bits as int and long indices received the same liberal VN, allowing the JIT to incorrectly fold a comparison of their different results.

Pack the auxiliary type into the upper byte of the existing SIMD base-type constant and update decoding and diagnostic output. SimdType retains two operands, and intrinsics without an auxiliary type retain their original type constant, avoiding an additional VN argument and constant lookup. A compile-time assertion bounds the encoding.

Add focused regressions for gather index width on xarch and saturating-add operand signedness on Arm64.

Validation: checked native and cross-target JIT builds; 368 regression tests passed; the gather repro fails against the baseline and passes with the fix, including under JitStress2; JIT formatting passed. Arm64 crossgen2 output preserves distinct sqadd and suqadd instructions, but the Arm64 test was not executed on matching hardware.

Resolves #134486

Note

This PR description and changes were prepared with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 23, 2026 13:33
Copilot stopped reviewing on behalf of tannergooding due to an error September 23, 2026 13:34
@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 23, 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.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

This PR updates JIT value numbering for HW intrinsics to distinguish overloads that share the same operand bits (via an “auxiliary type” encoded into the SIMD type VN) and adds a regression test to validate the behavior for gather and AddSaturateScalar.

Changes:

  • Encode an additional auxiliaryType into VNF_SimdType value numbers and update related decoding/dumping.
  • Update HW intrinsic value numbering to incorporate GetAuxiliaryType() into the result type VN.
  • Add a JIT regression test covering AVX2 gather index width and Arm64 AddSaturateScalar overload distinction.
File Description
src/​tests/​JIT/​Regression_ro_2/​Runtime_134486.cs Adds regression coverage to catch incorrect VN/CSE across intrinsic overloads.
src/​coreclr/​jit/​valuenum.h Introduces SIMD type encoding constants and extends the VNForSimdType API to accept an auxiliary type.
src/​coreclr/​jit/​valuenum.cpp Implements auxiliary-type encoding/decoding, updates simd-type dumping, and uses auxiliary type for HW intrinsic VNs.

Comment thread src/coreclr/jit/valuenum.cpp
Comment thread src/coreclr/jit/valuenum.h
Comment thread src/coreclr/jit/valuenum.h
Comment thread src/coreclr/jit/valuenum.cpp
@tannergooding
tannergooding merged commit 5b82fc4 into dotnet:main Sep 23, 2026
143 of 146 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 24, 2026
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: (bug) VN ignores HWIntrinsic auxiliary type, so Avx2.GatherVector128 with int and long indices is treated as equal

3 participants