[PATCH] D67999: Fix `compiler_rt_logbf_test.c` test failure for Builtins-i386-darwin test suite.
Dan Liew via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 17:15:58 PDT 2019
delcypher created this revision.
delcypher added reviewers: rupprecht, scanon, compnerd, echristo.
Herald added projects: LLVM, Sanitizers.
Herald added a subscriber: Sanitizers.
It seems that previously compiler-rt's implementation and Darwin
libm's implementation of `logbf()` differed when given a NaN
with raised sign bit. Strangely this behaviour only happens with
i386 Darwin libm. For x86_64 and x86_64h the existing compiler-rt
implementation matched Darwin libm.
To workaround this compiler-rt's implementation of `logbf()` has
been modified to behave like i386 Darwin libm but only when being
built for i386 Darwin. In all other cases the existing behaviour is
retained to avoid breaking other platforms and architectures.
rdar://problem/55565503
Repository:
rCRT Compiler Runtime
https://reviews.llvm.org/D67999
Files:
lib/builtins/fp_lib.h
Index: lib/builtins/fp_lib.h
===================================================================
--- lib/builtins/fp_lib.h
+++ lib/builtins/fp_lib.h
@@ -271,8 +271,18 @@
// 1) +/- inf returns +inf; NaN returns NaN
// 2) 0.0 returns -inf
if (exp == maxExponent) {
- if (((rep & signBit) == 0) || (x != x)) {
- return x; // NaN or +inf: return x
+ if (x != x) {
+ // NaN
+#if defined(__APPLE__) && defined(__i386__)
+ // Darwin i386 libm when given a NaN with a raised
+ // sign bit returns a NaN without a sign bit.
+ if (rep & signBit) {
+ return fromRep((~signBit) & rep);
+ }
+#endif
+ return x;
+ } else if ((rep & signBit) == 0) {
+ return x; // +inf: return x
} else {
return -x; // -inf: return -x
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67999.221629.patch
Type: text/x-patch
Size: 788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190925/0bdc2522/attachment.bin>
More information about the llvm-commits
mailing list