Skip to content

JIT: fix exception ordering in SIMD negation rewrite - #137523

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix/134895-preserve-simd-exception-order
Nov 14, 2026
Merged

AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:fix/134895-preserve-simd-exception-order

Conversation

@AndyAyersMS

@AndyAyersMS AndyAyersMS commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

fgOptimizeHWIntrinsic rewrites (-v1) - (-v2) to v2 - v1, which can reverse exception order when evaluating the operands. Guard the rewrite with gtCanSwapOrder and add a regression test that verifies the first operand's IndexOutOfRangeException is observed before the second operand's NullReferenceException.

Validation

  • .\build.cmd clr -rc Checked passed with 0 warnings and 0 errors.
  • src\tests\build.cmd -GenerateLayoutOnly x64 Checked passed.
  • The regression test passes with the fixed JIT and fails with the unfixed JIT as expected.

Resolves #134895

Note

This PR description was generated with GitHub Copilot.

Use gtCanSwapOrder before rewriting (-a) - (-b) as b - a, so the transform preserves operand evaluation order. Fixes dotnet#134895.

Co-authored-by: Copilot <[email protected]>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@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 Nov 14, 2026
@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.

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) (-v1) - (-v2) vector rewrite reorders side effects (wrong exception)

2 participants