This is an archive of the discontinued LLVM Phabricator instance.

Set std::numeric_limits<>::tinyness_before to true for floating point types on ARM platforms.
ClosedPublic

Authored by resistor on Dec 28 2021, 11:51 AM.

Details

Summary

Set std::numeric_limits<>::tinyness_before to true for floating point types on ARM platforms.

Section E1.3.5 in the ARMv8 Architecture Reference Manual specifies:

Underflow. The bit is set to 1 if the absolute value of the result
of an operation, produced before rounding, is less than the minimum
positive normalized number for the destination precision, and the
rounded result is inexact.

Diff Detail

Event Timeline

resistor created this revision.Dec 28 2021, 11:51 AM
resistor requested review of this revision.Dec 28 2021, 11:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2021, 11:51 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
resistor edited the summary of this revision. (Show Details)Dec 28 2021, 11:52 AM

This will require at least one change to libcxx/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp.

Is there any way for us to actually test that tinyness_before is set to the correct value for the platform's behavior? e.g. by somehow taking and modifying the sample code from cppreference? https://en.cppreference.com/w/cpp/types/numeric_limits/tinyness_before#Example

resistor updated this revision to Diff 396460.Dec 28 2021, 8:06 PM

Update tests to account for the change in behavior, and add a
specific test that checks the value of tinyness_before against
the actual platform behavior.

This looks reasonable to me but we definitely want for CI to be back and passing before shipping this one.

libcxx/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp
27

Unless this was intended?

resistor updated this revision to Diff 396551.Dec 29 2021, 10:25 AM

Fix oversight where std::nextafter was always specialized on double rather than the type under test.

resistor marked an inline comment as done.Dec 29 2021, 10:26 AM
resistor added inline comments.
libcxx/test/std/language.support/support.limits/limits/numeric.limits.members/tinyness_before.pass.cpp
27

Thank for you for the catch.

resistor updated this revision to Diff 396559.Dec 29 2021, 11:39 AM
resistor marked an inline comment as done.

Remove the platform verification test. Unfortunately, getting this to work consistently
across different compilers isn't really tractable given the state of strict floating point
support in various compilers/versions.

Remove the platform verification test. Unfortunately, getting this to work consistently
across different compilers isn't really tractable given the state of strict floating point
support in various compilers/versions.

Which ones were not working? It might be reasonable to XFAIL that part of the test for non mainstream compilers? Technically we only support recent Clangs and GCCs, which I would assume should handle this properly.

Which ones were not working? It might be reasonable to XFAIL that part of the test for non mainstream compilers? Technically we only support recent Clangs and GCCs, which I would assume should handle this properly.

With the clang revision I tested, passing the test was dependent on optimization flags.

Do we also need to test for __aarch64__? https://developer.arm.com/documentation/dui0774/g/chr1383660321827 says that __arm__ is only defined for 32-bit targets.

resistor updated this revision to Diff 399360.Jan 12 2022, 9:41 AM

Add arch64 to detect AArch64 properly.

Do we also need to test for __aarch64__? https://developer.arm.com/documentation/dui0774/g/chr1383660321827 says that __arm__ is only defined for 32-bit targets.

Good catch, thanks.

EricWF accepted this revision.Feb 22 2022, 10:39 AM
EricWF added a subscriber: EricWF.
EricWF added inline comments.
libcxx/include/limits
342

Instead of each of these ifdefs could we maybe do something like

#if defined(arm or w/e)
#define _LIBCPP_TINYNESS_BEFORE true
#else
#define _LIBCPP_TINYNESS_BEFORE false
#endif

Then we can undef it at the end of the header.

This revision is now accepted and ready to land.Feb 22 2022, 10:39 AM
This revision was landed with ongoing or failed builds.Feb 22 2022, 3:49 PM
This revision was automatically updated to reflect the committed changes.
This comment was removed by tstellar.
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2023, 8:35 AM
This comment was removed by tstellar.
Unknown Object (User) added a subscriber: Unknown Object (User).Jun 29 2023, 4:27 AM
This comment was removed by tstellar.