Fix Vector2 and Vector3 comparison reductions - #133044
Open
tannergooding wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
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. |
vcsjones
approved these changes
Sep 1, 2026
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-numerics |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Review tier: Lite
Findings: None
What changed in this PR
This PR corrects Vector2/Vector3 strict GreaterThanAny/LessThanAny reductions to avoid false positives caused by comparing a full Vector128 result against a mask that includes zero padding lanes. It switches to the dedicated Vector128.*Any/*All reduction helpers and adds regression tests to ensure padding lanes and NaN behavior don’t corrupt results.
Changes:
- Fix
Vector2/Vector3strictGreaterThanAnyandLessThanAnyto useVector128.GreaterThanAny/Vector128.LessThanAny. - Simplify inclusive
GreaterThanOrEqualAll/LessThanOrEqualAllto useVector128.*Allreductions directly. - Add/extend unit tests to cover padding-lane-sensitive false positives and
NaNbehavior for inclusiveAll.
| File | Description |
|---|---|
| src/libraries/System.Private.CoreLib/src/System/Numerics/Vector3.cs | Uses Vector128.*Any/*All reduction helpers to avoid padding-lane false positives. |
| src/libraries/System.Private.CoreLib/src/System/Numerics/Vector2.cs | Same reduction change for Vector2 comparisons. |
| src/libraries/System.Numerics.Vectors/tests/Vector3Tests.cs | Adds regression coverage for strict Any and extends inclusive All tests with padding/NaN cases. |
| src/libraries/System.Numerics.Vectors/tests/Vector2Tests.cs | Adds regression coverage for strict Any and extends inclusive All tests with padding/NaN cases. |
This was referenced Sep 2, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Vector2andVector3strictAnycomparisons incorrectly returnedtruewhen no logical lanes matched because zero-filled padding lanes matched zero entries in the validity mask. Use the directVector128comparison reductions, which the JIT expands to the canonical comparison forms, and simplify the inclusiveAllreductions similarly.Add coverage for padding-sensitive outcomes and NaN in every valid lane.
Note
This pull request was created with GitHub Copilot.