From nobody Sat Mar 26 09:13:51 2022 X-Original-To: dev-commits-src-main@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 2A9431A26FAF; Sat, 26 Mar 2022 09:13:52 +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 4KQYDH6qMHz3vMd; Sat, 26 Mar 2022 09:13:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648286032; 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=ms49MrEwIqBEyd6ZL3o2FpcAy5QdG8ux+079xTSTCRE=; b=fI9qqYbWTBzWosmxYYFzY0oEaFFaFpteB3OCaWUDJMJO/1DUNIVIw7HCCAFbxMp5RxXGB7 sAoXZKSDgZ2PzRD+PTD86jbjOeC8eGTxQs2Ln9KXYdG9RkkpfLTpeHvq1FOPKbjbArv1rJ hROpwoeBzyBW6JTZc9XmwMVKcBQtsaEhC1zzdCPoGTT9fBJZlq1D9QyFGYpzw/qVTQOuOQ Jk3onGsAtVXchZwdYG42WBVgk3wjxEDhNk23P3ERNGjad9xKtsHe2oFC9V+iP6Pqzl0lGq at0qbU4l28KwPn5sJhQCYLP0mxWNrtfd49v2nYVE5Mbkl+ywqkMZaVmDPgGY8w== 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 B9B261E595; Sat, 26 Mar 2022 09:13:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22Q9DpG3010891; Sat, 26 Mar 2022 09:13:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22Q9DpEH010890; Sat, 26 Mar 2022 09:13:51 GMT (envelope-from git) Date: Sat, 26 Mar 2022 09:13:51 GMT Message-Id: <202203260913.22Q9DpEH010890@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: fbc002cb72d2 - main - amd64: bring back asm bcmp, shared with memcmp List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fbc002cb72d2d9bb435cce99630d5d7da9f59390 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648286032; 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=ms49MrEwIqBEyd6ZL3o2FpcAy5QdG8ux+079xTSTCRE=; b=IvDFMAzxS14azMwpaADmupuTHTGK4eggLpaM43PksP/o8stAjI1mHO48T3HIoIorBC5jQe YDWnOA22bfWDsZil6BAeAtaVdUjutd2DKSyMKJewuHQVZw0YzB3fjy1eOb/9Ihw8imyYse AL2cxteTgzZ0+HNSO4ZK8o7W/fBADECshfImBKlq/J9I5hY6xN8vOewSnvs5Ir9yn9lYrT VhMzL/5emW0v9xSsGuJ4lgYSm/6JDUnrXuKUFj3ZXwLtJEdV85a1ik6uXEKYtH8JQflgUs qXuIzmbDwURRlDYY1NIx+IkRvCDEIk7F7k6eaGZJ+mzVmH0DfGQHcbY9iYe11w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648286032; a=rsa-sha256; cv=none; b=t8LSdipZJvR52lDZ3SXIWjoBGGrDrMQ4qkrbZ//ZBEZr1LZ6P/sByEOU2sig/63LGxn7Ru o9iwdYZSJxJUnFUPsMxW8nKWiPCHaNAGVUtzvt/07BnCn7SXKoFgEa2lFzE77+8AXgtUNP Ok800GYEDm+9M1+y2uMaw1Qvdb6dpOZxoA+kEnA+rd/O3SF1HXiDjQWFoATWXx/iSoMZv7 4lKaf8Py5Vp3S1tRoYK6n51ND7YUMEihSuZQJZlHB5bdDXJsC85tFO142Zjf7QDzAYgZy5 mNE7b/Ewt7vSctE56+4dTvEiHSfvEgYTaulUlngKtDPCp2N5/a7r3muAtgyjmg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=fbc002cb72d2d9bb435cce99630d5d7da9f59390 commit fbc002cb72d2d9bb435cce99630d5d7da9f59390 Author: Mateusz Guzik AuthorDate: 2022-03-25 15:04:04 +0000 Commit: Mateusz Guzik CommitDate: 2022-03-26 09:10:03 +0000 amd64: bring back asm bcmp, shared with memcmp Turns out clang converts "memcmp(foo, bar, len) == 0" and similar to bcmp calls. Reviewed by: emaste (previous version), jhb (previous version) Differential Revision: https://reviews.freebsd.org/D34673 --- lib/libc/amd64/string/Makefile.inc | 1 + lib/libc/amd64/string/bcmp.S | 7 +++++++ lib/libc/amd64/string/bcmp.c | 16 ---------------- lib/libc/amd64/string/memcmp.S | 26 ++++++++++++++++++++++++-- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/lib/libc/amd64/string/Makefile.inc b/lib/libc/amd64/string/Makefile.inc index b77079afc933..cb370bc6be1c 100644 --- a/lib/libc/amd64/string/Makefile.inc +++ b/lib/libc/amd64/string/Makefile.inc @@ -1,6 +1,7 @@ # $FreeBSD$ MDSRCS+= \ + bcmp.S \ memcmp.S \ memcpy.S \ memmove.S \ diff --git a/lib/libc/amd64/string/bcmp.S b/lib/libc/amd64/string/bcmp.S new file mode 100644 index 000000000000..f7a4603f6c5a --- /dev/null +++ b/lib/libc/amd64/string/bcmp.S @@ -0,0 +1,7 @@ +/*- + * Written by Mateusz Guzik + * Public domain. + */ + +#define BCMP +#include "memcmp.S" diff --git a/lib/libc/amd64/string/bcmp.c b/lib/libc/amd64/string/bcmp.c deleted file mode 100644 index b45176dc2d56..000000000000 --- a/lib/libc/amd64/string/bcmp.c +++ /dev/null @@ -1,16 +0,0 @@ -/*- - * Written by Mateusz Guzik - * Public domain. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include - -int -bcmp(const void *b1, const void *b2, size_t len) -{ - - return (memcmp(b1, b2, len)); -} diff --git a/lib/libc/amd64/string/memcmp.S b/lib/libc/amd64/string/memcmp.S index 0c8121f9d885..3e6df7966312 100644 --- a/lib/libc/amd64/string/memcmp.S +++ b/lib/libc/amd64/string/memcmp.S @@ -39,7 +39,11 @@ __FBSDID("$FreeBSD$"); #define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */ +#ifdef BCMP +ENTRY(bcmp) +#else ENTRY(memcmp) +#endif xorl %eax,%eax 10: cmpq $16,%rdx @@ -143,8 +147,25 @@ ENTRY(memcmp) /* * Mismatch was found. - * - * Before we compute it we narrow down the range (16 -> 8 -> 4 bytes). + */ +#ifdef BCMP + ALIGN_TEXT +10320016: +10320000: +10081608: +10163224: +10163216: +10163208: +10040804: +80: +1: + leal 1(%eax),%eax + ret +END(bcmp) +#else +/* + * We need to compute the difference between strings. + * Start with narrowing the range down (16 -> 8 -> 4 bytes). */ ALIGN_TEXT 10320016: @@ -214,5 +235,6 @@ ENTRY(memcmp) subl %r8d,%eax ret END(memcmp) +#endif .section .note.GNU-stack,"",%progbits