[libc-commits] [PATCH] D117824: [libc] Use get_round() instead of floating point tricks in generic hypot implementation.
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Thu Jan 20 11:45:26 PST 2022
lntue created this revision.
lntue added a reviewer: sivachandra.
Herald added subscribers: ecnelises, tschuett, kristof.beyls, mgorny.
Herald added a project: libc-project.
lntue requested review of this revision.
The floating point tricks used to get rounding mode require -frounding-math flag, which behaves differently on aarch64. Reverting back to use get_round instead.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117824
Files:
libc/src/__support/FPUtil/Hypot.h
libc/src/math/generic/CMakeLists.txt
Index: libc/src/math/generic/CMakeLists.txt
===================================================================
--- libc/src/math/generic/CMakeLists.txt
+++ libc/src/math/generic/CMakeLists.txt
@@ -955,8 +955,6 @@
libc.src.__support.FPUtil.fputil
COMPILE_OPTIONS
-O3
- -frounding-math
- -Wno-c++17-extensions
)
add_entrypoint_object(
@@ -1005,8 +1003,6 @@
libc.src.__support.FPUtil.fputil
COMPILE_OPTIONS
-O3
- -frounding-math
- -Wno-c++17-extensions
)
add_entrypoint_object(
Index: libc/src/__support/FPUtil/Hypot.h
===================================================================
--- libc/src/__support/FPUtil/Hypot.h
+++ libc/src/__support/FPUtil/Hypot.h
@@ -144,9 +144,7 @@
if ((x_bits.get_unbiased_exponent() >=
y_bits.get_unbiased_exponent() + MantissaWidth<T>::VALUE + 2) ||
(y == 0)) {
- // Check if the rounding mode is FE_UPWARD, will need -frounding-math so
- // that the compiler does not optimize it away.
- if ((y != 0) && (0x1p0f + 0x1p-24f != 0x1p0f)) {
+ if ((y != 0) && (get_round() == FE_UPWARD)) {
UIntType out_bits = FPBits_t(abs(x)).uintval();
return T(FPBits_t(++out_bits));
}
@@ -154,9 +152,7 @@
} else if ((y_bits.get_unbiased_exponent() >=
x_bits.get_unbiased_exponent() + MantissaWidth<T>::VALUE + 2) ||
(x == 0)) {
- // Check if the rounding mode is FE_UPWARD, will need -frounding-math so
- // that the compiler does not optimize it away.
- if ((x != 0) && (0x1p0f + 0x1p-24f != 0x1p0f)) {
+ if ((x != 0) && (get_round() == FE_UPWARD)) {
UIntType out_bits = FPBits_t(abs(y)).uintval();
return T(FPBits_t(++out_bits));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117824.401726.patch
Type: text/x-patch
Size: 1710 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220120/0f19fbed/attachment-0001.bin>
More information about the libc-commits
mailing list