[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
Wed Sep 25 20:56:23 PDT 2019
delcypher updated this revision to Diff 221884.
delcypher added a comment.
Modify test instead.
Repository:
rCRT Compiler Runtime
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67999/new/
https://reviews.llvm.org/D67999
Files:
lib/builtins/fp_lib.h
test/builtins/Unit/compiler_rt_logbf_test.c
Index: test/builtins/Unit/compiler_rt_logbf_test.c
===================================================================
--- test/builtins/Unit/compiler_rt_logbf_test.c
+++ test/builtins/Unit/compiler_rt_logbf_test.c
@@ -21,7 +21,8 @@
fp_t crt_value = __compiler_rt_logbf(x);
fp_t libm_value = logbf(x);
// Compare actual rep, e.g. to avoid NaN != the same NaN
- if (toRep(crt_value) != toRep(libm_value)) {
+ if (canonicalizeNaNRep(toRep(crt_value)) !=
+ canonicalizeNaNRep(toRep(libm_value))) {
printf("error: in __compiler_rt_logb(%a [%X]) = %a [%X] != %a [%X]\n", x,
toRep(x), crt_value, toRep(crt_value), libm_value,
toRep(libm_value));
Index: lib/builtins/fp_lib.h
===================================================================
--- lib/builtins/fp_lib.h
+++ lib/builtins/fp_lib.h
@@ -259,6 +259,18 @@
}
}
+// Iff `rep` represents the bit pattern for a NaN then return a canonical
+// representation of NaN, otherwise return `rep`.
+static __inline rep_t canonicalizeNaNRep(rep_t rep) {
+ rep_t exp = (rep & exponentMask) >> significandBits;
+ rep_t significand = (rep & significandMask);
+ if (exp == maxExponent && significand) {
+ // `rep` is a NaN
+ return qnanRep;
+ }
+ return rep;
+}
+
// Implements logb methods (logb, logbf, logbl) for IEEE-754. This avoids
// pulling in a libm dependency from compiler-rt, but is not meant to replace
// it (i.e. code calling logb() should get the one from libm, not this), hence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67999.221884.patch
Type: text/x-patch
Size: 1498 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190926/a5cdfc41/attachment.bin>
More information about the llvm-commits
mailing list