From patchwork Wed Jan 11 20:45:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 641275 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp3458828pvb; Wed, 11 Jan 2023 12:49:18 -0800 (PST) X-Google-Smtp-Source: AMrXdXviIDklHO01xqqj3WVis71hHGq6T1HTuUSm6Rhllcg2FR6mbiWVG4Zu8Vp3xgaFd3hFZIw4 X-Received: by 2002:a05:6402:2a02:b0:470:44eb:9e58 with SMTP id ey2-20020a0564022a0200b0047044eb9e58mr66391053edb.30.1673470158149; Wed, 11 Jan 2023 12:49:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673470158; cv=none; d=google.com; s=arc-20160816; b=SzmhsAOsq0NiTQZmLiAD8VByIsGrNyUzoRhS772yoOAPbliTuM1oV1brIcXtgu4AZt GhDRwVgOmF0Z3sg2DQSmGM4dC18zLDkXId24fMCTmIl29Pj2L1V9GXoHjbZsomrINJEh wBymtmkJJMuO3E+0J9B5BAeI3VjGZBSBXsZuuLA3VHwVIj3LL0dPi3fE7+DS3o9tCElC +RDviH+LMmA+nuJ8nk4yNjgRAnPdwB0WZaqnIhQihR3qmgigMH2m9YPpmVyRJ05kqEk0 +qi0tHZtcQIv0decOqkOVBY3FtN0gvPieGxjcYgSy0m1NpzkITcIoJUsD0EhlYQnG05t rW/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=4ccsKlaV6iEM5HdbbwpX6FgBr0cjdJfigDL2bOGuIrU=; b=0hBZr/GCsYUsKK4KpcR1Wcl/drZ83uwjL+wC45ljyjKdQezIVXUbYYuOb8eireEjAh B1Hdp6Otj4qRf9I3cc0RQt0Mn+sRelxcksljHkWAU0R4UgyuhaOqsYKybk63MeQ3JVJW sHSAomczvyd6aw7VBXXQ8eN/xZdPvEK1e+BY/9K839h4DnvZJdutavpy4ihL1GsGxGia aKxGbhid6weweZdBb75kWRFQrncUk6fgBWk6/GLmprO3FRe0fLUK/7b9wmfcRvSBTsMf OAWVXMgv9weg3jm0u+fztjnzAyGbg845CaGJkYg3eqkyqgKc294MGnHQ5oUjFDXq9rFM M3Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=BFK72Vx8; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Return-Path: Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f26-20020a056402161a00b0046965a49126si14512139edv.528.2023.01.11.12.49.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 12:49:18 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=BFK72Vx8; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0370F3817FA2 for ; Wed, 11 Jan 2023 20:49:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0370F3817FA2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673470157; bh=4ccsKlaV6iEM5HdbbwpX6FgBr0cjdJfigDL2bOGuIrU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=BFK72Vx8VJbkMf349lxBw9hSSSnBR/RFvFiBKBL8B132urXvP8vWLM0eTZ6z7FwgH YsoOYlIj1pnPDGOWip3YSppgzuyZb5GOL8uM4rQmO9JO6+6jOIvtL7UaMZ15+Clmms lbnkb2Bq56L+jnHOLIo7omdIPM9VtX4V4XBDtKJc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id ED0B338555A0 for ; Wed, 11 Jan 2023 20:46:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED0B338555A0 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-142b72a728fso16802657fac.9 for ; Wed, 11 Jan 2023 12:46:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4ccsKlaV6iEM5HdbbwpX6FgBr0cjdJfigDL2bOGuIrU=; b=23oA8p8N2F/AfK7ph8YJsYMPyQeJZw9xAQcgQSCL3HGbdkrcZbJRc3oaHswowkBDoI conTcCkstqLWBDuC113OahtUefuiK+h9au+xzQPDcCFXtSEYOljEB9LXV0HsHvXrxIVH PzLgJ/a6Yy5Nhj/CiRHP4YHXXSJI/tw5tswmpdPytIHHLCZDEquf80yZx+sCH62c18Jw cRVNp4fiZ6hcItbVdCWqyH591TsbNshhamS4Z/tRO7cs1OqGGpyniWCk6uC6h/57RdgX LFCVSRUQvL0qmYTnEJXdf6fSWc6hxl9PqCSBa0iVi6N/o5R7dF1A+84ebec+ivOR79C6 glFA== X-Gm-Message-State: AFqh2krYUE6u1ZbbCEEiF/CReoGXzHlWKukfPa1Ets20pBaw0MMLPZkD 0L0nJfO7Oj2+z6TbmWeLddpxx5YaM+NlWBu/SZo= X-Received: by 2002:a05:6870:89aa:b0:150:50f5:f805 with SMTP id f42-20020a05687089aa00b0015050f5f805mr24820498oaq.6.1673469995022; Wed, 11 Jan 2023 12:46:35 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a93a:a504:f3f6:dd7b:801]) by smtp.gmail.com with ESMTPSA id kw18-20020a056870ac1200b0014c8b5d54b2sm7990274oab.20.2023.01.11.12.46.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Jan 2023 12:46:34 -0800 (PST) To: libc-alpha@sourceware.org, Noah Goldstein , Richard Henderson Subject: [PATCH v7 15/17] arm: Add string-fza.h Date: Wed, 11 Jan 2023 17:45:56 -0300 Message-Id: <20230111204558.2402155-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230111204558.2402155-1-adhemerval.zanella@linaro.org> References: <20230111204558.2402155-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While arm has the more important string functions in assembly, there are still a few generic routines used. Use the UQSUB8 insn for testing of zeros. Checked on armv7-linux-gnueabihf --- sysdeps/arm/armv6t2/string-fza.h | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sysdeps/arm/armv6t2/string-fza.h diff --git a/sysdeps/arm/armv6t2/string-fza.h b/sysdeps/arm/armv6t2/string-fza.h new file mode 100644 index 0000000000..7aa0843325 --- /dev/null +++ b/sysdeps/arm/armv6t2/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. ARM version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_FZA_H +#define _STRING_FZA_H 1 + +#include +#include + +/* This function returns at least one bit set within every byte + of X that is zero. */ + +static __always_inline op_t +find_zero_all (op_t x) +{ + /* Use unsigned saturated subtraction from 1 in each byte. + That leaves 1 for every byte that was zero. */ + op_t ret, ones = repeat_bytes (0x01); + asm ("uqsub8 %0,%1,%2" : "=r"(ret) : "r"(ones), "r"(x)); + return ret; +} + +/* Identify bytes that are equal between X1 and X2. */ + +static __always_inline op_t +find_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or equality between X1 and X2. */ + +static __always_inline op_t +find_zero_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or inequality between X1 and X2. */ + +static __always_inline op_t +find_zero_ne_all (op_t x1, op_t x2) +{ + /* Make use of the fact that we'll already have ONES in a register. */ + op_t ones = repeat_bytes (0x01); + return find_zero_all (x1) | (find_zero_all (x1 ^ x2) ^ ones); +} + +/* Define the "inexact" versions in terms of the exact versions. */ +#define find_zero_low find_zero_all +#define find_eq_low find_eq_all +#define find_zero_eq_low find_zero_eq_all +#define find_zero_ne_low find_zero_ne_all + +#endif /* _STRING_FZA_H */