This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add implementation for hypotf
ClosedPublic

Authored by lntue on Sep 11 2020, 7:49 AM.

Details

Summary

Truncating the sum of squares, and then use shift-and-add algorithm to compute its square root.
Required MPFR testing infra is updated in https://reviews.llvm.org/D87514

Diff Detail

Event Timeline

lntue created this revision.Sep 11 2020, 7:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 11 2020, 7:49 AM
lntue requested review of this revision.Sep 11 2020, 7:49 AM
lntue updated this revision to Diff 291223.Sep 11 2020, 8:08 AM

Fix comments alignment and remove commented tests.

hungptit added inline comments.
libc/src/math/hypotf.cpp
89

Shall we use the return early pattern for this if block?

libc/test/src/math/hypotf_test.cpp
22

Does const/constexpr work for these global variables?

lntue marked 2 inline comments as done.Sep 14 2020, 12:41 PM
lntue added inline comments.
libc/test/src/math/hypotf_test.cpp
22

The template class FPBits<T> does not support constexpr yet.

lntue updated this revision to Diff 291654.Sep 14 2020, 12:41 PM
lntue marked an inline comment as done.

Change to early return pattern.

sivachandra accepted this revision.Sep 17 2020, 9:05 AM
sivachandra added inline comments.
libc/src/math/hypotf.cpp
2

With other implementations in libc/src, we have followed snake_case. I think we should do that here for consistency.

100

I understand why the use of a 64-bit integers is required here. But, I would ideally prefer to restrict a function which deals with 32-bit numbers not have to deal with wider numbers. It surely is not a problem on most modern architectures. So, we can revisit if it ever becomes a problem. FWIW, the AOR implementations also switch to double_t for higher precision with intermediate computations.

This revision is now accepted and ready to land.Sep 17 2020, 9:05 AM
lntue marked an inline comment as done.Sep 17 2020, 8:45 PM
lntue updated this revision to Diff 292698.Sep 17 2020, 8:46 PM

Change to snake_case.

This revision was landed with ongoing or failed builds.Sep 17 2020, 8:47 PM
This revision was automatically updated to reflect the committed changes.