From nobody Wed Jan 24 19:44:45 2024 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 4TKvYT4XcZz58byN; Wed, 24 Jan 2024 19:44:45 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TKvYT3lymz45vx; Wed, 24 Jan 2024 19:44:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706125485; 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=urA6C0nK8QWTGpAkMueLyumKoRFp00uR73vU36lsDgI=; b=wx+b8sRfgtHiUo4eQl9G8l+z+lYCSShQTop692MzwskDIjIpcJb6fwSWKBEdjxwO+4eY1n FuwJS3tSfy0JUrXKr5nqQxWnSn7V4rqjxjcAruG+OWZ9iHVFyfvKgs0/0AboWPDsp/UG54 qH91Y/kLbQswUgC7qFTVZf4V70lNGgjv+/+Vr/Vrud5CCutupR+72JEEyLQXUrgmlZpstU tYpjK/4f1JaOMbWu2g8uR7/tCr0XYkcy+hkSOKlJB9t8YJDDO3lMJx68i0Kk0XUOxqyP9+ hytaXXv/DwBC01QXrQkZhUngTL1+x/X+ILgjYwE7/zUEKuCm47H6YggquNAtzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706125485; 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=urA6C0nK8QWTGpAkMueLyumKoRFp00uR73vU36lsDgI=; b=dRDC0IfjiOTxQ+SqcoeV0uIy2V2/OkXyJOrhhcmUSNB15iMlf/ypOViQa07wXqZkAuzKOP C8IbpgDh80K8fbMrzWx/hZeXzBvAYNrv/cgItndokoBecJQICG1Fdf8Y8agTxY5U51jgfq pLAZNLPoB4jNKTJN5ldHe9MtGwN8sWT7Tz3QaqFaWxX3oobPScLIYh1Qk3+k/ge3dOriWs 9KZxCnZEpoQVigyhpEAH9Z4P0mej8r1af7QtebhkEFZe0m8bwnhOxDpwihRCEzd0ABtT7p 7Bn9HpX+DiYX6EmcIICAX15RONEGhezA62RbNmK7nEkK7bMrOU0SkogeQQCvzw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706125485; a=rsa-sha256; cv=none; b=jXhq2/464V7Y/fypIBjf+kI9DPt27wCxriAOvEZzDC2xHyHQWBwBcJ+/qTBBQqF7CPmIqK lgS9pCWGFa18OjVmjnsbVo1l3ZT0ZrecM/r/OZEVKrm/bphYJOlsxLbVTDAHliaVW18N/o G3KYuy4JKEo4B7eL0f7rLNXvt9Vicj3Nqru//9JeETDhjWbc3jkDfaqIY9Kk5KfFTd4xrD VRNgHShOfdYCYq7hXsniEsGEGHgNNC1bstuwft7SZgEJZD68IyLpMl+LxOZJEa0Fy+It7e VU4If5xVyd/yWTzDpodPvcJa3aVWuXuxFIq3I4aevnU7fmvnLlZSU1P0DDgI0w== 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 4TKvYT2tLlzRmv; Wed, 24 Jan 2024 19:44:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40OJijdK005508; Wed, 24 Jan 2024 19:44:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40OJijUO005506; Wed, 24 Jan 2024 19:44:45 GMT (envelope-from git) Date: Wed, 24 Jan 2024 19:44:45 GMT Message-Id: <202401241944.40OJijUO005506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Robert Clausecker Subject: git: 7a605ba8f799 - stable/14 - lib/libc/amd64/string/strcat.S: enable use of SIMD 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 7a605ba8f7996f38ba7b353a0120d84bae48da0f Auto-Submitted: auto-generated The branch stable/14 has been updated by fuz: URL: https://cgit.FreeBSD.org/src/commit/?id=7a605ba8f7996f38ba7b353a0120d84bae48da0f commit 7a605ba8f7996f38ba7b353a0120d84bae48da0f Author: Robert Clausecker AuthorDate: 2023-11-14 18:09:08 +0000 Commit: Robert Clausecker CommitDate: 2024-01-24 19:39:28 +0000 lib/libc/amd64/string/strcat.S: enable use of SIMD strcat has a bespoke scalar assembly implementation we inherited from NetBSD. While it performs well, it is better to call into our SIMD implementations if any SIMD features are available at all. So do that and implement strcat() by calling into strlen() and strcpy() if these are available. Sponsored by: The FreeBSD Foundation Tested by: developers@, exp-run Approved by: mjg MFC after: 1 month MFC to: stable/14 PR: 275785 Differential Reviison: https://reviews.freebsd.org/D42600 (cherry picked from commit aff9143a242c0012b0195b3666e03fa3b7cd33e8) --- lib/libc/amd64/string/strcat.S | 47 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/lib/libc/amd64/string/strcat.S b/lib/libc/amd64/string/strcat.S index 0834408acfb7..081e98840cee 100644 --- a/lib/libc/amd64/string/strcat.S +++ b/lib/libc/amd64/string/strcat.S @@ -1,6 +1,14 @@ -/* - * Written by J.T. Conklin - * Public domain. +/*- + * Copyright (c) 2023, The FreeBSD Foundation + * + * SPDX-License-Expression: BSD-2-Clause + * + * Portions of this software were developed by Robert Clausecker + * under sponsorship from the FreeBSD Foundation. + * + * Adapted from NetBSD's common/lib/libc/arch/x86_64/string/strcat.S + * written by J.T. Conklin + * that was originally dedicated to the public domain */ #include @@ -8,7 +16,14 @@ RCSID("$NetBSD: strcat.S,v 1.4 2004/07/26 18:51:21 drochner Exp $") #endif -ENTRY(strcat) +#include "amd64_archlevel.h" + +ARCHFUNCS(strcat) + ARCHFUNC(strcat, scalar) + ARCHFUNC(strcat, baseline) +ENDARCHFUNCS(strcat) + +ARCHENTRY(strcat, scalar) movq %rdi,%rax movabsq $0x0101010101010101,%r8 movabsq $0x8080808080808080,%r9 @@ -161,6 +176,28 @@ ENTRY(strcat) .Ldone: ret -END(strcat) +ARCHEND(strcat, scalar) + +/* + * Call into strlen + strcpy if we have any SIMD at all. + * The scalar implementation above is better for the scalar + * case as it avoids the function call overhead, but pessimal + * if we could call SIMD routines instead. + */ +ARCHENTRY(strcat, baseline) + push %rbp + mov %rsp, %rbp + push %rsi + push %rbx + mov %rdi, %rbx # remember destination for later + call CNAME(strlen) # strlen(dest) + mov -8(%rbp), %rsi + lea (%rbx, %rax, 1), %rdi # dest + strlen(dest) + call CNAME(__stpcpy) # stpcpy(dest + strlen(dest), src) + mov %rbx, %rax # return dest + pop %rbx + leave + ret +ARCHEND(strcat, baseline) .section .note.GNU-stack,"",%progbits