Skip to content

[release/11.0] Fix SIMD MinMax constant special cases - #133256

Open
tannergooding wants to merge 1 commit into
dotnet:release/11.0from
tannergooding:backport-133173-release-11.0
Open

[release/11.0] Fix SIMD MinMax constant special cases#133256
tannergooding wants to merge 1 commit into
dotnet:release/11.0from
tannergooding:backport-133173-release-11.0

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Backport of #133173 to release/11.0

/cc @AndyAyersMS

Customer Impact

  • Customer reported
  • Found internally

SIMD Min, Max, MinNumber, and MaxNumber can return incorrect results on xarch when a constant vector contains a mix of ordinary values and NaN or signed-zero lanes. The AVX-512 path can incorrectly return the opaque operand wholesale.

Regression

  • Yes
  • No

The vector mixed-lane regression was introduced by #116804 during .NET 10 development.

Testing

The focused Runtime_133022 regression fails against the pre-fix JIT and passes with the fix. The original change was verified on checked x64 and x86 with AVX-512 enabled and with DOTNET_EnableAVX512=0; all 13,082 System.Runtime.Intrinsics tests also passed under both AVX-512 settings.

For this backport, the checked x64 JIT build and jit-format passed. The source patch matches the merged change; the test-project conflict was resolved by adding only Runtime_133022 to the target branch's merged regression project. A full clr+libs baseline was attempted but hit unrelated MSVC C1041 PDB contention in System.Globalization.Native.

Risk

Medium. The change is localized to JIT import-time SIMD constant classification and fixup-table construction, but affects shared Min/Max code generation. Mixed NaN and signed-zero cases are covered across float/double, Vector128/Vector256, operand order, and AVX-512 enabled/disabled configurations.

IMPORTANT: If this backport is for a servicing release, please verify that:

  • For .NET 8 and .NET 9: The PR target branch is release/X.0-staging, not release/X.0.
  • For .NET 10+: The PR target branch is release/X.0 (no -staging suffix).

Package authoring no longer needed in .NET 9

IMPORTANT: Starting with .NET 9, you no longer need to edit a NuGet package's csproj to enable building and bump the version.
Keep in mind that we still need package authoring in .NET 8 and older versions.

Note

This pull request description was generated with GitHub Copilot assistance.

SIMD Min/Max constant handling used whole-vector checks for NaN and
signed zero when deciding whether native xarch Min/Max needed
compensation. Constants containing a mix of ordinary and special lanes
could therefore lose the managed NaN or signed-zero semantics.
This evaluates the predicates through reusable SIMD mask helpers
matching `IsNaN`/`IsNegative` and
`AnyWhereAllBitsSet`/`AllWhereAllBitsSet`, then uses any-lane checks for
fast-path eligibility.
Fixesdotnet#133022
> [!NOTE]
> This pull request was created with GitHub Copilot.
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
CopilotAI lite review requested due to automatic review settings September 4, 2026 19:23
@tannergoodingtannergooding added Servicing-consider Issue for next servicing release review area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Sep 4, 2026
@azure-pipelines

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

CopilotAI 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

It changes JIT SIMD min/max import-time semantics and fixup generation in a way that can have broad codegen impact across xarch, warranting final human validation for the backport.

Review tier: Lite
Findings: None

What changed in this PR

Backport that fixes xarch SIMD Min/Max/MinNumber/MaxNumber constant-vector special-case handling for mixed-lane NaN and signed-zero semantics by switching from whole-vector checks to per-lane mask evaluation, and adds regression coverage.

Changes:

  • Update JIT SIMD constant evaluation helpers to support per-lane mask/predicate evaluation over the active SIMD size.
  • Refine xarch SIMD min/max import-time constant classification, operand ordering, and AVX-512 fixup-table construction to correctly handle mixed NaN / signed-zero lanes.
  • Add a focused JIT regression test and expand generic-math test data to cover NaN payload + signed-zero interactions.
FileDescription
src/​coreclr/​jit/​simd.hAdds SIMD-size-aware evaluation helpers and predicates used for per-lane special-case detection.
src/​coreclr/​jit/​gentree.hExtends GenTreeVecCon with helpers to detect NaN / ±0 presence in vector constants.
src/​coreclr/​jit/​gentree.cppUses new per-lane predicates to drive operand ordering and fixup-table generation for SIMD min/max.
src/​libraries/​Common/​tests/​System/​GenericMathTestMemberData.csAdds NaN-payload test inputs and new cases involving NaN and signed zero for min/max variants.
src/​tests/​JIT/​Regression/​JitBlue/​Runtime_133022/​Runtime_133022.csAdds regression coverage for mixed-lane NaN and signed-zero behavior across vector widths and variants.
src/​tests/​JIT/​Regression/​Regression_ro_2.csprojIncludes the new regression test in the merged regression project.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIServicing-considerIssue for next servicing release review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@tannergooding@AndyAyersMS