[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 11:52:56 PST 2023
lntue updated this revision to Diff 494027.
lntue added a comment.
Add comments.
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.494027.patch
Type: text/x-patch
Size: 647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230201/7ef9f3a1/attachment.bin>
More information about the libc-commits
mailing list