Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2216095/?format=api
{ "id": 2216095, "url": "http://patchwork.ozlabs.org/api/patches/2216095/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/20260325192357.1284741-7-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-7-adhemerval.zanella@linaro.org>", "list_archive_url": null, "date": "2026-03-25T19:22:24", "name": "[6/8] math: Use sincosf from CORE-MATH", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "3d92d6f24e9e004714b286a5a85119a779c84053", "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-7-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/2216095/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2216095/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=PvMZ43MK;\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=PvMZ43MK", "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::a2a" ], "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 4fgxmp3drWz1y1K\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 26 Mar 2026 06:29:30 +1100 (AEDT)", "from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 84E914BAD15D\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 25 Mar 2026 19:29:28 +0000 (GMT)", "from mail-vk1-xa2a.google.com (mail-vk1-xa2a.google.com\n [IPv6:2607:f8b0:4864:20::a2a])\n by sourceware.org (Postfix) with ESMTPS id 83B844BB58FD\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 19:24:20 +0000 (GMT)", "by mail-vk1-xa2a.google.com with SMTP id\n 71dfb90a1353d-56ba039eecbso125772e0c.0\n for <libc-alpha@sourceware.org>; Wed, 25 Mar 2026 12:24:20 -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.17\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 25 Mar 2026 12:24:18 -0700 (PDT)" ], "DKIM-Filter": [ "OpenDKIM Filter v2.11.0 sourceware.org 84E914BAD15D", "OpenDKIM Filter v2.11.0 sourceware.org 83B844BB58FD" ], "DMARC-Filter": "OpenDMARC Filter v1.4.2 sourceware.org 83B844BB58FD", "ARC-Filter": "OpenARC Filter v1.0.0 sourceware.org 83B844BB58FD", "ARC-Seal": "i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774466660; cv=none;\n b=FUcckrlZ83f+AzscC3x+LC8xLpRoQ3JblxJVRyQkuWxHpsivBoXUAGAuSdmRjgAxXjWdjYpfMx0DbiOqGKIEPJawpcP+JetecliXjlk/K8uKarr1Z/LMULs+IX6TO6Ojcalg/YKiusckfRhWyG1ngcdGAKhnfBJ5oH4jIZAtnhI=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1774466660; c=relaxed/simple;\n bh=zF/1FZOD/7LPrc/5zxp14Vl+KWQdlXEiiAjlt6rOzmA=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=iSfJavIDN+EpcOdpZPEzzlvsH7jYYeyGh+rTuMeToaBMMotQBkw8PWm71wDPVObAzkUi59to3Kr420bjhl7okFS/35FB7UgzUF9vl95GssOonqEPBCYMkwo5ZS9J8YjgyDx1ajmJajjz2cvwrHyp7ur0b0OJlPphy56iyvmIQHI=", "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=1774466659; x=1775071459; 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=CdXcMji6L+FMz7B84UL4n5RBn9XLl+7+jjshZzc/W9U=;\n b=PvMZ43MKN7vh60/vkgfnuS1H3Hb12XVSK9v9MvDXMqYHEsIFSxPDMptebBENiE2cnt\n npwtMCGNejpDxamU0mYMqcss7y2dgurgiwmqm8r5fG9brBhojAck2QsBaBCoZhTHw/EO\n lw3uPH1TbbclOH97JJ6ds5cO6J4aclQAd4FEzS9xI7bC9tQCuRgr2zF/DdMs5hj7FhMb\n WBeyGeYSpKXpe38r4d9d3L337Bl2vhNL4skZA9o0h2mOlmh0m7mRW6IDMNfEYCfYeUWj\n 2rrON+seICaI/dgZgutjrLfEQ71A1FLKGqSgxuoNV0BOalVrCYDh2qljj6j1uebAKgUN\n ZjEw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774466659; x=1775071459;\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=CdXcMji6L+FMz7B84UL4n5RBn9XLl+7+jjshZzc/W9U=;\n b=Yf5ytJI4uMF/4+M5T/BBaD8lR54h62PDzT71K88GgLrLx7Oe/91CW0ZDN58g1TNRm4\n gvm7Gt6Fu3Nfcchxm7L/xWnKtVwUo6Rrq76j205gvNm0koNTOd76FMDqhsV2O4Ly5PTb\n lFUOYWNuXUibQU9HdN/iDNSJAmDOluW628Vaqbv4Jkgt78sKiY+edIVTa9kApt52A7yz\n PBB5WdfKVT7jfGSdaG+9mmUqzxf8yKTJZRdZCinSx1QQa0bZ0UTYQ/PqYGO9qgpw97hf\n cFy+ZWT8Xepo/Yq8gozoq8Jsz0KzC1+jARCSQV0wOo4tGB+FKniLxC5aepTkq7Fqbd/H\n 7/yA==", "X-Gm-Message-State": "AOJu0YwFjzrYnEBmAWHd3W/mPt1nQEclJFJHdHk1A+akWWw9i495+vze\n vpXn5+yyUq3FNicEhLzfcE7l1/JG3FSbULI3cDmdP+sDrp1/VRPgj+bres1QLa3C+bv+GmNLxSQ\n sx0QF", "X-Gm-Gg": "ATEYQzy33troz1vERI3NFJ3lHUlEZMtYfE/aBqjC0y+BTS4iyUmvQ2M2+laM2QwbbK4\n ikQHLkmnfgZLDQozHObDid1W7H5STK60g5VAyX14rqEzYsVwY+utyAqS1rh8KufBGIlaBCIQ7GU\n zcRBSRfa67/21w2ZGQie0sW+ztiEwv+00VUhnBHmGA088It8V4yaKJ9AG2dwt9u3B1J0pDxXofa\n 6jgT4cykjGFXwBmuiYWEWKnhEruxdgujmKWmVCXOQSu2p7u1rXxqsGmwzoiRRoeUKHSZPiVZNHK\n uux1WtAPVpyT2KT+27Cw+ze+yC6xwnraJdD/9BZpEXcJ2OX5Cuhxp4KHf9C1wR0i6J9z/l3iwrg\n 4pPOxlx7QVjSDSWY5kc03ZvnGbbGprdOaaCE97J8DAGyViqPX+kdRAodP48ygUtDKdJ5Jcm3hI1\n k356q6eb7u/K8WEHXyo4QoYC4JdP0MCeLNEAo=", "X-Received": "by 2002:a05:6122:d96:b0:56a:9841:9f81 with SMTP id\n 71dfb90a1353d-56d21f50c1fmr2651154e0c.6.1774466659410;\n Wed, 25 Mar 2026 12:24:19 -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 6/8] math: Use sincosf from CORE-MATH", "Date": "Wed, 25 Mar 2026 16:22:24 -0300", "Message-ID": "<20260325192357.1284741-7-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)\nlatency master patched improvement\nx86_64 15.4175 21.4282 -38.99%\nx86_64v2 14.0476 14.3099 -1.87%\nx86_64v3 10.9744 11.6395 -6.06%\naarch64 9.2646 10.2755 -10.91%\npower10 5.2857 4.8504 8.24%\n\n- input: large (-64, 64)\nlatency master patched improvement\nx86_64 15.8593 22.4521 -41.57%\nx86_64v2 14.7728 15.0530 -1.90%\nx86_64v3 12.5962 13.3065 -5.64%\naarch64 9.2468 11.5874 -25.31%\npower10 6.3992 5.5319 13.55%\n\n- input: huge (-1024, 1024)\nlatency master patched improvement\nx86_64 19.6595 22.7598 -15.77%\nx86_64v2 15.0780 15.3032 -1.49%\nx86_64v3 12.6576 13.3942 -5.82%\naarch64 10.5701 10.9711 -3.79%\npower10 7.3381 5.1920 29.25%\n\n* reciprocal-throughput\n- input: random (-2*pi, 2*pi)\n master patched improvement\nx86_64 15.3955 21.4922 -39.60%\nx86_64v2 14.0497 14.3085 -1.84%\nx86_64v3 10.9702 11.6287 -6.00%\naarch64 9.1699 10.0887 -10.02%\npower10 5.3090 4.8565 8.52%\n\n- input: rlarge (-64, 64)\n master patched improvement\nx86_64 15.8584 22.4857 -41.79%\nx86_64v2 14.7689 15.0531 -1.92%\nx86_64v3 11.8228 12.4646 -5.43%\naarch64 9.2013 11.5711 -25.76%\npower10 6.4112 5.5249 13.82%\n\n- input: huge (-1024, 1024)\n master patched improvement\nx86_64 19.6392 22.7250 -15.71%\nx86_64v2 15.0745 15.2802 -1.36%\nx86_64v3 12.0551 12.7136 -5.46%\naarch64 10.5383 10.9630 -4.03%\npower10 7.2801 5.1874 28.74%\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 math/auto-libm-test-in | 1 +\n math/auto-libm-test-out-sincos | 25 ++\n sysdeps/ieee754/flt-32/libm-test-ulps | 12 +\n sysdeps/ieee754/flt-32/s_sincosf.c | 254 +++++++++++++-----\n sysdeps/ieee754/flt-32/s_sincosf_data.h | 13 +\n .../ieee754/flt-32/s_sincosf_data_generic.c | 13 +\n 7 files changed, 247 insertions(+), 73 deletions(-)", "diff": "diff --git a/SHARED-FILES b/SHARED-FILES\nindex 751b31fae4..68413ec08f 100644\n--- a/SHARED-FILES\n+++ b/SHARED-FILES\n@@ -310,6 +310,8 @@ core-math:\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/sincos/sincosf.c revision 8ea8ea35\n+ sysdeps/ieee754/flt-32/s_sincosf.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/math/auto-libm-test-in b/math/auto-libm-test-in\nindex 4f38095453..2574957ada 100644\n--- a/math/auto-libm-test-in\n+++ b/math/auto-libm-test-in\n@@ -9499,6 +9499,7 @@ sincos 1e22\n sincos 0x1p1023\n sincos 0x1p16383\n sincos 0x1p+120\n+sincos 0x1p-126\n sincos 0x1p+127\n sincos 0x1.fffff8p+127\n sincos 0x1.fffffep+127\ndiff --git a/math/auto-libm-test-out-sincos b/math/auto-libm-test-out-sincos\nindex f0457631a9..085b9f421a 100644\n--- a/math/auto-libm-test-out-sincos\n+++ b/math/auto-libm-test-out-sincos\n@@ -1197,6 +1197,31 @@ sincos 0x1p+120\n = sincos tonearest ibm128 0x1p+120 : 0x6.0b8d19579bf2db5e5f1aa933f4p-4 -0xe.d06685b36c66c4cf35c11f6518p-4 : inexact-ok\n = sincos towardzero ibm128 0x1p+120 : 0x6.0b8d19579bf2db5e5f1aa933f2p-4 -0xe.d06685b36c66c4cf35c11f6518p-4 : inexact-ok\n = sincos upward ibm128 0x1p+120 : 0x6.0b8d19579bf2db5e5f1aa933f4p-4 -0xe.d06685b36c66c4cf35c11f6518p-4 : inexact-ok\n+sincos 0x1p-126\n+= sincos downward binary32 0x4p-128 : 0x3.fffff8p-128 0xf.fffffp-4 : inexact-ok underflow-ok errno-erange-ok\n+= sincos tonearest binary32 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok underflow-ok errno-erange-ok\n+= sincos towardzero binary32 0x4p-128 : 0x3.fffff8p-128 0xf.fffffp-4 : inexact-ok underflow-ok errno-erange-ok\n+= sincos upward binary32 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok underflow-ok errno-erange-ok\n+= sincos downward binary64 0x4p-128 : 0x3.ffffffffffffep-128 0xf.ffffffffffff8p-4 : inexact-ok\n+= sincos tonearest binary64 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n+= sincos towardzero binary64 0x4p-128 : 0x3.ffffffffffffep-128 0xf.ffffffffffff8p-4 : inexact-ok\n+= sincos upward binary64 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n+= sincos downward intel96 0x4p-128 : 0x3.fffffffffffffffcp-128 0xf.fffffffffffffffp-4 : inexact-ok\n+= sincos tonearest intel96 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n+= sincos towardzero intel96 0x4p-128 : 0x3.fffffffffffffffcp-128 0xf.fffffffffffffffp-4 : inexact-ok\n+= sincos upward intel96 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n+= sincos downward m68k96 0x4p-128 : 0x3.fffffffffffffffcp-128 0xf.fffffffffffffffp-4 : inexact-ok\n+= sincos tonearest m68k96 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n+= sincos towardzero m68k96 0x4p-128 : 0x3.fffffffffffffffcp-128 0xf.fffffffffffffffp-4 : inexact-ok\n+= sincos upward m68k96 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n+= sincos downward binary128 0x4p-128 : 0x3.fffffffffffffffffffffffffffep-128 0xf.fffffffffffffffffffffffffff8p-4 : inexact-ok\n+= sincos tonearest binary128 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n+= sincos towardzero binary128 0x4p-128 : 0x3.fffffffffffffffffffffffffffep-128 0xf.fffffffffffffffffffffffffff8p-4 : inexact-ok\n+= sincos upward binary128 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n+= sincos downward ibm128 0x4p-128 : 0x3.ffffffffffffffffffffffffffp-128 0xf.fffffffffffffffffffffffffcp-4 : inexact-ok\n+= sincos tonearest ibm128 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n+= sincos towardzero ibm128 0x4p-128 : 0x3.ffffffffffffffffffffffffffp-128 0xf.fffffffffffffffffffffffffcp-4 : inexact-ok\n+= sincos upward ibm128 0x4p-128 : 0x4p-128 0x1p+0 : inexact-ok\n sincos 0x1p+127\n = sincos downward binary32 0x8p+124 : 0x9.f9631p-4 0xc.82b8ep-4 : inexact-ok\n = sincos tonearest binary32 0x8p+124 : 0x9.f9631p-4 0xc.82b8fp-4 : inexact-ok\ndiff --git a/sysdeps/ieee754/flt-32/libm-test-ulps b/sysdeps/ieee754/flt-32/libm-test-ulps\nindex 0179223018..dfe78a63c8 100644\n--- a/sysdeps/ieee754/flt-32/libm-test-ulps\n+++ b/sysdeps/ieee754/flt-32/libm-test-ulps\n@@ -275,6 +275,18 @@ float: 0\n Function: \"sin_upward\":\n float: 0\n \n+Function: \"sincos\":\n+float: 0\n+\n+Function: \"sincos_downward\":\n+float: 0\n+\n+Function: \"sincos_towardzero\":\n+float: 0\n+\n+Function: \"sincos_upward\":\n+float: 0\n+\n Function: \"sinh\":\n float: 0\n \ndiff --git a/sysdeps/ieee754/flt-32/s_sincosf.c b/sysdeps/ieee754/flt-32/s_sincosf.c\nindex fd49d20b58..eb5d849174 100644\n--- a/sysdeps/ieee754/flt-32/s_sincosf.c\n+++ b/sysdeps/ieee754/flt-32/s_sincosf.c\n@@ -1,28 +1,35 @@\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+/* Correctly-rounded sincos of binary32 value.\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+Copyright (c) 2024-2025 Alexei Sibidanov\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+The original version of this file was copied from the CORE-MATH\n+project (file src/binary32/sincos/sincosf.c, revision 8ea8ea35.\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+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-#include <errno.h>\n-#include <stdint.h>\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 <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@@ -34,73 +41,174 @@\n # define SINCOSF_FUNC SINCOSF\n #endif\n \n-/* Fast sincosf 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-void\n-SECTION\n-SINCOSF_FUNC (float y, float *sinp, float *cosp)\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- double x2 = x * x;\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- if (__glibc_unlikely (abstop12 (y) < abstop12 (0x1p-12f)))\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+ uint32_t t = asuint (x);\n+ uint32_t ax = t & (~0u >> 1);\n+ for (unsigned i = 0; i < array_length (ST_SINCOSF); i++)\n+ if (__glibc_unlikely (ST_SINCOSF[i].uarg == ax))\n {\n-\t/* Force underflow for tiny y. */\n-\tif (__glibc_unlikely (abstop12 (y) < abstop12 (0x1p-126f)))\n-\t math_force_eval ((float)x2);\n-\t*sinp = y;\n-\t*cosp = 1.0f;\n-\treturn;\n+\t*sout = add_sign (x, ST_SINCOSF[i].sh, ST_SINCOSF[i].sl);\n+\t*cout = ST_SINCOSF[i].ch + ST_SINCOSF[i].cl;\n+\tbreak;\n }\n+}\n \n- sincosf_poly (x, x2, p, 0, sinp, cosp);\n+static void __attribute__ ((noinline))\n+as_sincosf_big (float x, float *sout, float *cout)\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+\t{\n+\t *sout = x + x;\n+\t *cout = x + x;\n+\t return; // nan\n+\t}\n+ *sout = *cout = x - x;\n+ __math_invalidf (x + x);\n+ return;\n }\n- else if (abstop12 (y) < abstop12 (120.0f))\n- {\n- x = reduce_fast (x, p, &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+ bb *= z;\n+ double s0 = TB[ia & 31], c0 = TB[(ia + 8u) & 31];\n+ double s = s0 + z * (aa * c0 - bb * s0);\n+ double c = c0 - z * (aa * s0 + bb * c0);\n+ *sout = s;\n+ *cout = c;\n+ uint64_t tr = asuint64 (c);\n+ uint64_t tail = (tr + 6) & (~UINT64_C(0) >> 36);\n+ if (__glibc_unlikely (tail <= 12))\n+ return as_sincosf_database (x, sout, cout);\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- sincosf_poly (x * s, x * x, p, n, sinp, cosp);\n- }\n- else if (__glibc_likely (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- sincosf_poly (x * s, x * x, p, n, sinp, cosp);\n+void SECTION\n+SINCOSF_FUNC (float x, float *sout, float *cout)\n+{\n+ uint32_t ax = asuint (x) << 1;\n+ int ia;\n+ double z0 = x, z;\n+ if (__glibc_likely (ax < 0x822d97c8u))\n+ { // |x| < 0x1.2d97c8p+3\n+ if (__glibc_unlikely (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\t{\n+\t\t *sout = x;\n+\t\t *cout = 1.0f;\n+\t\t}\n+\t else\n+\t\t{\n+\t\t *sout = fmaf (-x, fabsf (x), x);\n+\t\t *cout = 1.0f - 0x1p-25f;\n+\t\t}\n+\t }\n+\t else\n+\t {\n+\t *sout = (-0x1.555556p-3f * x) * (x * x) + x;\n+\t *cout = (-0x1p-1f * x) * x + 1.0f;\n+\t }\n+\t return;\n+\t}\n+ if (__glibc_unlikely (ax == 0x812d97c8u))\n+\treturn as_sincosf_database (x, sout, cout);\n+ z = rltl0 (z0, &ia);\n }\n else\n {\n- /* Return NaN if Inf or NaN for both sin and cos. */\n- *sinp = *cosp = y - y;\n-#if WANT_ERRNO\n- /* Needed to set errno for +-Inf, the add is a hack to work\n-\t around a gcc register allocation issue: just passing y\n-\t affects code generation in the fast path (PR86901). */\n- __math_invalidf (y + y);\n-#endif\n+ if (__glibc_unlikely (ax > 0x99000000u))\n+\treturn as_sincosf_big (x, sout, cout);\n+ if (__glibc_unlikely (ax == 0x8c333330u))\n+\treturn as_sincosf_database (x, sout, cout);\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+ aa *= z;\n+ bb *= z2;\n+ double s0 = TB[ia & 31], c0 = TB[(ia + 8) & 31];\n+ double rs = s0 + (aa * c0 - bb * s0);\n+ double rc = c0 - (aa * s0 + bb * c0);\n+ *sout = rs;\n+ *cout = rc;\n }\n \n #ifndef SINCOSF\ndiff --git a/sysdeps/ieee754/flt-32/s_sincosf_data.h b/sysdeps/ieee754/flt-32/s_sincosf_data.h\nindex 8bea0042f3..354e9b6a88 100644\n--- a/sysdeps/ieee754/flt-32/s_sincosf_data.h\n+++ b/sysdeps/ieee754/flt-32/s_sincosf_data.h\n@@ -46,4 +46,17 @@ extern const sincosf_database_t __sinf_st[4] attribute_hidden;\n extern const sincosf_database_t __cosf_st[5] attribute_hidden;\n #define ST_COSF __cosf_st\n \n+typedef struct\n+{\n+ union\n+ {\n+ float arg;\n+ uint32_t uarg;\n+ };\n+ float sh, sl;\n+ float ch, cl;\n+} sincosf2_database_t;\n+extern const sincosf2_database_t __sincosf_st[9] attribute_hidden;\n+#define ST_SINCOSF __sincosf_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\nindex 2e58f0b423..2a85b687dd 100644\n--- a/sysdeps/ieee754/flt-32/s_sincosf_data_generic.c\n+++ b/sysdeps/ieee754/flt-32/s_sincosf_data_generic.c\n@@ -88,3 +88,16 @@ const sincosf_database_t __cosf_st[] =\n { { 0x1.3170fp+63 }, 0x1.fe2976p-1, 0x1p-26 },\n { { 0x1.2b9622p+67 }, 0x1.f0285ep-1, -0x1p-26 },\n };\n+\n+const sincosf2_database_t __sincosf_st[] =\n+{\n+ { { 0x1.33333p+13 }, -0x1.63f4bap-2, -0x1p-27, -0x1.e01216p-1, -0x1p-26 },\n+ { { 0x1.75b8a2p-1 }, 0x1.55688ap-1, -0x1p-26, 0x1.7d8e1ep-1, 0x1p-26 },\n+ { { 0x1.4f0654p+0 }, 0x1.ee836cp-1, -0x1p-26, 0x1.09558p-2, -0x1p-27 },\n+ { { 0x1.2d97c8p+3 }, -0x1.99bc5ap-26, -0x1p-51, -0x1p+0, 0x1p-25 },\n+ { { 0x1.2d97c8p+2 }, -0x1p+0, 0x1p-25, 0x1.99bc5cp-27, -0x1p-52 },\n+ { { 0x1.4555p+51 }, -0x1.b0ea44p-1, 0x1p-26, 0x1.115d7ep-1, -0x1p-26 },\n+ { { 0x1.48a858p+54 }, 0x1.beac8cp-1, 0x1p-26, 0x1.f48148p-2, 0x1p-27 },\n+ { { 0x1.3170fp+63 }, 0x1.5ac1eep-4, -0x1p-30, 0x1.fe2976p-1, 0x1p-26 },\n+ { { 0x1.2b9622p+67 }, -0x1.f983c2p-3, 0x1p-28, 0x1.f0285ep-1, -0x1p-26 },\n+};\n", "prefixes": [ "6/8" ] }