Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216100/?format=api
{ "id": 2216100, "url": "http://patchwork.ozlabs.org/api/patches/2216100/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/20260325192357.1284741-8-adhemerval.zanella@linaro.org/", "project": { "id": 41, "url": "http://patchwork.ozlabs.org/api/projects/41/?format=api", "name": "GNU C Library", "link_name": "glibc", "list_id": "libc-alpha.sourceware.org", "list_email": "libc-alpha@sourceware.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260325192357.1284741-8-adhemerval.zanella@linaro.org>", "list_archive_url": null, "date": "2026-03-25T19:22:25", "name": "[7/8] math: Consolidate common definitions for cosf/sinf/tanf/sincosf", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "81898fbca258fec70d4b1262c39403be47531c23", "submitter": { "id": 66065, "url": "http://patchwork.ozlabs.org/api/people/66065/?format=api", "name": "Adhemerval Zanella Netto", "email": "adhemerval.zanella@linaro.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/20260325192357.1284741-8-adhemerval.zanella@linaro.org/mbox/", "series": [ { "id": 497503, "url": "http://patchwork.ozlabs.org/api/series/497503/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=497503", "date": "2026-03-25T19:22:18", "name": "Add sinf/cosf/sincosf CORE-MATH implementations", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/497503/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2216100/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216100/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "libc-alpha@sourceware.org" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "libc-alpha@sourceware.org" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=l0wIBn4G;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org;\n receiver=patchwork.ozlabs.org)", "sourceware.org;\n\tdkim=pass (2048-bit key,\n unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256\n header.s=google header.b=l0wIBn4G", "sourceware.org;\n dmarc=pass (p=none dis=none) header.from=linaro.org", "sourceware.org; spf=pass smtp.mailfrom=linaro.org", "server2.sourceware.org;\n arc=none smtp.remote-ip=2607:f8b0:4864:20::a36" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fgxpt0Hn6z1xy3\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 06:31:18 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id DC4054BAD15D\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 19:31:15 +0000 (GMT)", "from mail-vk1-xa36.google.com (mail-vk1-xa36.google.com\n [IPv6:2607:f8b0:4864:20::a36])\n by sourceware.org (Postfix) with ESMTPS id C7BF24BB590E\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 19:24:22 +0000 (GMT)", "by mail-vk1-xa36.google.com with SMTP id\n 71dfb90a1353d-56ce1384618so200489e0c.1\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 12:24:22 -0700 (PDT)", "from mandiga.. ([2804:1b3:a7c1:90ea:f31d:ca7d:f8dd:c20b])\n by smtp.gmail.com with ESMTPSA id\n 71dfb90a1353d-56d31d394fcsm1040021e0c.12.2026.03.25.12.24.19\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 Mar 2026 12:24:21 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org DC4054BAD15D", "OpenDKIM Filter v2.11.0 sourceware.org C7BF24BB590E" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org C7BF24BB590E", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org C7BF24BB590E", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774466662; cv=none;\n b=M3/sI5sLRuTJIbaCCAETa+xvW600daq9KCho1/RptW+gUj0/S4hOcTZpixboFqNEQExGwhrlo2OEKF8iXV4t/GSm1SlPgPM0imVOj6wwU7qPp7LPg/G6MDIKNAloYaUxptVvgTW+3Tab3h76h3995/3dXM82pEbiljNUVs9xg7E=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774466662; c=relaxed/simple;\n bh=VoVpS9vd5ZHbsrxkIIi98zxb6cJeOPalQjtjKBNHI5U=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=a5f8TpCU5u9XCvOyAES3stuDxFQY2ZRvfX1VqzNPfiUsA4j5ugOClmu6s3dw1S1xWFo82MsrIpkf1joPBTLenpkd/KXSk6TXh44WBSQqmQsjTkrBqLyAj5Wpw187zve5qaoZNWbshhIaueKK63WylUO7PzZ7PcZOlzbLNnbsTKY=", "ARC-Authentication-Results": "i=1; server2.sourceware.org", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=linaro.org; s=google; t=1774466662; x=1775071462; darn=sourceware.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=mbZwTzJo7Eo53aszNM2W6sjlbFFt4Lxr32/w2rjQeL4=;\n b=l0wIBn4GIjtOsXEKmjEVirnF+x454Eh+Bm9/sgSiI0OllUpE7Uhu/A+E9qkJ9vTkfG\n hXOQkry415rcMgchERN5sQIDgxGfhkjo973bsKt51wFx44+ADR5EEkh+XxfaqRrsww9g\n xenKMTseLOjeNyHlMWMzKm/CrTT65caq2V73XLaGMI79MIrH+P68ocVDNldDThHWOW4W\n pPVM6AyPew0TiHrPVIjJYDyXBZhUQmtbtgI6i3vVT18G3HoUNr0QjoMLOvZV0KefCSiQ\n lIhD/8PrPQAU1cKESZJsAgW1n9pf2y5KK/hjR5zpHS6PfKsHBVuiLtmA0iC2vcosZeV0\n GiUw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774466662; x=1775071462;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=mbZwTzJo7Eo53aszNM2W6sjlbFFt4Lxr32/w2rjQeL4=;\n b=Fh8tCze4Zs5cjpBM/BrSPJSHYxz4EvTsJAYwqPt7MGda4uX8HmHYKJ8kyAejKe1PLt\n JlPTYzFzaoikQMM9jLYMmYsQDM0NIGYf2orJfS7qnOWcTVhph31JCSiQkXC66LGCw7a6\n CPZpMVKXjH9N+aQLnF+DChLGr804hTfFkX0coxSy+qVYIV/91q8GFBs4ql9Qsa/Pecgh\n i7saU9lo7jfPoEjNg3qnv0Z1Vu/wPNZA9lU/oz+cp0o/9diC46wmdFUtOVwGh6dRxny2\n 1pPhvV8ZtZ9QdR6FEk555QBE8agSBeaELUleS71F0bvnvXnXVho1FqESztoeiaPmlqd4\n ZU1A==", "X-Gm-Message-State": "AOJu0YxnlxniFQ2l9qjMP7vAKoxvcYA7b39S/erEs+c7NYsjo4xUJsUT\n zDzGV4Q2ngPgj2FbGhAQ6OXgwa50x1P1esC4JwjoCM6qdP5FDc3ivz6lcKu30PTRnnHKSQIjxxd\n rxfV4", "X-Gm-Gg": "ATEYQzx28IK+w1f/kBSfkW0ThcE2xTifmyRHjNmw9FJoFzrD8BwZv3uGH8M20j8qSH3\n IrPLxLkR83rnBFmAxVb+OtCBc0lavNrnIec/0FU2yWKFXIZ6cveH1nOwj5/+evFQEXpCFNT2LwT\n p05O1VoLAjQM3F2+n9mfNG9CqzLG2Ng9MEXflEeM7C46IbgaIIaQu8SFN+v2HBkwl+33dp7pr0X\n j08gr1RuQmB2rY5v/aJl5FnJFOzVlRnM+bnulWimTjNgvQsorVr36JEdYut/u1NgbMLKieAB5hD\n LWsXxjuLS03wo1VCp7MBPASXDTT/ZO7UtHhTL3odjA7RyoNwE8iIc1hvut3/1fh3P0gDgdNzdWN\n A43uHgRl9ENmBj15Td/4FNHQ9PYjIqpvSh7ch70OhT7gaXvbINu5OvU0OmEy/WJxVzZ9KPGEUfp\n F4vaqXvdhF+83z3G2n3gc0wgPh32w6ni0+EEc=", "X-Received": "by 2002:a05:6122:3d03:b0:563:7062:2a75 with SMTP id\n 71dfb90a1353d-56d21f9d5abmr2637692e0c.8.1774466661649;\n Wed, 25 Mar 2026 12:24:21 -0700 (PDT)", "From": "Adhemerval Zanella <adhemerval.zanella@linaro.org>", "To": "libc-alpha@sourceware.org", "Cc": "Paul Zimmermann <Paul.Zimmermann@inria.fr>,\n\tDJ Delorie <dj@redhat.com>", "Subject": "[PATCH 7/8] math: Consolidate common definitions for\n cosf/sinf/tanf/sincosf", "Date": "Wed, 25 Mar 2026 16:22:25 -0300", "Message-ID": "<20260325192357.1284741-8-adhemerval.zanella@linaro.org>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260325192357.1284741-1-adhemerval.zanella@linaro.org>", "References": "<20260325192357.1284741-1-adhemerval.zanella@linaro.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libc-alpha@sourceware.org", "X-Mailman-Version": "2.1.30", "Precedence": "list", "List-Id": "Libc-alpha mailing list <libc-alpha.sourceware.org>", "List-Unsubscribe": "<https://sourceware.org/mailman/options/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe>", "List-Archive": "<https://sourceware.org/pipermail/libc-alpha/>", "List-Post": "<mailto:libc-alpha@sourceware.org>", "List-Help": "<mailto:libc-alpha-request@sourceware.org?subject=help>", "List-Subscribe": "<https://sourceware.org/mailman/listinfo/libc-alpha>,\n <mailto:libc-alpha-request@sourceware.org?subject=subscribe>", "Errors-To": "libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org" }, "content": "The rbig does not use floating-point instructions, so it can be on a\ndifferent TU and not be built multiple times for multiarch (since the\nresulting code will be similar and not a hotspot).\n\nChecked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,\nand powerpc64le-linux-gnu.\n---\n math/Makefile | 1 +\n sysdeps/ieee754/flt-32/s_cosf.c | 64 +---------------\n sysdeps/ieee754/flt-32/s_sincosf.c | 71 +-----------------\n sysdeps/ieee754/flt-32/s_sincosf_common.c | 90 +++++++++++++++++++++++\n sysdeps/ieee754/flt-32/s_sincosf_common.h | 63 ++++++++++++++++\n sysdeps/ieee754/flt-32/s_sinf.c | 71 +-----------------\n sysdeps/ieee754/flt-32/s_tanf.c | 65 ++--------------\n 7 files changed, 166 insertions(+), 259 deletions(-)\n create mode 100644 sysdeps/ieee754/flt-32/s_sincosf_common.c\n create mode 100644 sysdeps/ieee754/flt-32/s_sincosf_common.h", "diff": "diff --git a/math/Makefile b/math/Makefile\nindex 7a9352c2cd..eaea4c77b9 100644\n--- a/math/Makefile\n+++ b/math/Makefile\n@@ -389,6 +389,7 @@ type-float-routines := \\\n s_asincosf_data \\\n s_asincoshf_data \\\n s_asincospif_data \\\n+ s_sincosf_common \\\n s_sincosf_data \\\n s_sincospif_data \\\n # type-float-routines\ndiff --git a/sysdeps/ieee754/flt-32/s_cosf.c b/sysdeps/ieee754/flt-32/s_cosf.c\nindex 2bef3b3036..47ebc530c6 100644\n--- a/sysdeps/ieee754/flt-32/s_cosf.c\n+++ b/sysdeps/ieee754/flt-32/s_cosf.c\n@@ -31,69 +31,9 @@ SOFTWARE.\n #include <libm-alias-float.h>\n #include \"math_config.h\"\n #include <math_uint128.h>\n+#include <s_sincosf_common.h>\n #include <s_sincosf_data.h>\n \n-static double __attribute__ ((noinline))\n-rbig (uint32_t u, int *q)\n-{\n- int e = (u >> 23) & 0xff, i;\n- uint64_t m = (u & (~0u >> 9)) | 1 << 23;\n- u128 p0 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[0]));\n- u128 p1 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[1]));\n- p1 = u128_add (p1, u128_rshift (p0, 64));\n- u128 p2 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[2]));\n- p2 = u128_add (p2, u128_rshift (p1, 64));\n- u128 p3 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[3]));\n- p3 = u128_add (p3, u128_rshift (p2, 64));\n- uint64_t p3h = u128_high (p3), p3l = u128_low (p3), p2l = u128_low (p2),\n-\t p1l = u128_low (p1);\n- int64_t A;\n- int k = e - 124, s = k - 23;\n- /* in cr_sinf(), rbig() is called in the case 127+28 <= e < 0xff\n- thus 155 <= e <= 254, which yields 28 <= k <= 127 and 5 <= s <= 104 */\n- if (s < 64)\n- {\n- i = p3h << s | p3l >> (64 - s);\n- A = p3l << s | p2l >> (64 - s);\n- }\n- else if (s == 64)\n- {\n- i = p3l;\n- A = p2l;\n- }\n- else\n- { /* s > 64 */\n- i = p3l << (s - 64) | p2l >> (128 - s);\n- A = p2l << (s - 64) | p1l >> (128 - s);\n- }\n- int sgn = u;\n- sgn >>= 31;\n- int64_t sm = A >> 63;\n- i -= sm;\n- double z = (A ^ sgn) * 0x1p-64;\n- i = (i ^ sgn) - sgn;\n- *q = i;\n- return z;\n-}\n-\n-static inline double\n-rltl (float z, int *q)\n-{\n- double x = z;\n- double idl = -0x1.b1bbead603d8bp-29 * x, idh = 0x1.45f306ep+2 * x,\n-\t id = roundeven_finite (idh);\n- *q = asuint64 (0x1.8p52 + id);\n- return (idh - id) + idl;\n-}\n-\n-static inline double\n-rltl0 (double x, int *q)\n-{\n- double idh = 0x1.45f306dc9c883p+2 * x, id = roundeven_finite (idh);\n- *q = asuint64 (0x1.8p52 + id);\n- return idh - id;\n-}\n-\n static float __attribute__ ((noinline))\n as_cosf_database (float x, double r)\n {\n@@ -117,7 +57,7 @@ as_cosf_big (float x)\n return __math_invalidf (x);\n }\n int ia;\n- double z = rbig (t, &ia);\n+ double z = RBIG_SINCOSF (t, &ia);\n double z2 = z * z, z4 = z2 * z2;\n double aa = (A[0] + z2 * A[1]) + z4 * (A[2] + z2 * A[3]);\n double bb = (B[0] + z2 * B[1]) + z4 * (B[2] + z2 * B[3]);\ndiff --git a/sysdeps/ieee754/flt-32/s_sincosf.c b/sysdeps/ieee754/flt-32/s_sincosf.c\nindex eb5d849174..9bb5b84a02 100644\n--- a/sysdeps/ieee754/flt-32/s_sincosf.c\n+++ b/sysdeps/ieee754/flt-32/s_sincosf.c\n@@ -29,6 +29,7 @@ SOFTWARE.\n #include <libm-alias-float.h>\n #include \"math_config.h\"\n #include <math_uint128.h>\n+#include <s_sincosf_common.h>\n #include <s_sincosf_data.h>\n \n #ifndef SECTION\n@@ -41,74 +42,6 @@ SOFTWARE.\n # define SINCOSF_FUNC SINCOSF\n #endif\n \n-static double __attribute__ ((noinline))\n-rbig (uint32_t u, int *q)\n-{\n- int e = (u >> 23) & 0xff, i;\n- uint64_t m = (u & (~0u >> 9)) | 1 << 23;\n- u128 p0 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[0]));\n- u128 p1 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[1]));\n- p1 = u128_add (p1, u128_rshift (p0, 64));\n- u128 p2 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[2]));\n- p2 = u128_add (p2, u128_rshift (p1, 64));\n- u128 p3 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[3]));\n- p3 = u128_add (p3, u128_rshift (p2, 64));\n- uint64_t p3h = u128_high (p3), p3l = u128_low (p3), p2l = u128_low (p2),\n-\t p1l = u128_low (p1);\n- int64_t a;\n- int k = e - 124, s = k - 23;\n- /* in cr_sinf(), rbig() is called in the case 127+28 <= e < 0xff\n- thus 155 <= e <= 254, which yields 28 <= k <= 127 and 5 <= s <= 104 */\n- if (s < 64)\n- {\n- i = p3h << s | p3l >> (64 - s);\n- a = p3l << s | p2l >> (64 - s);\n- }\n- else if (s == 64)\n- {\n- i = p3l;\n- a = p2l;\n- }\n- else\n- { /* s > 64 */\n- i = p3l << (s - 64) | p2l >> (128 - s);\n- a = p2l << (s - 64) | p1l >> (128 - s);\n- }\n- int sgn = u;\n- sgn >>= 31;\n- int64_t sm = a >> 63;\n- i -= sm;\n- double z = (a ^ sgn) * 0x1p-64;\n- i = (i ^ sgn) - sgn;\n- *q = i;\n- return z;\n-}\n-\n-static inline double\n-rltl (float z, int *q)\n-{\n- double x = z;\n- double idl = -0x1.b1bbead603d8bp-29 * x, idh = 0x1.45f306ep+2 * x,\n-\t id = roundeven_finite (idh);\n- *q = asuint64 (0x1.8p52 + id);\n- return (idh - id) + idl;\n-}\n-\n-static inline double\n-rltl0 (double x, int *q)\n-{\n- double idh = 0x1.45f306dc9c883p+2 * x, id = roundeven_finite (idh);\n- *q = asuint64 (0x1.8p52 + id);\n- return idh - id;\n-}\n-\n-static inline float\n-add_sign (float x, float rh, float rl)\n-{\n- float sgn = copysignf (1.0f, x);\n- return sgn * rh + sgn * rl;\n-}\n-\n static void __attribute__ ((noinline))\n as_sincosf_database (float x, float *sout, float *cout)\n {\n@@ -141,7 +74,7 @@ as_sincosf_big (float x, float *sout, float *cout)\n return;\n }\n int ia;\n- double z = rbig (t, &ia);\n+ double z = RBIG_SINCOSF (t, &ia);\n double z2 = z * z, z4 = z2 * z2;\n double aa = (A[0] + z2 * A[1]) + z4 * (A[2] + z2 * A[3]);\n double bb = (B[0] + z2 * B[1]) + z4 * (B[2] + z2 * B[3]);\ndiff --git a/sysdeps/ieee754/flt-32/s_sincosf_common.c b/sysdeps/ieee754/flt-32/s_sincosf_common.c\nnew file mode 100644\nindex 0000000000..6d0f47d402\n--- /dev/null\n+++ b/sysdeps/ieee754/flt-32/s_sincosf_common.c\n@@ -0,0 +1,90 @@\n+/* Common routines for sinf/cosf/tanf/sincosf.\n+\n+Copyright (c) 2022-2026 Alexei Sibidanov.\n+\n+The original version of this file was copied from the CORE-MATH\n+project (file src/binary32/tan/tanf.c, revision 59d21d7).\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n+*/\n+\n+#include <math_uint128.h>\n+#include <s_sincosf_common.h>\n+#include <s_sincosf_data.h>\n+\n+static double\n+rbig (uint32_t u, int *q, int e_bias)\n+{\n+ int e = (u >> 23) & 0xff, i;\n+ uint64_t m = (u & (~0u >> 9)) | 1 << 23;\n+ u128 p0 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[0]));\n+ u128 p1 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[1]));\n+ p1 = u128_add (p1, u128_rshift (p0, 64));\n+ u128 p2 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[2]));\n+ p2 = u128_add (p2, u128_rshift (p1, 64));\n+ u128 p3 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[3]));\n+ p3 = u128_add (p3, u128_rshift (p2, 64));\n+ uint64_t p3h = u128_high (p3), p3l = u128_low (p3), p2l = u128_low (p2),\n+\t p1l = u128_low (p1);\n+ int64_t a;\n+ int k = e - e_bias, s = k - 23;\n+ /* in cr_sinf(), rbig() is called in the case 127+28 <= e < 0xff\n+ thus 155 <= e <= 254, which yields 28 <= k <= 127 and 5 <= s <= 104 */\n+ if (s < 64)\n+ {\n+ i = p3h << s | p3l >> (64 - s);\n+ a = p3l << s | p2l >> (64 - s);\n+ }\n+ else if (s == 64)\n+ {\n+ i = p3l;\n+ a = p2l;\n+ }\n+ else\n+ { /* s > 64 */\n+ i = p3l << (s - 64) | p2l >> (128 - s);\n+ a = p2l << (s - 64) | p1l >> (128 - s);\n+ }\n+ int sgn = u;\n+ sgn >>= 31;\n+ int64_t sm = a >> 63;\n+ i -= sm;\n+ double z = (a ^ sgn) * 0x1p-64;\n+ i = (i ^ sgn) - sgn;\n+ *q = i;\n+ return z;\n+}\n+\n+double\n+__sincosf_rbig (uint32_t u, int *q)\n+{\n+ /* in cr_sinf(), rbig() is called in the case 127+28 <= e < 0xff\n+ thus 155 <= e <= 254, which yields 28 <= k <= 127 and 5 <= s <= 104 */\n+ return rbig (u, q, 124);\n+}\n+\n+/* argument reduction\n+ same as rltl, but for |x| >= 2^28 */\n+double\n+__tanf_rbig (uint32_t u, int *q)\n+{\n+ /* in ctanf(), rbig() is called in the case 127+28 <= e < 0xff\n+ thus 155 <= e <= 254, which yields 28 <= k <= 127 and 5 <= s <= 104 */\n+ return rbig (u, q, 127);\n+}\ndiff --git a/sysdeps/ieee754/flt-32/s_sincosf_common.h b/sysdeps/ieee754/flt-32/s_sincosf_common.h\nnew file mode 100644\nindex 0000000000..a15a0afe80\n--- /dev/null\n+++ b/sysdeps/ieee754/flt-32/s_sincosf_common.h\n@@ -0,0 +1,63 @@\n+/* Common routines for sinf/cosf/tanf/sincosf.\n+\n+Copyright (c) 2022-2026 Alexei Sibidanov.\n+\n+The original version of this file was copied from the CORE-MATH\n+project (file src/binary32/tan/tanf.c, revision 59d21d7).\n+\n+Permission is hereby granted, free of charge, to any person obtaining a copy\n+of this software and associated documentation files (the \"Software\"), to deal\n+in the Software without restriction, including without limitation the rights\n+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+copies of the Software, and to permit persons to whom the Software is\n+furnished to do so, subject to the following conditions:\n+\n+The above copyright notice and this permission notice shall be included in all\n+copies or substantial portions of the Software.\n+\n+THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+SOFTWARE.\n+*/\n+\n+#ifndef _S_SINCOSF_COMMON_H\n+#define _S_SINCOSF_COMMON_H\n+\n+#include <stdint.h>\n+#include \"math_config.h\"\n+\n+static inline double\n+rltl0 (double x, int *q)\n+{\n+ double idh = 0x1.45f306dc9c883p+2 * x, id = roundeven_finite (idh);\n+ *q = asuint64 (0x1.8p52 + id);\n+ return idh - id;\n+}\n+\n+static inline double\n+rltl (float z, int *q)\n+{\n+ double x = z;\n+ double idl = -0x1.b1bbead603d8bp-29 * x, idh = 0x1.45f306ep+2 * x,\n+\t id = roundeven_finite (idh);\n+ *q = asuint64 (0x1.8p52 + id);\n+ return (idh - id) + idl;\n+}\n+\n+static inline float\n+add_sign (float x, float rh, float rl)\n+{\n+ float sgn = copysignf (1.0f, x);\n+ return sgn * rh + sgn * rl;\n+}\n+\n+extern double __tanf_rbig (uint32_t u, int *q) attribute_hidden;\n+#define RBIG_TANF __tanf_rbig\n+extern double __sincosf_rbig (uint32_t u, int *q) attribute_hidden;\n+#define RBIG_SINCOSF __sincosf_rbig\n+\n+#endif\ndiff --git a/sysdeps/ieee754/flt-32/s_sinf.c b/sysdeps/ieee754/flt-32/s_sinf.c\nindex 45d8a62a44..795a9131ba 100644\n--- a/sysdeps/ieee754/flt-32/s_sinf.c\n+++ b/sysdeps/ieee754/flt-32/s_sinf.c\n@@ -31,6 +31,7 @@ SOFTWARE.\n #include <libm-alias-float.h>\n #include \"math_config.h\"\n #include <math_uint128.h>\n+#include <s_sincosf_common.h>\n #include <s_sincosf_data.h>\n \n #ifndef SECTION\n@@ -43,74 +44,6 @@ SOFTWARE.\n # define SINF_FUNC SINF\n #endif\n \n-static double __attribute__ ((noinline))\n-rbig (uint32_t u, int *q)\n-{\n- int e = (u >> 23) & 0xff, i;\n- uint64_t m = (u & (~0u >> 9)) | 1 << 23;\n- u128 p0 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[0]));\n- u128 p1 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[1]));\n- p1 = u128_add (p1, u128_rshift (p0, 64));\n- u128 p2 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[2]));\n- p2 = u128_add (p2, u128_rshift (p1, 64));\n- u128 p3 = u128_mul (u128_from_u64 (m), u128_from_u64 (IPI[3]));\n- p3 = u128_add (p3, u128_rshift (p2, 64));\n- uint64_t p3h = u128_high (p3), p3l = u128_low (p3), p2l = u128_low (p2),\n-\t p1l = u128_low (p1);\n- int64_t a;\n- int k = e - 124, s = k - 23;\n- /* in cr_sinf(), rbig() is called in the case 127+28 <= e < 0xff\n- thus 155 <= e <= 254, which yields 28 <= k <= 127 and 5 <= s <= 104 */\n- if (s < 64)\n- {\n- i = p3h << s | p3l >> (64 - s);\n- a = p3l << s | p2l >> (64 - s);\n- }\n- else if (s == 64)\n- {\n- i = p3l;\n- a = p2l;\n- }\n- else\n- { /* s > 64 */\n- i = p3l << (s - 64) | p2l >> (128 - s);\n- a = p2l << (s - 64) | p1l >> (128 - s);\n- }\n- int sgn = u;\n- sgn >>= 31;\n- int64_t sm = a >> 63;\n- i -= sm;\n- double z = (a ^ sgn) * 0x1p-64;\n- i = (i ^ sgn) - sgn;\n- *q = i;\n- return z;\n-}\n-\n-static inline double\n-rltl (float z, int *q)\n-{\n- double x = z;\n- double idl = -0x1.b1bbead603d8bp-29 * x, idh = 0x1.45f306ep+2 * x,\n-\t id = roundeven_finite (idh);\n- *q = asuint64 (0x1.8p52 + id);\n- return (idh - id) + idl;\n-}\n-\n-static inline double\n-rltl0 (double x, int *q)\n-{\n- double idh = 0x1.45f306dc9c883p+2 * x, id = roundeven_finite (idh);\n- *q = asuint64 (0x1.8p52 + id);\n- return idh - id;\n-}\n-\n-static inline float\n-add_sign (float x, float rh, float rl)\n-{\n- float sgn = copysignf (1.0f, x);\n- return sgn * rh + sgn * rl;\n-}\n-\n static float __attribute__ ((noinline))\n as_sinf_database (float x, double r)\n {\n@@ -133,7 +66,7 @@ as_sinf_big (float x)\n return __math_invalidf (x);\n }\n int ia;\n- double z = rbig (t, &ia);\n+ double z = RBIG_SINCOSF (t, &ia);\n double z2 = z * z, z4 = z2 * z2;\n double aa = (A[0] + z2 * A[1]) + z4 * (A[2] + z2 * A[3]);\n double bb = (B[0] + z2 * B[1]) + z4 * (B[2] + z2 * B[3]);\ndiff --git a/sysdeps/ieee754/flt-32/s_tanf.c b/sysdeps/ieee754/flt-32/s_tanf.c\nindex 5ee1d6f35e..d14c1f11bd 100644\n--- a/sysdeps/ieee754/flt-32/s_tanf.c\n+++ b/sysdeps/ieee754/flt-32/s_tanf.c\n@@ -1,6 +1,6 @@\n /* Correctly-rounded tangent of binary32 value.\n \n-Copyright (c) 2022-2024 Alexei Sibidanov.\n+Copyright (c) 2022-2026 Alexei Sibidanov.\n \n The original version of this file was copied from the CORE-MATH\n project (file src/binary32/tan/tanf.c, revision 59d21d7).\n@@ -27,13 +27,12 @@ SOFTWARE.\n #include <array_length.h>\n #include <stdint.h>\n #include <libm-alias-float.h>\n-#include \"math_config.h\"\n-#include <math_uint128.h>\n+#include <s_sincosf_common.h>\n \n /* argument reduction\n for |z| < 2^28, return r such that 2/pi*x = q + r */\n-static inline double\n-rltl (float z, int *q)\n+static __always_inline double\n+rltl_tanf (float z, int *q)\n {\n double x = z;\n double idl = -0x1.b1bbead603d8bp-32 * x;\n@@ -43,58 +42,6 @@ rltl (float z, int *q)\n return (idh - id) + idl;\n }\n \n-/* argument reduction\n- same as rltl, but for |x| >= 2^28 */\n-static double __attribute__ ((noinline))\n-rbig (uint32_t u, int *q)\n-{\n- static const uint64_t ipi[] =\n- {\n- 0xfe5163abdebbc562, 0xdb6295993c439041,\n- 0xfc2757d1f534ddc0, 0xa2f9836e4e441529\n- };\n- int e = (u >> 23) & 0xff, i;\n- uint64_t m = (u & (~0u >> 9)) | 1 << 23;\n- u128 p0 = u128_mul (u128_from_u64 (m), u128_from_u64 (ipi[0]));\n- u128 p1 = u128_mul (u128_from_u64 (m), u128_from_u64 (ipi[1]));\n- p1 = u128_add (p1, u128_rshift (p0, 64));\n- u128 p2 = u128_mul (u128_from_u64 (m), u128_from_u64 (ipi[2]));\n- p2 = u128_add (p2, u128_rshift (p1, 64));\n- u128 p3 = u128_mul (u128_from_u64 (m), u128_from_u64 (ipi[3]));\n- p3 = u128_add (p3, u128_rshift (p2, 64));\n- uint64_t p3h = u128_high (p3);\n- uint64_t p3l = u128_low (p3);\n- uint64_t p2l = u128_low (p2);\n- uint64_t p1l = u128_low (p1);\n- int64_t a;\n- int k = e - 127, s = k - 23;\n- /* in ctanf(), rbig() is called in the case 127+28 <= e < 0xff\n- thus 155 <= e <= 254, which yields 28 <= k <= 127 and 5 <= s <= 104 */\n- if (s < 64)\n- {\n- i = p3h << s | p3l >> (64 - s);\n- a = p3l << s | p2l >> (64 - s);\n- }\n- else if (s == 64)\n- {\n- i = p3l;\n- a = p2l;\n- }\n- else\n- { /* s > 64 */\n- i = p3l << (s - 64) | p2l >> (128 - s);\n- a = p2l << (s - 64) | p1l >> (128 - s);\n- }\n- int sgn = u;\n- sgn >>= 31;\n- int64_t sm = a >> 63;\n- i -= sm;\n- double z = (a ^ sgn) * 0x1p-64;\n- i = (i ^ sgn) - sgn;\n- *q = i;\n- return z;\n-}\n-\n float\n __tanf (float x)\n {\n@@ -111,10 +58,10 @@ __tanf (float x)\n \t float x2 = x * x;\n \t return fmaf (x, 0x1.555556p-2f * x2, x);\n \t}\n- z = rltl (x, &i);\n+ z = rltl_tanf (x, &i);\n }\n else if (e < 0xff)\n- z = rbig (t, &i);\n+ z = RBIG_TANF (t, &i);\n else\n {\n if (t << 9)\n", "prefixes": [ "7/8" ] }