Repository navigation
Fix unsigned vector division correction lane width - #134362
Merged
tannergooding merged 1 commit intoSep 22, 2026
Merged
tannergooding merged 1 commit into
tannergooding merged 1 commit into
Conversation
Co-authored-by: Copilot App <[email protected]>
|
Azure Pipelines: Successfully started running 6 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. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved blocking issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Fixes incorrect unsigned SIMD vector division correction by selecting quotient corrections independently per 32-bit lane.
Changes:
- Replaces
blendvpdwithblendvpsin AVX and SSE4.1 paths. - Updates blend-mask register documentation.
- Adds
Vector128<uint>andVector256<uint>regression tests.
| File | Description |
|---|---|
src/tests/JIT/Regression_ro_2/Runtime_133752.cs |
Adds focused unsigned division regressions. |
src/coreclr/jit/lsraxarch.cpp |
Updates blend instruction allocation commentary. |
src/coreclr/jit/hwintrinsiccodegenxarch.cpp |
Corrects quotient correction to use 32-bit lanes. |
EgorBo
approved these changes
Sep 21, 2026
Member
Author
|
/backport to release/11.0 Note Backport requested through GitHub Copilot at the maintainer's direction. |
Contributor
|
Started backporting to |
2 of 4 tasks
JulieLeeMSFT
pushed a commit
that referenced
this pull request
Oct 12, 2026
…34421) Backport of #134362 to `release/11.0`. ## Customer Impact - [ ] Customer reported - [x] Found internally Reported in #133752 with a focused JIT repro; no production customer incident is documented in that report. On x86/x64 unsigned-vector division paths without AVX-512, `Vector128<uint>` and `Vector256<uint>` can silently return incorrect results when a quotient reaches `2^31`. The correction can also overwrite an adjacent lane whose quotient was already correct. For example, `<uint.MaxValue, 9, 1, 1> / <1, 3, 1, 1>` should produce `<4294967295, 3, 1, 1>`, but produces `<2147483648, 3, 1, 1>`. This affects the AVX/AVX2 and legacy SSE4.1 fallback paths; AVX-512 and software-fallback controls are unaffected. The fix replaces the two final quotient-correction `blendvpd` instructions with `blendvps`, so selection operates on the packed 32-bit quotient lanes rather than pairs of lanes. The earlier double-precision input correction remains unchanged. ## Regression - [x] Yes - [ ] No Introduced during .NET 11 development by #117996, commit `be7db811e5d11f176ecad493bb623e22985e7a85`, merged September 15, 2025. That change extended SIMD integer division to unsigned and smaller integer types and introduced both incorrect correction blends. The .NET 10.0.0 source only imports this integer-division path for signed `int`, not `uint`; the introducing commit is not in the .NET 10.0.0 release ancestry. This version assessment is based on source/history inspection, not execution on .NET 10. ## Testing On the main-branch implementation, built Checked and Release JITs on Windows x64. Both added regression tests fail without the fix under AVX2, AVX-only, and SSE4.1, and pass with the fix. AVX-512 and software-fallback controls pass before and after. Verified that both tests actually executed using the test-result XML. The focused regressions cover the reported 128-bit and 256-bit inputs, quotients below/at/above the signed-conversion boundary, and neighboring lanes requiring different corrections. Ordinary small quotients do not expose the error, and the AVX-512 path bypasses the faulty correction; the new cases explicitly exercise those missing conditions. An additional scratch audit passed 16,314 vector comparisons across five ISA configurations, covering related integer division, conversion boundaries, and mixed-mask selection. Disassembly comparisons showed only the intended blend-opcode changes, with unchanged instruction counts and code size. Local BenchmarkDotNet timing intervals overlapped; no throughput improvement is claimed. The Windows x64 JIT formatting check passed. The bot-created backport was inspected and contains the same two opcode fixes, explanatory comments, and focused regression tests. The release/11.0 backport has not been built or executed locally; the execution results above are from main. x86 and non-Windows execution were not tested locally. ## Risk Low. The executable change is limited to two blend opcodes in the non-AVX-512 unsigned quotient correction. It corrects selection granularity without changing register allocation, instruction count, code size, public APIs, or the double-precision input conversion. Focused before/after regressions cover both affected emission paths, and AVX-512/software controls confirm unaffected paths retain their results. The backport introduces no additional implementation changes. **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). Verified: this PR targets `dotnet/runtime:release/11.0`. ## 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. No package-authoring changes are needed for this .NET 11 JIT fix. Resolves #133752 > [!NOTE] > This servicing assessment was drafted with GitHub Copilot. Co-authored-by: Tanner Gooding <[email protected]> Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
blendvpsinstead ofblendvpdfor the final unsigned quotient correction in both the AVX and SSE4.1 division paths.The fallback computes quotients as doubles, then converts them to packed 32-bit integers with
cvttpd2dq. Quotients at or above2^31produce the signed conversion's overflow sentinel. For nonzerouintdivisors, those quotients require a divisor of 1, so the correction selects the original dividend. That selection must operate independently on each 32-bit lane; the previous 64-bit blend could miss an overflowing lane or incorrectly replace its neighbor. The earlier unsigned-input-to-double correction still correctly usesblendvpd.Add focused
Vector128<uint>andVector256<uint>regressions covering the reported inputs, the signed-conversion boundary, and differing correction masks in neighboring lanes.Validation
Resolves #133752
Note
This pull request description was drafted with GitHub Copilot.