-
Notifications
You must be signed in to change notification settings - Fork 1.6k
The Uncanny xmath Overhaul #5959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
StephanTLavavej
merged 21 commits into
microsoft:main
from
StephanTLavavej:math-blaster-2
Jan 8, 2026
+318
−459
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5077f20
Fuse xfcosh.cpp into xcosh.cpp.
StephanTLavavej ffcaac1
Fuse xfsinh.cpp into xsinh.cpp.
StephanTLavavej fdb8401
Fuse xfdtest.cpp into xdtest.cpp.
StephanTLavavej e0ca27b
Fuse xfexp.cpp into xexp.cpp.
StephanTLavavej cbf7497
Fuse xfdscale.cpp into xexp.cpp.
StephanTLavavej 05e05ca
Fuse xfdnorm.cpp into xexp.cpp.
StephanTLavavej 24d50a0
Replace `_Feraise()` with `errno = ERANGE;`.
StephanTLavavej 0cf8a8b
Fuse underflow/overflow cases, avoid missing `break;`.
StephanTLavavej 1485cc9
Preserve `_Dtest()` for bincompat, replaced with `fpclassify()`.
StephanTLavavej ec5d314
`_FINITE` => `FP_NORMAL`
StephanTLavavej 067bf92
`_INFCODE` => `FP_INFINITE`
StephanTLavavej a12cfce
`_NANCODE` => `FP_NAN`
StephanTLavavej c548b9a
`0` => `FP_ZERO`, carefully.
StephanTLavavej 4330caa
Remove now-unused `_Dtest()` macros.
StephanTLavavej d8dfbd5
Replace `DSIGN` and `FSIGN` with `signbit()`.
StephanTLavavej 340232d
Move `_Dval`, `_Fval`, and their index macros into xexp.cpp's unnamed…
StephanTLavavej bb230a5
Change index macros to `constexpr int`, cleanup comments.
StephanTLavavej a6d8c16
Move `_Xfe_overflow()`, `_Xfe_underflow()` into xexp.cpp's unnamed na…
StephanTLavavej e56b8f8
Replace `extern const` `_Xbig` and `_FXbig` with replicated `constexpr`.
StephanTLavavej 055190c
Delete xmath.hpp, include only relevant headers.
StephanTLavavej a85563e
Fix dangerous `_Dval`, `_Fval` union sizes.
StephanTLavavej File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,23 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| // _Dtest function -- IEEE 754 version | ||
|
|
||
| #include "xmath.hpp" | ||
| #include <cmath> | ||
|
|
||
| _EXTERN_C_UNLESS_PURE | ||
|
|
||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double* px) noexcept { // categorize *px | ||
| const auto ps = reinterpret_cast<_Dval*>(px); | ||
|
|
||
| if ((ps->_Sh[_D0] & _DMASK) == _DMAX << _DOFF) { | ||
| return (ps->_Sh[_D0] & _DFRAC) != 0 || ps->_Sh[_D1] != 0 || ps->_Sh[_D2] != 0 || ps->_Sh[_D3] != 0 ? _NANCODE | ||
| : _INFCODE; | ||
| } else if ((ps->_Sh[_D0] & ~_DSIGN) != 0 || ps->_Sh[_D1] != 0 || ps->_Sh[_D2] != 0 || ps->_Sh[_D3] != 0) { | ||
| return (ps->_Sh[_D0] & _DMASK) == 0 ? _DENORM : _FINITE; | ||
| } else { | ||
| return 0; | ||
| } | ||
| // TRANSITION, ABI: preserved for binary compatibility | ||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Dtest(double* px) noexcept { | ||
| return static_cast<short>(_STD fpclassify(*px)); | ||
| } | ||
|
|
||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double* px) noexcept { // categorize *px -- 64-bit | ||
| // TRANSITION, ABI: preserved for binary compatibility | ||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _LDtest(long double* px) noexcept { | ||
| return _Dtest(reinterpret_cast<double*>(px)); | ||
| } | ||
|
|
||
| // TRANSITION, ABI: preserved for binary compatibility | ||
| _CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _FDtest(float* px) noexcept { | ||
| return static_cast<short>(_STD fpclassify(*px)); | ||
| } | ||
|
|
||
| _END_EXTERN_C_UNLESS_PURE |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.