From patchwork Thu Aug 3 11:54:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Ramsay X-Patchwork-Id: 1816415 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=qfoWepUu; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RGnNH6xcGz1yZl for ; Thu, 3 Aug 2023 21:55:27 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A4B103858C27 for ; Thu, 3 Aug 2023 11:55:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A4B103858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691063725; bh=AkByFugRzYJ8tmjwNONp5sq8d/OmeKapl+hi3aqz8OA=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=qfoWepUuY6ziEHZWWj73VUdQ3CNdgG0w2zrX8s1j9I4Khd9Xz35LqQ13jW5H/ltGU RbayT0X+HNJsLDUcbB41sXPwSfEmKrgu+MyCDgucHuFtr8/G7l8ZnqZaBuxdrQ6S1N DNTl2kCgxjHsuNJAQcKbfTK7fXq/i5cYEqEwjwFg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2050.outbound.protection.outlook.com [40.107.241.50]) by sourceware.org (Postfix) with ESMTPS id 295133858C27 for ; Thu, 3 Aug 2023 11:55:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 295133858C27 Received: from AS4P192CA0034.EURP192.PROD.OUTLOOK.COM (2603:10a6:20b:658::13) by DU0PR08MB9274.eurprd08.prod.outlook.com (2603:10a6:10:41a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Thu, 3 Aug 2023 11:55:06 +0000 Received: from AM7EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:658:cafe::ab) by AS4P192CA0034.outlook.office365.com (2603:10a6:20b:658::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.20 via Frontend Transport; Thu, 3 Aug 2023 11:55:06 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT020.mail.protection.outlook.com (100.127.140.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47 via Frontend Transport; Thu, 3 Aug 2023 11:55:06 +0000 Received: ("Tessian outbound f5de790fcf89:v145"); Thu, 03 Aug 2023 11:55:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: eed6675138fe1322 X-CR-MTA-TID: 64aa7808 Received: from 46f1af5a3f6c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 8AD142F2-2F62-4FD4-9B98-E2DFB131A5E1.1; Thu, 03 Aug 2023 11:54:58 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 46f1af5a3f6c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 03 Aug 2023 11:54:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AxVonVHZOcBuZa8tdyXwX2WyASrJcB47QIkyVxnWxVjcR3HmnivfOO7HrRhrMnQMInA/33Lca2EvnD/3S1g4xuGqmnxEnam/PE0SPuQvuRKmauCZdFA1lSsTIxHEA9CZQJH7ucPGw1iLfJgM15d7XYKHHxqlreAowSk04AA8WWNFPSqYh5uIkqbPV3fy5Rm7awGaoCuzpUu/RhxcQr01ht8D7DV5Uo62Sg10p1UmE1iiZWNhucai+p7CkvKPWd/pT7ZQKNWY4ZRint784tKEFKUxcG+heRb26DrcKETlBT3tz2HdVH2d+HRk9NQTcYlG2oWnTC5jm1qDK/mbiq3msg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AkByFugRzYJ8tmjwNONp5sq8d/OmeKapl+hi3aqz8OA=; b=Npm+TTmv81C0BBJr2OCbqHoqO3hxLCp4a2Hu+O0j7bxjIlSMACAjyHITDgbWnq1TbAdw2ISDuLi3hIGw48nDTyt0UWF7kW7dG8y4I2VarUOhxlZfqWt5ppYlppBwi5dg2NTMKPt7djXZ4SxpRm5u0YZgQ1e7K0bo0Wx1FHVml78YpEv5iDXI04ElBKtvefPyaPltlktNiADsifP1fIa4QGCw46XwRL9t2xWtkupOEDJpAEkYnkyQk6hBRoqrKOdvg72WjW4swbGd1sxm7IPwRwXEHAEfN8Cubf//ojGoyHDYIAqxp21qDQ5lpQwZ2IJ4gwy8+J0/LMBD+MYEA+znXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none Received: from DUZPR01CA0162.eurprd01.prod.exchangelabs.com (2603:10a6:10:4bd::10) by DB9PR08MB7770.eurprd08.prod.outlook.com (2603:10a6:10:396::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.47; Thu, 3 Aug 2023 11:54:57 +0000 Received: from DBAEUR03FT040.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4bd:cafe::43) by DUZPR01CA0162.outlook.office365.com (2603:10a6:10:4bd::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.19 via Frontend Transport; Thu, 3 Aug 2023 11:54:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT040.mail.protection.outlook.com (100.127.142.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6631.45 via Frontend Transport; Thu, 3 Aug 2023 11:54:57 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 3 Aug 2023 11:54:56 +0000 Received: from vcn-man-apps.manchester.arm.com (10.32.108.22) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 3 Aug 2023 11:54:56 +0000 To: CC: Joe Ramsay Subject: [PATCH] aarch64: Improve SVE sin polynomial Date: Thu, 3 Aug 2023 12:54:53 +0100 Message-ID: <20230803115453.14801-1-Joe.Ramsay@arm.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT040:EE_|DB9PR08MB7770:EE_|AM7EUR03FT020:EE_|DU0PR08MB9274:EE_ X-MS-Office365-Filtering-Correlation-Id: 109238da-7ff7-4468-cded-08db94187abc x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: HCJPmjiMVTTgfx90ePF5xmMVQLC8WsCnevnAxhfpEQR0g4bpctNz526k07fqqK3vsjbqF/3aSC8TuEF6BqimyTUbhqGeAi3+Co3h79HRLqw/+4mgEP01AOtMvhQ6bsZIuf8IawhycsxAYZFk0dFMNUjO3WxoTVzMeRpUUMJKpgr0B3jglvaSDvbmJzS9ITEO8YQAvLQapzcPWAtF41prNjX6nEjy2mmcB9npiBa3ckovRzqE2DcwIYEH3xVy/TpA5dsbAYGVk/WIKHq2MmhmKRA8FlVpjNOtAAI7DenaRvXv8smagqUTvhcWQaNdD1hsoCmBPHpL+cfH67HmOH73y/3LgOcmlwb/WqhwxN8j0xloxLnwouL/nMap0KnPA+w8a3IMJltgkM0UyP8zWjiR6mnXQOF91BD+wpkT3ie1mFxuxnlAnPoyg6b9MVLh5Wcp4mJyVovwafW88iAqMnTXp1HwTPMczcY30mSaWu8nSIM8JBuj72p11SiakUiw/J0tRmD6CFnxvCjOLUoQpz6EoQ05OTtyaVmoIL1dLcDnXiMISWFo3fMcc2XV+MI80o7x5xWqDmR20l3vbaCp7MwIwaAkm2UMz5DNb15+7zf1zOOoEktE+ZKT0RaIP+aRV5MhSC+0zAAEe7HST6hzOFgSx+4C+nLW+zRIyFJHMmO18Cs95QCM3RP0qqbr658+Ls75wcUgdJ+tsFgUo0N5O9z9HUo2IM5AbiGBRPrUya+nwffNgotUkL5QmbA/U4VaLcMT0F7PC0wXX4o0AcU9AqV4mg== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230028)(4636009)(376002)(396003)(136003)(39860400002)(346002)(82310400008)(451199021)(36840700001)(46966006)(426003)(2616005)(1076003)(336012)(83380400001)(26005)(186003)(47076005)(41300700001)(36860700001)(70586007)(2906002)(70206006)(4326008)(5660300002)(6916009)(316002)(8676002)(8936002)(6666004)(7696005)(478600001)(40480700001)(356005)(81166007)(82740400003)(36756003)(86362001)(36900700001)(473944003); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7770 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4a8120e1-c88a-41cc-d753-08db94187581 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iHiVENsDa1HsgXx21HixgoFdvO1A4m2hJub0iPa6ifvHRgrmNgw0RQrvhDh4L99JaLeOjZDTEkVTb34h+AQCmP2CXFpNdshJU9Oj4zIjnjCdk63FmPimSeWOvdbToOp91W+qC10y4Bgzztt9Z/A8isluYGBY/JtDpBpl2fSh6vKsuBcnwmfL0W9JK2kWQXZrbQPIAmyKmjKaaBvGYpGLrVXEE5DNvc3rbOCqCtnGdoaMX9XGIK1k/pJ/rFocWfOHhv8e02ucrz5ND9L+V2q8Yb65gCJh+nyXeFbzaL1dcxKLdjtcbKisj47fM19xGts3bUYRHuxDllCh8wv1uEgX5V2NIVi+emWJ+dKhqIY76fmTmpM47XzHYih7Es/nobOW/k6pUHwMiFo7mCmUZJrTPST1IY2z0CKepFlvqZzjKmmWRs9e+LH0q0vaM1+kwxeKGGRajDE5ivA/4mkIlRJ8nWswvNeOM8MwuRqscwWhBiWLna5P2k8XtbQZZE1UZFbBGwTbtSCWRmVgfwPHvvgxsSvCBperr/lU2RuQvcPlclp73N/RvsrhApI6Ss33iQRF9Y8KQbVK1dnGwIREjAx+r33Dd8sWNZNPJSXezmccMTZUwXS+T0H9UhiDvAByWuO/iF1xaC/DrwnL6mwAk5unRHcB1X8b0Ia4+bitmWrwmKcNAlnsGxblfu6hVMuRSrGegwNPmGqKcOwEqsMy/1zKdHuBxX/syqSzDFyjkJg1741eu3oJ4RbJrvZPRMTZDsh0I2D0jQVerVutLhWkxOsXCQ== X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230028)(4636009)(396003)(376002)(346002)(136003)(39860400002)(451199021)(82310400008)(40470700004)(36840700001)(46966006)(41300700001)(40460700003)(316002)(2906002)(4326008)(70206006)(70586007)(6916009)(8936002)(8676002)(5660300002)(81166007)(82740400003)(26005)(1076003)(36756003)(186003)(86362001)(83380400001)(2616005)(426003)(336012)(47076005)(36860700001)(478600001)(7696005)(6666004)(40480700001)(473944003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2023 11:55:06.1751 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 109238da-7ff7-4468-cded-08db94187abc X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT020.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9274 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Joe Ramsay via Libc-alpha From: Joe Ramsay Reply-To: Joe Ramsay Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The polynomial used in the AdvSIMD variant was found to be more efficient than FTRIG intrinsics, with acceptable loss of precision. --- Thanks, Joe sysdeps/aarch64/fpu/sin_sve.c | 99 ++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/sysdeps/aarch64/fpu/sin_sve.c b/sysdeps/aarch64/fpu/sin_sve.c index c3f450d0ea..4d93e761af 100644 --- a/sysdeps/aarch64/fpu/sin_sve.c +++ b/sysdeps/aarch64/fpu/sin_sve.c @@ -21,20 +21,23 @@ static const struct data { - double inv_pi, half_pi, inv_pi_over_2, pi_over_2_1, pi_over_2_2, pi_over_2_3, - shift; + double inv_pi, pi_1, pi_2, pi_3, shift, range_val; + double poly[7]; } data = { - /* Polynomial coefficients are hard-wired in the FTMAD instruction. */ + /* Worst-case error is 2.8+0.5 ulp in [-pi/2, pi/2]. */ + .poly = { -0x1.555555555547bp-3, 0x1.1111111108a4dp-7, -0x1.a01a019936f27p-13, + 0x1.71de37a97d93ep-19, -0x1.ae633919987c6p-26, + 0x1.60e277ae07cecp-33, -0x1.9e9540300a1p-41, }, + .inv_pi = 0x1.45f306dc9c883p-2, - .half_pi = 0x1.921fb54442d18p+0, - .inv_pi_over_2 = 0x1.45f306dc9c882p-1, - .pi_over_2_1 = 0x1.921fb50000000p+0, - .pi_over_2_2 = 0x1.110b460000000p-26, - .pi_over_2_3 = 0x1.1a62633145c07p-54, - .shift = 0x1.8p52 + .pi_1 = 0x1.921fb54442d18p+1, + .pi_2 = 0x1.1a62633145c06p-53, + .pi_3 = 0x1.c1cd129024e09p-106, + .shift = 0x1.8p52, + .range_val = 0x1p23, }; -#define RangeVal 0x4160000000000000 /* asuint64 (0x1p23). */ +#define C(i) sv_f64 (d->poly[i]) static svfloat64_t NOINLINE special_case (svfloat64_t x, svfloat64_t y, svbool_t cmp) @@ -42,55 +45,53 @@ special_case (svfloat64_t x, svfloat64_t y, svbool_t cmp) return sv_call_f64 (sin, x, y, cmp); } -/* A fast SVE implementation of sin based on trigonometric - instructions (FTMAD, FTSSEL, FTSMUL). - Maximum observed error in 2.52 ULP: - SV_NAME_D1 (sin)(0x1.2d2b00df69661p+19) got 0x1.10ace8f3e786bp-40 - want 0x1.10ace8f3e7868p-40. */ +/* A fast SVE implementation of sin. + Maximum observed error in 3.22 ULP: + _ZGVsMxv_sin (0x1.d70eef40f39b1p+12) got -0x1.ffe9537d5dbb7p-3 + want -0x1.ffe9537d5dbb4p-3. */ svfloat64_t SV_NAME_D1 (sin) (svfloat64_t x, const svbool_t pg) { const struct data *d = ptr_barrier (&data); - svfloat64_t r = svabs_f64_x (pg, x); - svuint64_t sign - = sveor_u64_x (pg, svreinterpret_u64_f64 (x), svreinterpret_u64_f64 (r)); - svbool_t cmp = svcmpge_n_u64 (pg, svreinterpret_u64_f64 (r), RangeVal); - - /* Load first two pio2-related constants to one vector. */ - svfloat64_t invpio2_and_pio2_1 - = svld1rq_f64 (svptrue_b64 (), &d->inv_pi_over_2); - - /* n = rint(|x|/(pi/2)). */ - svfloat64_t q = svmla_lane_f64 (sv_f64 (d->shift), r, invpio2_and_pio2_1, 0); - svfloat64_t n = svsub_n_f64_x (pg, q, d->shift); + /* Load some values in quad-word chunks to minimise memory access. */ + const svbool_t ptrue = svptrue_b64 (); + svfloat64_t shift = sv_f64 (d->shift); + svfloat64_t inv_pi_and_pi1 = svld1rq (ptrue, &d->inv_pi); + svfloat64_t pi2_and_pi3 = svld1rq (ptrue, &d->pi_2); + + /* n = rint(|x|/pi). */ + svfloat64_t n = svmla_lane (shift, x, inv_pi_and_pi1, 0); + svuint64_t odd = svlsl_x (pg, svreinterpret_u64 (n), 63); + odd = sveor_m ( + svcmpeq (pg, svreinterpret_u64 (x), svreinterpret_u64 (sv_f64 (-0.0))), + odd, 0x8000000000000000); + n = svsub_x (pg, n, shift); + + /* r = |x| - n*(pi/2) (range reduction into -pi/2 .. pi/2). */ + svfloat64_t r = x; + r = svmls_lane (r, n, inv_pi_and_pi1, 1); + r = svmls_lane (r, n, pi2_and_pi3, 0); + r = svmls_lane (r, n, pi2_and_pi3, 1); - /* r = |x| - n*(pi/2) (range reduction into -pi/4 .. pi/4). */ - r = svmls_lane_f64 (r, n, invpio2_and_pio2_1, 1); - r = svmls_n_f64_x (pg, r, n, d->pi_over_2_2); - r = svmls_n_f64_x (pg, r, n, d->pi_over_2_3); + /* sin(r) poly approx. */ + svfloat64_t r2 = svmul_x (pg, r, r); + svfloat64_t r3 = svmul_x (pg, r2, r); + svfloat64_t r4 = svmul_x (pg, r2, r2); - /* Final multiplicative factor: 1.0 or x depending on bit #0 of q. */ - svfloat64_t f = svtssel_f64 (r, svreinterpret_u64_f64 (q)); + svfloat64_t t1 = svmla_x (pg, C (4), C (5), r2); + svfloat64_t t2 = svmla_x (pg, C (2), C (3), r2); + svfloat64_t t3 = svmla_x (pg, C (0), C (1), r2); - /* sin(r) poly approx. */ - svfloat64_t r2 = svtsmul_f64 (r, svreinterpret_u64_f64 (q)); - svfloat64_t y = sv_f64 (0.0); - y = svtmad_f64 (y, r2, 7); - y = svtmad_f64 (y, r2, 6); - y = svtmad_f64 (y, r2, 5); - y = svtmad_f64 (y, r2, 4); - y = svtmad_f64 (y, r2, 3); - y = svtmad_f64 (y, r2, 2); - y = svtmad_f64 (y, r2, 1); - y = svtmad_f64 (y, r2, 0); - - /* Apply factor. */ - y = svmul_f64_x (pg, f, y); + svfloat64_t y = svmla_x (pg, t1, C (6), r4); + y = svmla_x (pg, t2, y, r4); + y = svmla_x (pg, t3, y, r4); + y = svmla_x (pg, r, y, r3); /* sign = y^sign. */ - y = svreinterpret_f64_u64 ( - sveor_u64_x (pg, svreinterpret_u64_f64 (y), sign)); + y = svreinterpret_f64 (sveor_z (pg, svreinterpret_u64 (y), odd)); + svbool_t cmp = svacle (pg, x, d->range_val); + cmp = svnot_z (pg, cmp); if (__glibc_unlikely (svptest_any (pg, cmp))) return special_case (x, y, cmp); return y;