Skip to content

Commit 196eae5

Browse files
committedOct 8, 2019
Fix compiler_rt_logbf_test.c test failure for Builtins-i386-darwin test suite.
Summary: It seems that compiler-rt's implementation and Darwin libm's implementation of `logbf()` differ 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 the `compiler_rt_logbf_test.c` has been modified to do a comparison on the `fp_t` type and if that fails check if both values are NaN. If both values are NaN they are equivalent and no error needs to be raised. rdar://problem/55565503 Reviewers: rupprecht, scanon, compnerd, echristo Subscribers: #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D67999 llvm-svn: 374109
1 parent b56e3a1 commit 196eae5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎compiler-rt/test/builtins/Unit/compiler_rt_logbf_test.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#define SINGLE_PRECISION
16+
#include "fp_lib.h"
17+
#include "int_math.h"
1618
#include <math.h>
1719
#include <stdio.h>
18-
#include "fp_lib.h"
1920

2021
int test__compiler_rt_logbf(fp_t x) {
2122
fp_t crt_value = __compiler_rt_logbf(x);
2223
fp_t libm_value = logbf(x);
23-
// Compare actual rep, e.g. to avoid NaN != the same NaN
24-
if (toRep(crt_value) != toRep(libm_value)) {
24+
// `!=` operator on fp_t returns false for NaNs so also check if operands are
25+
// both NaN. We don't do `toRepr(crt_value) != toRepr(libm_value)` because
26+
// that treats different representations of NaN as not equivalent.
27+
if (crt_value != libm_value &&
28+
!(crt_isnan(crt_value) && crt_isnan(libm_value))) {
2529
printf("error: in __compiler_rt_logb(%a [%X]) = %a [%X] != %a [%X]\n", x,
2630
toRep(x), crt_value, toRep(crt_value), libm_value,
2731
toRep(libm_value));

0 commit comments

Comments
 (0)
Please sign in to comment.