-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
Switch to special quiet NaN as init value for all FP types #2207
Conversation
118b26c
to
95dc0b7
Compare
|
In 0x7FF4000000000000 instead of 0x7FFC000000000000 Not sure why, considering it passes on x86. It is the only failure though. Should we be implementing |
|
The new value |
|
[Changed the scope of the PR after figuring out what the actual issue is.] |
|
Why did you remove |
|
To make clear we don't need that buggy version assuming x87 real_t if size != 8. |
|
Maybe at least add a comment saying |
fe778df
to
e767f28
Compare
|
Win32 unexpectedly still fails with quiet |
|
To be more precise: the Win32 LDC compiler generates quiet ones; the 64-bit build with |
96dbf62
to
f4995b6
Compare
|
In the long term, using quiet FP inits (with the second-most significant mantissa bit set too, to distinguish them from normal quiet NaNs) for all 3 types may make more sense. |
f4995b6
to
b10485e
Compare
|
Well, why wait => switched to quiet |
|
Any objections to a consistent special quiet NaN for all FP types? |
|
can't help judging here, maybe ask on the forums if you're unsure. |
b10485e
to
8178fb6
Compare
By letting LLVM narrow compile-time real_t values to float/double IR
constants. We previously relied on the host, which turns signalling
real_t NaNs to quiet float/double NaNs.
Signalling NaNs are characterized by their most-significant mantissa bit
being 0 (and at least for D the 2nd-most-significant mantissa bit being
set to distinguish them from infinity). The host truncation led to the MSB
getting set while keeping the rest of the mantissa (i.e., both MSBs set).
Here's the resulting bitpattern table in hex:
float: double: x87 real:
init old: 7fe00000 7ffc000000000000 7fffa000000000000000
init new: 7fa00000 7ff4000000000000 7fffa000000000000000
qnan: 7fc00000 7ff8000000000000 7fffc000000000000000
DMD 2.074.0 produces wrongly quiet float/double init values.
A Win32 LDC build (with double-precision real_t) still loses the
signalling-ness for {float,double,64-bit real}.init, probably due to the
FPU being used instead of SSE.
As 'processing' a signalling NaN may convert it to a quiet NaN. Apparently happening on 32-bit x86 using the x87 FPU, but not on x86_64 with SSE. This fixes potential issues with different constants being used when mixing natively and cross-compiled objects/libs and failing bitwise `is` comparisons etc. See https://forum.dlang.org/post/nsp1ql$ivu$1@digitalmars.com for Martin Nowak's summarized findings.
8178fb6
to
5dd07dc
Compare
|
No feedback in the forum - merging. |
Update:
By letting LLVM truncate compile-time
real_tvalues to float/double IR constants. We previously relied on the host, which turns signalling real_t NaNs to quiet float/double NaNs.Signalling NaNs are characterized by their most-significant mantissa bit being 0 (and at least for D the 2nd-most-significant mantissa bit being set to distinguish them from infinity). The host truncation led to the MSB
getting set while keeping the rest of the mantissa (i.e., both MSBs set).
Here's the resulting bitpattern table in hex:
DMD 2.074.0 produces wrongly quiet float/double init values. It's known: https://forum.dlang.org/post/nsp1ql$ivu$1@digitalmars.com