[libc-commits] [PATCH] D143098: [libc][math] Fix setting exceptional value for tanf to work with gcc.
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Feb 1 12:54:07 PST 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG135cea495bc1: [libc][math] Fix setting exceptional value for tanf to work with gcc. (authored by lntue).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143098/new/
https://reviews.llvm.org/D143098
Files:
libc/src/math/generic/tanf.cpp
Index: libc/src/math/generic/tanf.cpp
===================================================================
--- libc/src/math/generic/tanf.cpp
+++ libc/src/math/generic/tanf.cpp
@@ -97,7 +97,12 @@
// |x| = 0x1.143ec4p0
float sign = x_sign ? -1.0f : 1.0f;
- return fputil::multiply_add(sign, 0x1.ddf9f4p0f, sign * 0x1.1p-24f);
+ // volatile is used to prevent compiler (gcc) from optimizing the
+ // computation, making the results incorrect in different rounding modes.
+ volatile float tmp = 0x1.ddf9f4p0f;
+ tmp = fputil::multiply_add(sign, tmp, sign * 0x1.1p-24f);
+
+ return tmp;
}
// |x| > 0x1.ada6a8p+27f
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143098.494044.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230201/6d701997/attachment.bin>
More information about the libc-commits
mailing list