Skip to content

Preserve side effects in SIMD classification helpers - #132921

Merged
tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-investigate-jit-issue-132902
Aug 31, 2026
Merged

tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-investigate-jit-issue-132902

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Fixes #132902

SIMD classification helpers that produce constant results now preserve side effects from their operands. This covers all nine affected classification operations rather than only the reported IsInfinity case.

Adds regression coverage using an exception-bearing Vector128.WithElement operand, which exercises the shared x64 and WASM import shape.

Note

This pull request was created with GitHub Copilot.

Copilot AI lite review requested due to automatic review settings August 29, 2026 17:01
@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 Aug 29, 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

Review tier: Lite
Findings: None

What changed in this PR

This PR fixes a JIT correctness issue where certain SIMD classification intrinsics could fold to a constant result and inadvertently drop operand side effects (notably exceptions). The fix wraps the folded constant results with extracted side effects from the operand, and adds a targeted regression test to ensure the operand is still evaluated.

Changes:

  • Update JIT SIMD classification helpers to preserve operand side effects when folding to constant results (e.g., integral-type cases).
  • Add a new JIT regression test that validates exception-bearing operands are not elided across nine classification operations.
  • Register the new regression test source file in the merged regression test project.
File Description
src/​coreclr/​jit/​gentree.cpp Wrap constant-folded SIMD classification results with extracted side effects from the operand to prevent eliding exceptions/calls.
src/​tests/​JIT/​Regression/​JitBlue/​Runtime_132902/​Runtime_132902.cs Adds regression coverage using Vector128.WithElement with an out-of-range index to ensure operand exceptions are preserved across classification intrinsics.
src/​tests/​JIT/​Regression/​Regression_ro_2.csproj Includes the new regression test in the merged JIT regression project build.

@tannergooding

Copy link
Copy Markdown
Member Author

/ba-g build monitor timeout

@tannergooding
tannergooding merged commit 23c1225 into dotnet:main Aug 31, 2026
140 of 142 checks passed
@tannergooding
tannergooding deleted the tannergooding-investigate-jit-issue-132902 branch August 31, 2026 16:51
@tannergooding

Copy link
Copy Markdown
Member Author

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@tannergooding backporting to release/11.0 failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git cherry-pick 23c122538691178f01ab0bcafc4c2e03e9da2bb6

Auto-merging src/coreclr/jit/gentree.cpp
Auto-merging src/tests/JIT/Regression/Regression_ro_2.csproj
CONFLICT (content): Merge conflict in src/tests/JIT/Regression/Regression_ro_2.csproj
error: could not apply 23c12253869... Preserve side effects in SIMD classification helpers (#132921)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"


$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Preserve side effects in SIMD classification helpers
Using index info to reconstruct a base tree...
M	src/coreclr/jit/gentree.cpp
M	src/tests/JIT/Regression/Regression_ro_2.csproj
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/jit/gentree.cpp
Auto-merging src/tests/JIT/Regression/Regression_ro_2.csproj
CONFLICT (content): Merge conflict in src/tests/JIT/Regression/Regression_ro_2.csproj
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Preserve side effects in SIMD classification helpers
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 1, 2026
JulieLeeMSFT pushed a commit that referenced this pull request Sep 1, 2026
…133016)

Fixes #132902

main PR #132921

# Description

Backports the fix that preserves operand side effects when SIMD
classification helpers fold to constant results. This covers all nine
affected classification operations.

# Customer Impact

Without this fix, the JIT can remove observable side effects, including
exceptions, from operands passed to SIMD classification APIs. Behavior
can differ depending on the compilation tier.

# Regression

No known regression in .NET 11.

# Testing

Built the checked CoreCLR runtime and the priority-1 `Regression_ro_2`
project. The checked consolidated regression shard passed, including all
nine `Runtime_132902` cases. `jit-format` completed successfully for
Windows x64.

# Risk

Low. The change is limited to preserving side effects on existing
constant-folding paths by using the established `gtWrapWithSideEffects`
helper. Regression coverage exercises every affected classification
operation.

# 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.

Co-authored-by: Copilot App <[email protected]>
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 1, 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.

IsInfinity can drop throwing side effects

3 participants