git: 3825e6bf3bb5 - stable/15 - lib/msun: add tests for fmaf(3) subnormals

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 14 Sep 2026 00:45:12 UTC
The branch stable/15 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=3825e6bf3bb579d229f404b27f67488eb3ebbf35

commit 3825e6bf3bb579d229f404b27f67488eb3ebbf35
Author:     Steve Kargl <kargl@FreeBSD.org>
AuthorDate: 2026-09-10 23:33:14 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-09-14 00:44:42 +0000

    lib/msun: add tests for fmaf(3) subnormals
    
    PR:     298260
    
    (cherry picked from commit cb82cc9f0e3bdf2b39734851c74b9a13edb0cbdc)
---
 lib/msun/tests/fma_test.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/lib/msun/tests/fma_test.c b/lib/msun/tests/fma_test.c
index ec57fc34c1b1..1c63f1fd0f89 100644
--- a/lib/msun/tests/fma_test.c
+++ b/lib/msun/tests/fma_test.c
@@ -538,6 +538,30 @@ ATF_TC_BODY(double_rounding, tc) {
 	test_double_rounding();
 }
 
+ATF_TC_WITHOUT_HEAD(fmaf_subnormals);
+ATF_TC_BODY(fmaf_subnormals, tc) {
+	float x, y, z;
+	float f1, f2;
+
+	x = -0x1.001p-81f, y = 0x1.ffe002p-70f, z = 0x1.0002p-133f;
+	f1 = fmaf(x, y, z);
+	f2 = 0x1.0001p-133;
+	printf("fmaf: %a %s\n", f1, "  expecting 0x1.0001p-133");
+	ATF_CHECK_MSG(f1 == f2, "%a %a", f1, f2);
+
+	x = -0x1.26524ep-54f, y = -0x1.cb7868p+11f, z = 0x1.d10f5ep-29f;
+	f1 = fmaf(x, y, z);
+	f2 = 0x1.d1179ep-29;
+	printf("fmaf: %a, %s\n", f1, "expecting 0x1.d1179ep-29");
+	ATF_CHECK_MSG(f1 == f2, "%a %a", f1, f2);
+
+	x = 0x1p-120f, y = 0x1p-120f, z = 0x1p-149f;
+	f1 = fmaf(x, y, z);
+	f2 = 0x1p-149;
+	printf("fmaf: %a, %s\n", f1, "      expecting 0x1p-149");
+	ATF_CHECK_MSG(f1 == f2, "%a %a", f1, f2);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, zeroes);
@@ -547,9 +571,11 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, big_z);
 	ATF_TP_ADD_TC(tp, accuracy);
 	ATF_TP_ADD_TC(tp, double_rounding);
+	ATF_TP_ADD_TC(tp, fmaf_subnormals);
+
 	/*
 	 * TODO:
-	 * - Tests for subnormals
+	 * - Tests for subnormals for fma
 	 * - Cancellation tests (e.g., z = (double)x*y, but x*y is inexact)
 	 */
 	return (atf_no_error());