Fix vector complement-add folding for floating-point types - #133539
Fix vector complement-add folding for floating-point types#133539tannergooding wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The fix is a small, well-scoped correctness change in the JIT morph optimization and is backed by a targeted regression that reproduces the reported incorrect floating-point folding.
Review tier: Lite
Findings: None
What changed in this PR
This PR fixes a JIT HWIntrinsic morph optimization that was incorrectly folding (~v) + 1 into -v for floating-point SIMD vectors (and skipping the intended integral-only transform). It updates the guard to only apply the fold for integral SIMD base types and adds a regression test that validates the floating-point behavior.
Changes:
- Restrict the
(~v) + 1→-vfolding infgOptimizeHWIntrinsicto integral SIMD base types. - Simplify xarch
SetMorphedhandling for the newly created negation node in the integral-only path. - Add a focused JIT regression test covering
Vector128<float>,Vector128<double>, andVector128<int>.
| File | Description |
|---|---|
| src/coreclr/jit/morph.cpp | Fixes the folding guard so (~v) + 1 is only rewritten for integral SIMD base types. |
| src/tests/JIT/Regression/JitBlue/Runtime_133522/Runtime_133522.cs | Adds a regression asserting correct floating-point ~v + 1 semantics and a basic integer check. |
| src/tests/JIT/Regression/Regression_ro_2.csproj | Includes the new regression test in the merged regression project. |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The JIT fix is narrowly scoped to the documented invalid fold for floating-point SIMD and is backed by a focused regression test that would fail on the buggy behavior.
Review tier: Lite
Findings: None
Restrict
(~v) + 1folding to integral SIMD base types. The guard was inverted, incorrectly replacing floating-point complement-and-add with negation while excluding the valid integer transform.Add a focused regression covering
Vector128<float>,Vector128<double>, andVector128<int>.Fixes #133522.
Note
This PR was prepared with GitHub Copilot.