[libc-commits] [PATCH] D117590: [libc] Implement correct rounding with all rounding modes for hypot functions.
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Jan 19 07:01:56 PST 2022
lntue added a comment.
In D117590#3254008 <https://reviews.llvm.org/D117590#3254008>, @zimmermann6 wrote:
> Dear Tue,
>
>> Update the rounding logic for generic hypot function so that it will round correctly with all rounding modes.
>
> I did stress this revision with my random testing code
> (https://gitlab.inria.fr/zimmerma/math_accuracy) and did not find any
> incorrectly rounded results, for all rounding modes, both for binary32
> and binary64.
>
> Instead of testing get_round() == FE_UPWARD to know the current rounding
> mode, I wonder whether a test like 0x1p0f + 0x1p-24f != 0x1p0f would be
> faster.
>
> Paul
Thanks Paul for testing the patch!
I've tried with using the 0x1p0f + 0x1p-24f != 0x1p0f instead of get_round() == FE_UPWARD, and it does make the perf tests on normal range ~ 5% faster.
But this is due to the compiler optimized away the expression (making it always False), and in turn, making the function not correctly rounded for all rounding modes any more: https://godbolt.org/z/87z4bWE9P
And if feel like if we add extra stuff to prevent the compiler from optimizing the expression away, it would bring the performance back to what we got with get_round() == FE_UPWARD.
This is also belong to the exceptional cases where we short-circuit the results, and so at least any changes inside would not affect the worst case performance.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D117590/new/
https://reviews.llvm.org/D117590
More information about the libc-commits
mailing list