From nobody Thu Jan 16 01:23:01 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YYQ922KTnz5kxDR; Thu, 16 Jan 2025 01:23:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YYQ9217Gsz44Cy; Thu, 16 Jan 2025 01:23:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736990582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZGrVwwSIjyxz0ew/ouVRo10iOOYLrKZXPVD5dxVKOZ4=; b=b6p+dkFO0HXDzUd5vsTURi/swnnNwAfOZS7tUVJqglKapl5AeedHCkR40KPBnSaJEVSNjt tJb8n0OybUTfzla4vjyZORNLltyg17gdC8HKTw/MKbQgPbb7I89DZ7IGZnqRpXgdkMcwQY bqB96YZRPWJycdAkbV2KCxXm89lT32yxXj4b+xOM8R17FUtq1KwT2lF16JWyy+OiZLnZKq /gY8vwIVdw4h+ZF3ZArsFWahuPv6aPCW2UIP3tsMDFZ+J1YMvZpWytPjpoxCF/wbOkBSZd gMz74Dk0B4HsDA5Psd8VAI/Cj67agxwiDa6DF2ls32r75g1QEVg3L+InHLNCqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736990582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZGrVwwSIjyxz0ew/ouVRo10iOOYLrKZXPVD5dxVKOZ4=; b=c6Bod8kJYrURLOgUM7nfEG4QOxyPMn8fJhx5iC0FswnyoX+bgeOCl1tOAFlzyBKrwGXS4N rnJR9NQWrq+D+41vyp/Fv35e3Vp9T+F3QccEk1QZu23JpccbDqriLp4nP4RS53FRCFK/+Y I6dMlMtMfLHYMY1wDma9kA5OIBhVHewD5uubMQLq3GWmJ998ZZ9gKBI41jATX2bSQg0Yt7 NJTuKr8HYyFzRmME1QboUdEbQZyiNYkfx1E7PrPTVm26M1FIZv4Y46J/Jdq5DgejPxymUo fJaEn1MtKeOvSU9ZBKDOWPxB4Qfo0PRm8DWCbnqtcfCgYZJgalW+aR2dDuQB2A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736990582; a=rsa-sha256; cv=none; b=hOgYnPO+IHOHoMgJnetUcQH66WjsGkJjSb/jqZjLaQ/kJEYeZYKJM1cYKIpdSMm9LQQSKD rCJPcvxWYEd9Sp1eWsn8aNiDNI+DXWCIEdRMWf0O8/oil+r5CDrLUnUkPIu8H3GKtX93xM XCmCjEphwM1ctAaM2IvCHsxZvFh3yrtcvxbMZEIICX2EyO3FVsbGTZvmLwwBwC0ifBKyrN Z8pt8307JMeugKt4FwsC5UCfGEj7/fIPszPCP3lD47in8l77r8KB42bppiH2M83jMfH5cd 6/McJRZqef4kBbtpuYOn8uQpHbkusx5+fBQtdSuJi8P/5wb+5Lop/Ireauxw0A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YYQ9204YZz19X8; Thu, 16 Jan 2025 01:23:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50G1N1Or012159; Thu, 16 Jan 2025 01:23:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50G1N11A012156; Thu, 16 Jan 2025 01:23:01 GMT (envelope-from git) Date: Thu, 16 Jan 2025 01:23:01 GMT Message-Id: <202501160123.50G1N11A012156@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Robert Clausecker Subject: git: 521c1fe0e200 - main - libc/aarch64: fix strlen() when flush-to-zero is set List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fuz X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 521c1fe0e2002dfd7d8db86eb7144b7865229912 Auto-Submitted: auto-generated The branch main has been updated by fuz: URL: https://cgit.FreeBSD.org/src/commit/?id=521c1fe0e2002dfd7d8db86eb7144b7865229912 commit 521c1fe0e2002dfd7d8db86eb7144b7865229912 Author: Robert Clausecker AuthorDate: 2025-01-13 13:41:41 +0000 Commit: Robert Clausecker CommitDate: 2025-01-16 01:20:30 +0000 libc/aarch64: fix strlen() when flush-to-zero is set Our SIMD-enhanced strlen() implementation for AArch64 uses a floating-point comparison to compare a bit mask to zero. This works fine under normal circumstances, but fails if the FZ (flush-to-zero) flag is set in FPCR (the floating-point control register) as then the CPU no longer distinguishes denormals from zero. This was not caught during testing; this flag is rarely set and programs that do so rarely perform string manipulation. Avoid this problem by using an integer comparison instead. The performance impact seems to be small (about 0.5 %) on the Windows 2023 Dev Kit, but seems to be more significant (up to around 19%) on the RPi 5. Reviewed by: getz Fixes: 3863fec1ce2dc6033f094a085118605ea89db9e2 Differential Revision: https://reviews.freebsd.org/D48442 --- lib/libc/aarch64/string/strlen.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/libc/aarch64/string/strlen.S b/lib/libc/aarch64/string/strlen.S index 7bfac7f4b1e1..6fefc252eca1 100644 --- a/lib/libc/aarch64/string/strlen.S +++ b/lib/libc/aarch64/string/strlen.S @@ -33,9 +33,8 @@ ENTRY(__strlen) ldr q0, [x10, #16]! cmeq v0.16b, v0.16b, #0 shrn v0.8b, v0.8h, #4 // reduce to fit mask in GPR - fcmp d0, #0.0 - b.eq .Lloop fmov x1, d0 + cbz x1, .Lloop .Ldone: sub x0, x10, x0 rbit x1, x1 // reverse bits as NEON has no ctz