Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216083/?format=api
{ "id": 2216083, "url": "http://patchwork.ozlabs.org/api/patches/2216083/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/20260325192357.1284741-5-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-5-adhemerval.zanella@linaro.org>", "list_archive_url": null, "date": "2026-03-25T19:22:22", "name": "[4/8] math: Use sinf from CORE-MATH", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b898287f5bc5b691b411601703667303bc34c278", "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-5-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/2216083/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216083/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=MeGXhvxh;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org\n (client-ip=2620:52:6:3111::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=MeGXhvxh", "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::a2b" ], "Received": [ "from vm01.sourceware.org (vm01.sourceware.org\n [IPv6:2620:52:6:3111::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 4fgxkR6LjGz1y1K\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 06:27:27 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 0184C4BB5890\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 19:27:26 +0000 (GMT)", "from mail-vk1-xa2b.google.com (mail-vk1-xa2b.google.com\n [IPv6:2607:f8b0:4864:20::a2b])\n by sourceware.org (Postfix) with ESMTPS id 14BD94BB58F2\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 19:24:16 +0000 (GMT)", "by mail-vk1-xa2b.google.com with SMTP id\n 71dfb90a1353d-56a857578a8so145282e0c.3\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 12:24:16 -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.12\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 Mar 2026 12:24:13 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 0184C4BB5890", "OpenDKIM Filter v2.11.0 sourceware.org 14BD94BB58F2" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 14BD94BB58F2", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 14BD94BB58F2", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774466656; cv=none;\n b=dtpEofBOT9y3rD7WYA3K4pEvA7pv2T52YLK1VIcnr+cKI7hw5tbDyHtWe0kparGn8Fkw5dmrWYMiLJ3gzzZ6OuQhZqhPse2wNBodzZpnzqjAz7B6asmfXgF1vALU0iI/psZ/54ZCIQq1LzUsCGWvTMdHZGq52ozQd5z1+VTwQqo=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774466656; c=relaxed/simple;\n bh=ztF19GFMHNVoOryLDnbT9EzFCB/3XLU1jVKH+/TEseE=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=iuSyqNSuueyOAeEeJIKiXNa2I6FhWsb3bTxN2qPd3q7LiJ23waykw+dr036gIUqjU5rDazVnZC7HYgOslw1uSnYP/P+Gc9ysQxE1FiWEJOM6jKfEdW/Z9MALqvfUNiQvs0yTBa62wXOnPDE0/YLXyj2iAW+SnmYNEGPhiBDZkQk=", "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=1774466655; x=1775071455; 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=Mw4DiAgJqbos5oEMHccqrTJvrtsH/umKSDTkwWw8Z5g=;\n b=MeGXhvxh0kejX0DPHwako8ITzuj12p0wZgQptFhdyv81sXg9f22A7C180vmrImjwv+\n vce4ENSVvdiYea4ySPPkOKgrCXYUzt2FnqgGXzgX2dbYxs7Suo5bdi23P7hHt5VhOSaV\n YYbJxwm8/ppFAGgOaHXWWwVhKM4QJsjZrhgjtUzTgKDJdActfDov+cBEAoNVdtMd7+MB\n TMZvTnU8nIPuyf1zduoEZhdmt2oTCMPqH4ku1kZ3/ajyDtpk/d3FCYAyfqDAk3UveWN+\n k1NW3fMGuh8sd0NSOXQVBeoaYLWW1rVIpx7uURApmfU6hMaskFfQXiBrhLBovEXIBCnO\n YaIQ==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774466655; x=1775071455;\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=Mw4DiAgJqbos5oEMHccqrTJvrtsH/umKSDTkwWw8Z5g=;\n b=R7TWfV+OsKgDNZs0qFlYbww/n27NC5TDuNZQjVmrOrzzkGVHcg1l3ry9Y5jkYHDYIR\n UqOm+XD9c5RBaTRR/lQPXrpTFWmSWiU0gslThEOVEzmioEu3ta03e6NzfwFdobN9pnHV\n r34na+lp9gr4w9zoKNk55FWEwxF11O2pimJtpZSQmscebmmvkfDiD8ltrnd9HlyzAJdL\n LeUJ2uJVisuM9xJmLTJ16qrJ7gzkzKkwyVsWw0btm0Ep8Q3XTDwB6X5zUFgW9TPbL7+U\n wpnwQBTtFCxM47fnVeDtMYqfE2pwt/BiftKqhHMNl9t1M2azHsbHfTN+ih/UvCm1qx3k\n ZndA==", "X-Gm-Message-State": "AOJu0Yxu47ccPnRl1J0FCu9GVTmPjGeuu3ODmHEN6LczUwUNXFl06DaP\n KEmz/RFkyYnz2MLWD40ilVoF/JX9vA4E7Uy7m/EkakU0lRMjHsD+9fbTHR4uUp8rcfTFCzbPEKf\n Ae7we", "X-Gm-Gg": "ATEYQzxeRvvr1I6D3aJNEAPhKoJQGVQ2RWD7vy8QOvZCUqJkLr6gOABU7u6pDgiocBV\n WLPoF7ol1mGH1LWdg6fHbBFVu7fFUX5XG69qqROe+wl0ECLzEjk8yHocqIcbRSkW3BRUzr17aof\n kAtWfpzGkTbF2WPGXPfs7Jtq964+2hro9VDbeaG2PT7PvR7prJmmuuqaJ3wd9QrezKkc5zySfIV\n vfjLszDUZXsvcdm3jQhpHTRTweYk7AnssxTgoBSxCDlZrOX6hcTj8pEGSPNDMjxnVGiMnf/yD0z\n kF86d9jsHEZwgEUPONvfajTcpnfve/bagsqK+sXMzDear2jxgKke23dFfQHO/UPRWu3ggb26p1M\n oZ9kjyG3fcYbBkThwKqaEoTGXGCwjoFxZKXJzrscGo8rLPQ0TqrMP+SHtEj6qK+xT4c82RW31RD\n 79SFfkCxwurAuJIgzaN4PV0MpFZSOcea3x8qACYt/swBHTpA==", "X-Received": "by 2002:a05:6123:a9:b0:56a:e25f:fc87 with SMTP id\n 71dfb90a1353d-56d21fa0afcmr2385878e0c.7.1774466654713;\n Wed, 25 Mar 2026 12:24:14 -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 4/8] math: Use sinf from CORE-MATH", "Date": "Wed, 25 Mar 2026 16:22:22 -0300", "Message-ID": "<20260325192357.1284741-5-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 CORE-MATH implementation is correctly rounded (in any rounding mode)\nand performs similarly.\n\n* latency\n- input: random (-2*pi, 2*pi)\n master patched improvement\nx86_64 39.8085 49.1343 -23.43%\nx86_64v2 40.0526 35.4431 11.51%\nx86_64v3 35.3150 35.4092 -0.27%\naarch64 14.1862 13.2657 6.49%\npower10 9.2147 7.9437 13.79%\n\n- input: large (-64, 64)\n master patched improvement\nx86_64 41.8170 50.5771 -20.95%\nx86_64v2 42.0707 37.7077 10.37%\nx86_64v3 37.1012 37.6129 -1.38%\naarch64 14.9308 15.7713 -5.63%\npower10 9.7280 8.7833 9.71%\n\n-input: huge (-1024, 1024)\n master patched improvement\nx86_64 45.4243 50.4141 -10.98%\nx86_64v2 45.6948 38.2110 16.38%\nx86_64v3 40.9413 37.3504 8.77%\naarch64 17.8339 14.9379 16.24%\npower10 10.8863 8.1787 24.87%\n\n* reciprocal-throughput\n- input: random (-2*pi, 2*pi)\n master patched improvement\nx86_64 11.9412 18.2488 -52.82%\nx86_64v2 12.0076 10.9426 8.87%\nx86_64v3 11.4248 10.4730 8.33%\naarch64 7.6716 6.9755 9.07%\npower10 4.5249 3.6755 18.77%\n\n- input: large (-64, 64)\n master patched improvement\nx86_64 11.8827 20.4191 -71.84%\nx86_64v2 11.8933 12.5825 -5.79%\nx86_64v3 11.3743 12.8875 -13.30%\naarch64 8.4026 8.1294 3.25%\npower10 5.1247 4.2635 16.81%\n\n- input :huge (-1024, 1024)\n master patched improvement\nx86_64 15.2653 20.3141 -33.07%\nx86_64v2 15.3004 12.5485 17.99%\nx86_64v3 13.9678 13.0890 6.29%\naarch64 9.6422 7.2273 25.04%\npower10 5.6171 3.7890 32.54%\n\nThe benchmarks were run on x64_64 (Ryzen 9 5900X, gcc 15.2.1)\nwith --disable-multi-arch disable; aarch64 (Neoverse-N1, gcc 15.2.1),\nand powerpc (POWER10, gcc 15.2.1).\n\nThe code is adapted to glibc style and to use the math_config\ndefinition.h (to handle errno, overflow, and underflow).\n\nThe x86_64-v1 shows some performance regression because the CORE-MATH\nimplementation relies on roundeven. The x86_64v2 and forward provide\na specific instruction, and x86_64 already provides an FMA ifunc variant.\n\nChecked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,\nand powerpc64le-linux-gnu.\n---\n SHARED-FILES | 2 +\n sysdeps/ieee754/flt-32/libm-test-ulps | 12 +\n sysdeps/ieee754/flt-32/s_sincosf_data.c | 2 +\n sysdeps/ieee754/flt-32/s_sincosf_data.h | 43 ++++\n .../ieee754/flt-32/s_sincosf_data_generic.c | 71 ++++++\n sysdeps/ieee754/flt-32/s_sinf.c | 235 +++++++++++++-----\n sysdeps/x86/fpu/s_sincosf_data.c | 2 +\n 7 files changed, 300 insertions(+), 67 deletions(-)\n create mode 100644 sysdeps/ieee754/flt-32/s_sincosf_data.h\n create mode 100644 sysdeps/ieee754/flt-32/s_sincosf_data_generic.c", "diff": "diff --git a/SHARED-FILES b/SHARED-FILES\nindex 5a676e1a48..d4b5b30ae4 100644\n--- a/SHARED-FILES\n+++ b/SHARED-FILES\n@@ -306,6 +306,8 @@ core-math:\n sysdeps/ieee754/flt-32/s_log1pf.c\n # src/binary32/log2p1/log2p1f.c revision 3fbe16be\n sysdeps/ieee754/flt-32/s_log2p1f.c\n+ # src/binary32/sin/sinf.c revision 8ea8ea35\n+ sysdeps/ieee754/flt-32/s_sinf.c\n # src/binary32/sinpi/sinpif.c, revision bbfabd99d\n sysdeps/ieee754/flt-32/s_sinpif.c\n # src/binary32/tan/tanf.c, revision 59d21d7\ndiff --git a/sysdeps/ieee754/flt-32/libm-test-ulps b/sysdeps/ieee754/flt-32/libm-test-ulps\nindex 15a7248d8b..2516f54a55 100644\n--- a/sysdeps/ieee754/flt-32/libm-test-ulps\n+++ b/sysdeps/ieee754/flt-32/libm-test-ulps\n@@ -251,6 +251,18 @@ float: 0\n Function: \"log2p1_upward\":\n float: 0\n \n+Function: \"sin\":\n+float: 0\n+\n+Function: \"sin_downward\":\n+float: 0\n+\n+Function: \"sin_towardzero\":\n+float: 0\n+\n+Function: \"sin_upward\":\n+float: 0\n+\n Function: \"sinh\":\n float: 0\n \ndiff --git a/sysdeps/ieee754/flt-32/s_sincosf_data.c b/sysdeps/ieee754/flt-32/s_sincosf_data.c\nindex 2ece6db708..8c914a8bf6 100644\n--- a/sysdeps/ieee754/flt-32/s_sincosf_data.c\n+++ b/sysdeps/ieee754/flt-32/s_sincosf_data.c\n@@ -72,3 +72,5 @@ const uint32_t __inv_pio4[24] =\n 0x34ddc0db, 0xddc0db62, 0xc0db6295, 0xdb629599,\n 0x6295993c, 0x95993c43, 0x993c4390, 0x3c439041\n };\n+\n+#include <sysdeps/ieee754/flt-32/s_sincosf_data_generic.c>\ndiff --git a/sysdeps/ieee754/flt-32/s_sincosf_data.h b/sysdeps/ieee754/flt-32/s_sincosf_data.h\nnew file mode 100644\nindex 0000000000..02465ee931\n--- /dev/null\n+++ b/sysdeps/ieee754/flt-32/s_sincosf_data.h\n@@ -0,0 +1,43 @@\n+/* Compute sine and cosine of argument.\n+ Copyright (C) 2018-2026 Free Software Foundation, Inc.\n+ This file is part of the GNU C Library.\n+\n+ The GNU C Library is free software; you can redistribute it and/or\n+ modify it under the terms of the GNU Lesser General Public\n+ License as published by the Free Software Foundation; either\n+ version 2.1 of the License, or (at your option) any later version.\n+\n+ The GNU C Library is distributed in the hope that it will be useful,\n+ but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n+ Lesser General Public License for more details.\n+\n+ You should have received a copy of the GNU Lesser General Public\n+ License along with the GNU C Library; if not, see\n+ <https://www.gnu.org/licenses/>. */\n+\n+#ifndef _S_SINCOSF_DATA_H\n+#define _S_SINCOSF_DATA_H\n+\n+extern const uint64_t __sinf_ipi[] attribute_hidden;\n+#define IPI __sinf_ipi\n+\n+extern const double __sinf_b[] attribute_hidden;\n+#define B __sinf_b\n+extern const double __sinf_a[] attribute_hidden;\n+#define A __sinf_a\n+extern const double __sinf_tb[] attribute_hidden;\n+#define TB __sinf_tb\n+\n+extern const struct\n+{\n+ union\n+ {\n+ float arg;\n+ uint32_t uarg;\n+ };\n+ float rh, rl;\n+} __sinf_st[4] attribute_hidden;\n+#define ST __sinf_st\n+\n+#endif\ndiff --git a/sysdeps/ieee754/flt-32/s_sincosf_data_generic.c b/sysdeps/ieee754/flt-32/s_sincosf_data_generic.c\nnew file mode 100644\nindex 0000000000..f53251d3d8\n--- /dev/null\n+++ b/sysdeps/ieee754/flt-32/s_sincosf_data_generic.c\n@@ -0,0 +1,71 @@\n+/* Correctly-rounded sine of binary32 value.\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/cosh/coshf.c, revision 8ea8ea35.\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+const uint64_t __sinf_ipi[] =\n+{\n+ 0xfe5163abdebbc562, 0xdb6295993c439041, 0xfc2757d1f534ddc0,\n+ 0xa2f9836e4e441529\n+};\n+\n+const double __sinf_b[] =\n+{\n+ 0x1.3bd3cc9be45dcp-6, -0x1.03c1f081b0833p-14, 0x1.55d3c6fc9ac1fp-24,\n+ -0x1.e1d3ff281b40dp-35\n+};\n+const double __sinf_a[] =\n+{\n+ 0x1.921fb54442d17p-3, -0x1.4abbce6256a39p-10, 0x1.466bc5a518c16p-19,\n+ -0x1.32bdc61074ff6p-29\n+};\n+const double __sinf_tb[] =\n+{\n+ 0x0p+0, 0x1.8f8b83c69a60bp-3, 0x1.87de2a6aea963p-2,\n+ 0x1.1c73b39ae68c8p-1, 0x1.6a09e667f3bcdp-1, 0x1.a9b66290ea1a3p-1,\n+ 0x1.d906bcf328d46p-1, 0x1.f6297cff75cbp-1, 0x1p+0,\n+ 0x1.f6297cff75cbp-1, 0x1.d906bcf328d46p-1, 0x1.a9b66290ea1a3p-1,\n+ 0x1.6a09e667f3bcdp-1, 0x1.1c73b39ae68c8p-1, 0x1.87de2a6aea963p-2,\n+ 0x1.8f8b83c69a60bp-3, 0x0p+0, -0x1.8f8b83c69a60bp-3,\n+ -0x1.87de2a6aea963p-2, -0x1.1c73b39ae68c8p-1, -0x1.6a09e667f3bcdp-1,\n+ -0x1.a9b66290ea1a3p-1, -0x1.d906bcf328d46p-1, -0x1.f6297cff75cbp-1,\n+ -0x1p+0, -0x1.f6297cff75cbp-1, -0x1.d906bcf328d46p-1,\n+ -0x1.a9b66290ea1a3p-1, -0x1.6a09e667f3bcdp-1, -0x1.1c73b39ae68c8p-1,\n+ -0x1.87de2a6aea963p-2, -0x1.8f8b83c69a60bp-3\n+};\n+\n+const struct\n+{\n+ union\n+ {\n+ float arg;\n+ uint32_t uarg;\n+ };\n+ float rh, rl;\n+} __sinf_st[] = {\n+ { { 0x1.33333p+13 }, -0x1.63f4bap-2, -0x1p-27 },\n+ { { 0x1.75b8a2p-1 }, 0x1.55688ap-1, -0x1p-26 },\n+ { { 0x1.4f0654p+0 }, 0x1.ee836cp-1, -0x1p-26 },\n+ { { 0x1.2d97c8p+3 }, -0x1.99bc5ap-26, -0x1p-51 },\n+};\ndiff --git a/sysdeps/ieee754/flt-32/s_sinf.c b/sysdeps/ieee754/flt-32/s_sinf.c\nindex 98845a3084..45d8a62a44 100644\n--- a/sysdeps/ieee754/flt-32/s_sinf.c\n+++ b/sysdeps/ieee754/flt-32/s_sinf.c\n@@ -1,27 +1,37 @@\n-/* Compute sine of argument.\n- Copyright (C) 2018-2026 Free Software Foundation, Inc.\n- This file is part of the GNU C Library.\n+/* Correctly-rounded sine of binary32 value.\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/cosh/coshf.c, revision 8ea8ea35.\n \n- The GNU C Library is free software; you can redistribute it and/or\n- modify it under the terms of the GNU Lesser General Public\n- License as published by the Free Software Foundation; either\n- version 2.1 of the License, or (at your option) any later version.\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 GNU C Library is distributed in the hope that it will be useful,\n- but WITHOUT ANY WARRANTY; without even the implied warranty of\n- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n- Lesser General Public License for more details.\n-\n- You should have received a copy of the GNU Lesser General Public\n- License along with the GNU C Library; if not, see\n- <https://www.gnu.org/licenses/>. */\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 <array_length.h>\n #include <stdint.h>\n #include <math.h>\n #include <math-barriers.h>\n #include <libm-alias-float.h>\n #include \"math_config.h\"\n-#include \"s_sincosf.h\"\n+#include <math_uint128.h>\n+#include <s_sincosf_data.h>\n \n #ifndef SECTION\n # define SECTION\n@@ -33,63 +43,154 @@\n # define SINF_FUNC SINF\n #endif\n \n-/* Fast sinf implementation. Worst-case ULP is 0.5607, maximum relative\n- error is 0.5303 * 2^-23. A single-step range reduction is used for\n- small values. Large inputs have their range reduced using fast integer\n- arithmetic.\n-*/\n-float\n-SECTION\n-SINF_FUNC (float y)\n+static double __attribute__ ((noinline))\n+rbig (uint32_t u, int *q)\n {\n- double x = y;\n- double s;\n- int n;\n- const sincos_t *p = &__sincosf_table[0];\n-\n- if (abstop12 (y) < abstop12 (pio4))\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- s = x * x;\n-\n- if (__glibc_unlikely (abstop12 (y) < abstop12 (0x1p-12f)))\n- {\n-\t/* Force underflow for tiny y. */\n-\tif (__glibc_unlikely (abstop12 (y) < abstop12 (0x1p-126f)))\n-\t math_force_eval ((float)s);\n-\treturn y;\n- }\n-\n- return sinf_poly (x, s, p, 0);\n+ i = p3h << s | p3l >> (64 - s);\n+ a = p3l << s | p2l >> (64 - s);\n }\n- else if (__glibc_likely (abstop12 (y) < abstop12 (120.0f)))\n+ else if (s == 64)\n {\n- x = reduce_fast (x, p, &n);\n-\n- /* Setup the signs for sin and cos. */\n- s = p->sign[n & 3];\n-\n- if (n & 2)\n-\tp = &__sincosf_table[1];\n-\n- return sinf_poly (x * s, x * x, p, n);\n- }\n- else if (abstop12 (y) < abstop12 (INFINITY))\n- {\n- uint32_t xi = asuint (y);\n- int sign = xi >> 31;\n-\n- x = reduce_large (xi, &n);\n-\n- /* Setup signs for sin and cos - include original sign. */\n- s = p->sign[(n + sign) & 3];\n-\n- if ((n + sign) & 2)\n-\tp = &__sincosf_table[1];\n-\n- return sinf_poly (x * s, x * x, p, n);\n+ i = p3l;\n+ a = p2l;\n }\n else\n- return __math_invalidf (y);\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+ uint32_t ax = asuint (x) & (~0u >> 1);\n+ for (unsigned i = 0; i < array_length (ST); i++)\n+ if (__glibc_unlikely (ST[i].uarg == ax))\n+ return add_sign (x, ST[i].rh, ST[i].rl);\n+ return r;\n+}\n+\n+static float __attribute__ ((noinline))\n+as_sinf_big (float x)\n+{\n+ uint32_t t = asuint (x);\n+ uint32_t ax = t << 1;\n+ if (__glibc_unlikely (ax >= 0xffu << 24))\n+ { // nan or +-inf\n+ if (ax << 8)\n+\treturn x + x; // nan\n+ return __math_invalidf (x);\n+ }\n+ int ia;\n+ double z = rbig (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]);\n+ double s0 = TB[ia & 31], c0 = TB[(ia + 8u) & 31];\n+ double r = s0 + z * (aa * c0 - bb * (z * s0));\n+ return r;\n+}\n+\n+float SECTION\n+SINF_FUNC (float x)\n+{\n+ uint32_t ax = asuint (x) << 1;\n+ int ia;\n+ double z0 = x, z;\n+ if (__glibc_unlikely (ax > 0x99000000u || ax < 0x73000000u))\n+ {\n+ // |x| > 0x1p+26 or |x| < 0x1p-12\n+ if (__glibc_likely (ax < 0x73000000u))\n+\t{ // |x| < 0x1p-12\n+\t if (__glibc_unlikely (ax < 0x66000000u))\n+\t { // |x| < 0x1p-25\n+\t if (__glibc_unlikely (ax == 0u))\n+\t\treturn x;\n+\t float res = fmaf (-x, fabsf (x), x);\n+\t /* The Taylor expansion of sin(x) at x=0 is x - x^3/6 + o(x^3).\n+\t\t For |x| > 2^-126 we have no underflow, whatever the rounding\n+\t\t mode. For |x| < 2^-126, since |sin(x)| < |x|, we always have\n+\t\t underflow. For |x| = 2^-126, we have underflow for rounding\n+\t\t towards zero, i.e., when sin(x) rounds to nextbelow(2^-126).\n+\t\t In summary, we have underflow whenever |x|<2^-126 or\n+\t\t |res|<2^-126. */\n+\t if (fabsf (x) < 0x1p-126f || fabsf (res) < 0x1p-126f)\n+\t\treturn __math_erangef (res); // underflow\n+\t return res;\n+\t }\n+\t return (-0x1.555556p-3f * x) * (x * x) + x;\n+\t}\n+ return as_sinf_big (x);\n+ }\n+ if (__glibc_likely (ax < 0x822d97c8u))\n+ {\n+ if (__glibc_unlikely (ax == 0x7e75b8a2u || ax == 0x7f4f0654u))\n+\treturn as_sinf_database (x, 0.0);\n+ z = rltl0 (z0, &ia);\n+ }\n+ else\n+ {\n+ if (__glibc_unlikely (ax == 0x8c333330u))\n+\treturn as_sinf_database (x, 0.0);\n+ z = rltl (z0, &ia);\n+ }\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]);\n+ double s0 = TB[ia & 31], c0 = TB[(ia + 8) & 31];\n+ double r = s0 + aa * (z * c0) - bb * (z2 * s0);\n+ return r;\n }\n \n #ifndef SINF\ndiff --git a/sysdeps/x86/fpu/s_sincosf_data.c b/sysdeps/x86/fpu/s_sincosf_data.c\nindex 2a62c7a4eb..8e96ecb86e 100644\n--- a/sysdeps/x86/fpu/s_sincosf_data.c\n+++ b/sysdeps/x86/fpu/s_sincosf_data.c\n@@ -66,3 +66,5 @@ const uint32_t __inv_pio4[24] =\n 0x34ddc0db, 0xddc0db62, 0xc0db6295, 0xdb629599,\n 0x6295993c, 0x95993c43, 0x993c4390, 0x3c439041\n };\n+\n+#include <sysdeps/ieee754/flt-32/s_sincosf_data_generic.c>\n", "prefixes": [ "4/8" ] }