Repository navigation
Re-enable Half modulus negative-zero tests - #131290
Merged
tannergooding merged 1 commit intoJul 24, 2026
Merged
Conversation
The disabled cases in HalfTests.op_ModulusTest were a workaround for a non-deterministic sign-of-zero loss in float remainder on a 2022 Windows toolset (dotnet#67993). The equivalent float, double, and NFloat cases are already enabled, and the current runtime deterministically returns -0. Also fixes the stale PositiveTwo reference to use Two. Co-authored-by: Copilot App <[email protected]>
|
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. |
Contributor
There was a problem hiding this comment.
Pull request overview
Re-enables two previously-disabled Half modulus test cases that validate preservation of negative zero for exact-zero remainders, bringing HalfTests.GenericMath back in line with the existing float/double generic-math coverage.
Changes:
- Re-enabled
Half.MinValue % 2expectingNegativeZero. - Re-enabled
NegativeZero % 2expectingNegativeZero. - Removed the now-obsolete commented-out assertions referencing
PositiveTwo, using the existingTwohelper instead.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Runtime/tests/System.Runtime.Tests/System/HalfTests.GenericMath.cs | Re-enables two negative-zero remainder assertions in op_ModulusTest using the existing Two helper. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
PranavSenthilnathan
approved these changes
Jul 23, 2026
hez2010
pushed a commit
to hez2010/runtime
that referenced
this pull request
Jul 26, 2026
Closes dotnet#67993. The two disabled cases in `HalfTests.op_ModulusTest` (`Half.MinValue % 2` and `-0 % 2`, both expected to be `-0`) were a workaround for a non-deterministic sign-of-zero loss in `float` remainder observed on a single `coreclr windows x64 Debug` CI leg back in 2022. The equivalent `float`, `double`, and `NFloat` assertions have been enabled and green the whole time. Investigation of the current state: - The JIT compile-time paths are correct: `gtFoldExprBinaryConstDbl` doesn''t fold `GT_MOD`, and VN `FpRem` computes `(TFp)fmod((double)-0, (double)2)` -> `-0`. - The runtime helper (`CORINFO_HELP_FLTREM` -> `fmodf`) returns `-0` for `fmod(-0, 2)` on the current MSVC toolset, including the debug CRT (`/MDd`, `/MTd`). - The `float`->`Half` cast preserves the sign bit (`0x8000`). - A repro on .NET 10 returns `0x8000` for both cases in Debug and Release. Root cause was an environmental toolset/CRT defect that no longer reproduces, so the assertions are safe to re-enable. Also fixes the stale `PositiveTwo` helper reference (the file defines `Two`). ---------- Validated behavior against the shipping .NET 10 runtime and the current MSVC CRT directly. Local repo test suite was not run (no baseline build in this environment); CI covers `System.Runtime.Tests`. > [!NOTE] > This PR was authored with the assistance of GitHub Copilot. 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.
Closes #67993.
The two disabled cases in
HalfTests.op_ModulusTest(Half.MinValue % 2and-0 % 2, both expected to be-0) were a workaround for a non-deterministic sign-of-zero loss infloatremainder observed on a singlecoreclr windows x64 DebugCI leg back in 2022. The equivalentfloat,double, andNFloatassertions have been enabled and green the whole time.Investigation of the current state:
gtFoldExprBinaryConstDbldoesn''t foldGT_MOD, and VNFpRemcomputes(TFp)fmod((double)-0, (double)2)->-0.CORINFO_HELP_FLTREM->fmodf) returns-0forfmod(-0, 2)on the current MSVC toolset, including the debug CRT (/MDd,/MTd).float->Halfcast preserves the sign bit (0x8000).0x8000for both cases in Debug and Release.Root cause was an environmental toolset/CRT defect that no longer reproduces, so the assertions are safe to re-enable. Also fixes the stale
PositiveTwohelper reference (the file definesTwo).Validated behavior against the shipping .NET 10 runtime and the current MSVC CRT directly. Local repo test suite was not run (no baseline build in this environment); CI covers
System.Runtime.Tests.Note
This PR was authored with the assistance of GitHub Copilot.