This is an archive of the discontinued LLVM Phabricator instance.

[libc] Match x86 long double NaN classification with that of the compiler.
ClosedPublic

Authored by sivachandra on Jun 22 2020, 2:04 PM.

Diff Detail

Event Timeline

sivachandra created this revision.Jun 22 2020, 2:04 PM
MaskRay added inline comments.
libc/test/utils/FPUtil/x86_long_double_test.cpp
27

You can test whether some combinations of bits are significant, instead of iterating over all integers from 0 to 1000000 (it is slow).

asteinhauser accepted this revision.Jun 22 2020, 4:27 PM
asteinhauser added inline comments.
libc/test/utils/FPUtil/x86_long_double_test.cpp
29

There is some ASSERT_NE(a, b) macro which might be useful. It asserts directly the inequality.

53

I would add one or two tests also for the false case - e.g.:

bits.exponent = 1;
bits.implicit = 1;
for (unsigned int i = 0; i < 1000000; ++i) {

// If exponent is non-zero and also not max, and the implicit bit is 0,
// then the number is a NaN for all values of mantissa.
bits.mantissa = i;
long double nan = bits;
ASSERT_EQ(isnan(nan), 0);
ASSERT_FALSE(bits.isNaN());

}

This revision is now accepted and ready to land.Jun 22 2020, 4:27 PM

Sorry, I kept there the old comment.

libc/test/utils/FPUtil/x86_long_double_test.cpp
53

Sorry, I left there an old comment from copy-pasting. There should be something like:
If the implicit bit is true and the exponent is not the max value,
the number is not a NaN for any mantissa.

sivachandra marked 3 inline comments as done.

Add tests for non-NaN numbers.

Added tests for non-NaN numbers.

This revision was automatically updated to reflect the committed changes.