[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 08:21:54 PST 2022
lntue added a comment.
In D117590#3254772 <https://reviews.llvm.org/D117590#3254772>, @zimmermann6 wrote:
> Dear Tue,
>
>> 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
>
> yes, you need to add -frounding-math to the compiler options.
>
>> 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.
>
> please can you try with -frounding-math and check if the perf tests are
> faster and slower?
>
> Paul
Thanks Paul! I've added -fround-math and it worked correctly while maintaining 5% overall performance improvement compared to get_round().
I've updated the patch accordingly. You might have to redo the stress tests again to make sure everything is still working properly.
Thanks!
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