summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/builtins/Unit/compiler_rt_logbf_test.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/test/builtins/Unit/compiler_rt_logbf_test.c b/test/builtins/Unit/compiler_rt_logbf_test.c
index fa3b8999f..4563fbdb4 100644
--- a/test/builtins/Unit/compiler_rt_logbf_test.c
+++ b/test/builtins/Unit/compiler_rt_logbf_test.c
@@ -13,15 +13,19 @@
//===----------------------------------------------------------------------===//
#define SINGLE_PRECISION
+#include "fp_lib.h"
+#include "int_math.h"
#include <math.h>
#include <stdio.h>
-#include "fp_lib.h"
int test__compiler_rt_logbf(fp_t x) {
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)) {
+ // `!=` operator on fp_t returns false for NaNs so also check if operands are
+ // both NaN. We don't do `toRepr(crt_value) != toRepr(libm_value)` because
+ // that treats different representations of NaN as not equivalent.
+ if (crt_value != libm_value &&
+ !(crt_isnan(crt_value) && crt_isnan(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));