git: d37fb0e37814 - stable/13 - AArch64: Don't set flush-subnormals-to-zero flag on startup
Alex Richardson
arichardson at FreeBSD.org
Wed Mar 17 10:27:30 UTC 2021
The branch stable/13 has been updated by arichardson:
URL: https://cgit.FreeBSD.org/src/commit/?id=d37fb0e37814db8f76462b3b9f1fb0e6dfca6324
commit d37fb0e37814db8f76462b3b9f1fb0e6dfca6324
Author: Alex Richardson <arichardson at FreeBSD.org>
AuthorDate: 2021-03-01 14:27:30 +0000
Commit: Alex Richardson <arichardson at FreeBSD.org>
CommitDate: 2021-03-17 09:45:56 +0000
AArch64: Don't set flush-subnormals-to-zero flag on startup
This flag has been set on startup since 65618fdda0f272a823e6701966421bdca0efa301.
However, This causes some of the math-related tests to fail as they report
zero instead of a tiny number. This fixes at least
/usr/tests/lib/msun/ldexp_test and possibly others.
Additionally, setting this flag prevents printf() from printing subnormal
numbers in decimal form.
See also https://www.openwall.com/lists/musl/2021/02/26/1
PR: 253847
Reviewed By: mmel
Differential Revision: https://reviews.freebsd.org/D28938
(cherry picked from commit 0e4ff0acbe80c547988bede738af2e227c7eb47c)
---
lib/libc/tests/stdio/printfloat_test.c | 35 +++++++++++++++++++++++++++++++++-
sys/arm64/arm64/vm_machdep.c | 2 +-
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/lib/libc/tests/stdio/printfloat_test.c b/lib/libc/tests/stdio/printfloat_test.c
index 97629fb0d2b1..736ba1b493ef 100644
--- a/lib/libc/tests/stdio/printfloat_test.c
+++ b/lib/libc/tests/stdio/printfloat_test.c
@@ -50,7 +50,7 @@ smash_stack(void)
{
static uint32_t junk = 0xdeadbeef;
uint32_t buf[512];
- int i;
+ size_t i;
for (i = 0; i < sizeof(buf) / sizeof(buf[0]); i++)
buf[i] = junk;
@@ -370,6 +370,37 @@ ATF_TC_BODY(hexadecimal_rounding, tc)
testfmt("0x1.83p+0", "%.2a", 1.51);
}
+ATF_TC_WITHOUT_HEAD(subnormal_double);
+ATF_TC_BODY(subnormal_double, tc)
+{
+ /* Regression test for https://bugs.freebsd.org/253847 */
+ double positive = __DBL_DENORM_MIN__;
+ testfmt("4.9406564584124654418e-324", "%20.20g", positive);
+ testfmt("4.9406564584124654418E-324", "%20.20G", positive);
+ testfmt("0x1p-1074", "%a", positive);
+ testfmt("0X1P-1074", "%A", positive);
+ double negative = -__DBL_DENORM_MIN__;
+ testfmt("-4.9406564584124654418e-324", "%20.20g", negative);
+ testfmt("-4.9406564584124654418E-324", "%20.20G", negative);
+ testfmt("-0x1p-1074", "%a", negative);
+ testfmt("-0X1P-1074", "%A", negative);
+}
+
+ATF_TC_WITHOUT_HEAD(subnormal_float);
+ATF_TC_BODY(subnormal_float, tc)
+{
+ float positive = __FLT_DENORM_MIN__;
+ testfmt("1.4012984643248170709e-45", "%20.20g", positive);
+ testfmt("1.4012984643248170709E-45", "%20.20G", positive);
+ testfmt("0x1p-149", "%a", positive);
+ testfmt("0X1P-149", "%A", positive);
+ float negative = -__FLT_DENORM_MIN__;
+ testfmt("-1.4012984643248170709e-45", "%20.20g", negative);
+ testfmt("-1.4012984643248170709E-45", "%20.20G", negative);
+ testfmt("-0x1p-149", "%a", negative);
+ testfmt("-0X1P-149", "%A", negative);
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -384,6 +415,8 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, decimal_rounding);
ATF_TP_ADD_TC(tp, hexadecimal_floating_point);
ATF_TP_ADD_TC(tp, hexadecimal_rounding);
+ ATF_TP_ADD_TC(tp, subnormal_double);
+ ATF_TP_ADD_TC(tp, subnormal_float);
return (atf_no_error());
}
diff --git a/sys/arm64/arm64/vm_machdep.c b/sys/arm64/arm64/vm_machdep.c
index 8a48f0243abc..ac2a47597a8c 100644
--- a/sys/arm64/arm64/vm_machdep.c
+++ b/sys/arm64/arm64/vm_machdep.c
@@ -55,7 +55,7 @@ __FBSDID("$FreeBSD$");
#include <machine/vfp.h>
#endif
-uint32_t initial_fpcr = VFPCR_DN | VFPCR_FZ;
+uint32_t initial_fpcr = VFPCR_DN;
#include <dev/psci/psci.h>
More information about the dev-commits-src-all
mailing list