This is an archive of the discontinued LLVM Phabricator instance.

[libc] Fix how math results are compared with MPFR results.
ClosedPublic

Authored by sivachandra on May 1 2020, 5:26 PM.

Details

Summary

Math results are compared with MPFR results by checking if they are
within a tolerance level of the MPFR result. The tolerance level is set
using additional bits of precision of the fractional part of a floating
point value. Hence, the actual value of the tolerance depends on not
only the additional bits, but also on the exponent part of the floating
point number.

Previously, the exponent part was not considered in evaluating the
tolerance value. While it was OK for small values less than 1 (hence
sinf, cosf, sincosf tests were OK), it breaks for large values which
functions like exp and friends produce. This change uses the exponent
value also to evaluate the tolerance value. LLVM libc produced results
can now be compared with MPFR produced results for large values also.

Depends on D79256.

Diff Detail

Event Timeline

sivachandra created this revision.May 1 2020, 5:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 1 2020, 5:27 PM
abrachet accepted this revision.May 5 2020, 11:46 PM
abrachet added inline comments.
libc/utils/MPFRWrapper/MPFRUtils.cpp
29

Is there any way to identify the floating point standard being used? Is IEEE 754 just used everywhere?

30

Does it make semantic sense for signMask's type to be BitsType?

56

Period after comment.

191–192

I missed this before, but is this being used?

This revision is now accepted and ready to land.May 5 2020, 11:46 PM
sivachandra marked 4 inline comments as done.

Address comments.

libc/utils/MPFRWrapper/MPFRUtils.cpp
29

Its just IEEE 754 used everywhere. If we add support for other formats, then we can specialize then may be.

This revision was automatically updated to reflect the committed changes.