Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libm on i386 with FLT_EVAL_METHOD=2, the computati...
details: https://anonhg.NetBSD.org/src/rev/a13154ed7360
branches: trunk
changeset: 999268:a13154ed7360
user: maya <maya%NetBSD.org@localhost>
date: Mon May 27 00:10:36 2019 +0000
description:
on i386 with FLT_EVAL_METHOD=2, the computation inside cosf was done in
binary80 arithmetic and never rounded to binary32 at the end, so it
appeared farther from the correctly rounded result in binary32 than expected.
Force binary32 using volatile float.
PR lib/54232: lib/libm/t_cos:cosf_angles regression on i386
>From Riastradh.
diffstat:
tests/lib/libm/t_cos.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diffs (36 lines):
diff -r ec1f4649edb5 -r a13154ed7360 tests/lib/libm/t_cos.c
--- a/tests/lib/libm/t_cos.c Sun May 26 23:03:31 2019 +0000
+++ b/tests/lib/libm/t_cos.c Mon May 27 00:10:36 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_cos.c,v 1.8 2019/04/25 22:58:23 maya Exp $ */
+/* $NetBSD: t_cos.c,v 1.9 2019/05/27 00:10:36 maya Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -275,13 +275,24 @@
float theta = angles[i].x;
float cos_theta = angles[i].fy;
+ /*
+ * Force rounding to float even if FLT_EVAL_METHOD=2,
+ * as is the case on i386.
+ *
+ * The volatile should not be necessary, by C99 Sec.
+ * 5.2.4.2.2. para. 8 on p. 24 which specifies that
+ * assignment and cast remove all extra range and precision,
+ * but seems to be needed to work around a compiler bug.
+ */
+ volatile float result = cosf(theta);
+
if (cos_theta == 999)
cos_theta = angles[i].y;
assert(cos_theta != 0);
- if (!(fabsf((cosf(theta) - cos_theta)/cos_theta) <= eps)) {
+ if (!(fabsf((result - cos_theta)/cos_theta) <= eps)) {
atf_tc_fail_nonfatal("cosf(%d deg = %.8g) = %.8g"
- " != %.8g", deg, theta, cos(theta), cos_theta);
+ " != %.8g", deg, theta, result, cos_theta);
}
}
}
Home |
Main Index |
Thread Index |
Old Index