Simplify floating-point integer classification - #133934
Open
tannergooding wants to merge 1 commit into
Open
tannergooding wants to merge 1 commit into
tannergooding wants to merge 1 commit into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 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: @dotnet/area-system-numerics |
Contributor
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Moderate mixed-lane coverage gaps and the range-mask comment correction remain unresolved.
Review tier: Lite
Findings: None
What changed in this PR
This PR simplifies floating-point integer classification across scalar, SIMD, and JIT implementations, fixes RootN parity handling, and updates vector logarithm special-value handling.
Changes:
- Uses truncation residuals and shared SIMD algorithms.
- Simplifies JIT lowering and logarithm masks.
- Adds boundary, mixed-lane, and regression coverage.
Review notes: two moderate findings request mixed-lane Log/Log2 coverage for each applicable vector width (one vote each); one nit requests correcting the range-mask comment (one vote).
| File | Reviewed changes |
|---|---|
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/SingleTests.GenericMath.cs |
Adds float classification tests. |
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/SingleTests.cs |
Adds RootN regressions. |
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DoubleTests.GenericMath.cs |
Adds double classification tests. |
src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector64Tests.cs |
Tests Vector64 classification. |
src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector512Tests.cs |
Tests Vector512 classification. |
src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector256Tests.cs |
Tests Vector256 classification. |
src/libraries/System.Runtime.Intrinsics/tests/Vectors/Vector128Tests.cs |
Tests Vector128 classification and mixed-lane logs. |
src/libraries/System.Private.CoreLib/src/System/Single.cs |
Updates float classification and RootN. |
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/VectorMath.cs |
Shares SIMD algorithms and revises logarithm masks. |
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs |
Updates Vector64 dispatch and classification. |
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector512.cs |
Updates Vector512 dispatch and classification. |
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs |
Updates Vector256 dispatch and classification. |
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs |
Updates Vector128 dispatch and classification. |
src/libraries/System.Private.CoreLib/src/System/Numerics/Vector.cs |
Updates portable vector classification. |
src/libraries/System.Private.CoreLib/src/System/Double.cs |
Updates double classification and RootN. |
src/libraries/System.Numerics.Vectors/tests/GenericVectorTests.cs |
Tests portable vector classification. |
src/libraries/Common/tests/System/GenericMathTestMemberData.cs |
Adds classification boundary data. |
src/coreclr/jit/hwintrinsic.cpp |
Updates floating-point classification dispatch. |
src/coreclr/jit/gentree.cpp |
Updates SIMD integer classification lowering. |
This was referenced Sep 15, 2026
Open
Closed
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.
Fixes #133916.
Replace finite checks, floating-point remainder, and exponent/significand parity tests with truncation-based residual comparisons for
float,double, and SIMD vectors. Nonfinite inputs produce NaN residuals and compare false. Even-integer classification subtracts from the original input so halving a subnormal cannot incorrectly classify it as zero.IsIntegercomparison in the JIT lowering as well as the managed implementations.Single.RootNandDouble.RootN. This also fixes negative inputs with odd roots that round to an even number when converted tofloat, such asfloat.RootN(-1, 16777217).Log/Log2with an unsigned encoding-range comparison, preserving special results and subnormal handling.Coverage focuses on representable neighbors of integer and precision boundaries, independent mixed-lane classification masks, four
Single.RootNregressions, and mixed-lane logarithm special cases.Performance
Representative paired BenchmarkDotNet measurements on Windows 11 / Ryzen 9 7950X, using Release runtime builds against baseline
e273d4d8b14(ns per element):double.IsEvenIntegerdouble.IsOddIntegerfloat.IsOddIntegerdouble.IsEvenIntegerdouble.IsOddIntegerRepresentative accelerated
IsIntegerwrappers shrink from 51 to 31 bytes forVector128<float>and from 54 to 34 bytes forVector256<double>. The final dispatch simplification retained accelerated throughput within measurement noise.Validation
Built CoreCLR/CoreLib in Checked and Release configurations. Ran scalar classification and
RootNtests, and fixed-width/portable vector coverage. After the final simplification, 1,488 fixed-width and 507 portable classification tests passed in each of the normal, no-AVX2, and hardware-intrinsics-disabled configurations. The retainedRootNregressions fail on the baseline. Windows x64 JIT formatting passed.Validation is local to Windows x64; ARM64, Mono, and WASM were not run. The full no-AVX2 intrinsic suite encounters a pre-existing
Vector256.IsPositive<double>JIT assertion; the focused tests for these changes pass.Note
This PR description was drafted with GitHub Copilot.