From patchwork Thu Feb 2 18:11:36 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: 649667 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp397236pva; Thu, 2 Feb 2023 10:18:13 -0800 (PST) X-Google-Smtp-Source: AK7set/TLQkSGPbohXEdNB/dDUd4/pNJQTIIyUgFy/u7qrRwCu+H/YBWI+DK5/56kcKW5HV6ON0Q X-Received: by 2002:a17:906:184a:b0:7c0:e30a:d3e5 with SMTP id w10-20020a170906184a00b007c0e30ad3e5mr8079222eje.18.1675361893764; Thu, 02 Feb 2023 10:18:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361893; cv=none; d=google.com; s=arc-20160816; b=GedlXqsv7orEWhIOl4kH/5+Y9vskKJ00/tJTh+JnBkT3aJFwF+gwIEPE1HUGKHBd6m p0HTVcjyn1u1+9SmGxHv8+AE+4YLbXh8LzmEyv2jBqGMWgIn852Ki2O2t7I+KgV1ruwE ME8A5zubH8CagmelIHLT7FMafm4/k3Hc04gG9RwKmlZhmG43YL0THrWibXTsdGWFDdFr Ux6t8fQU0x1v6ho2gxc0wGaS+9zK5hb42CeJiHgOVI0K7d/RnA7ysrmDh7nn+16z2mSg Vcgra3kR50F+lVK2CqLqMmKEtjudLkJxiB4YAN1fCg/slJXZfLrmZ5oE2sZvIvELlN+9 objQ== 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=4YbYZoIUJG5C/9HOQop3Df8+9J6Xk8b5bFDcEadWMBU=; b=p2YKubVNPdSjCjzr3da8LwWzw9xKf2phOkUqvm6VDpeoiOEbGL3JPEtHzqcQ1kP9Oy xutgjok3KXk95szXXnv6rHZm8pCG7rKzaOE4spQ2Dqh4Yo6wqZR/EPS5TdDDRFV5cGfT wA5Yx2lZTsWyYE8aktJijF88ligyW6TynwTbJkqESOQurjaSrBFKBVnKmjh07iQWAKbY B0cXa6TJP61ytmzrp/ZLodqGD1yp/IP58SzuI9zUzt13ADxfrMgWYMVLpiSyckWlQAMl IZZgbpNuQXqZyy3QtrasdpUafFE6Sxb3X02T59TFkFrIChjdIV2E2H9/xBCJ1JxM8GG7 r27g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=CiXlFhGT; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n12-20020a056402060c00b004a0afc59d41si53905edv.410.2023.02.02.10.18.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:18:13 -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=CiXlFhGT; 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 8A04038A90A0 for ; Thu, 2 Feb 2023 18:18:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A04038A90A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675361892; bh=4YbYZoIUJG5C/9HOQop3Df8+9J6Xk8b5bFDcEadWMBU=; 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=CiXlFhGTO5ojymQNDywDXTeU9bkZMV/Bw0B7thoJ7lQeT3B8u0H5rYo2hEo5xexX8 01oHq09hRsl658y4DFZ49mrB1JkA/YO/0+AH1SD+11rwcxzThF17QUkoyIzGKqnItR BIRLun4N5ULQsyfIF1kztDIcLBY70Te/olIrrYJw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 7AB2A38493EB for ; Thu, 2 Feb 2023 18:12:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AB2A38493EB Received: by mail-ot1-x334.google.com with SMTP id 14-20020a9d010e000000b0068bdddfa263so696246otu.2 for ; Thu, 02 Feb 2023 10:12:40 -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=4YbYZoIUJG5C/9HOQop3Df8+9J6Xk8b5bFDcEadWMBU=; b=kf67v98KjnPZMb9Wup7AKKHebAIt/lkYSJyGf0nru6KRmqcG7NT9LeNnb9oiuPL+6p lJ/7CwvVj5svBEOTM71Np4L2Tj08ysjnkeUSOheCxUyBrgx7fJSGwZiJAyhjUdYU8xhX CDHWBlAoJxC2lt/yBH+lH4GfkX2iq/7h0KsoVZ0AKI6He2bShnY52SXr6+wdOkTiuD5a XSB+QstD0fi9+2JSsdYKUs0qYN56MYW2T2KqX13VYYAnble8S6g0GU48bSy0NceEew9W t3bizjZxiI+HVnnikWzeqvYVgy4e4VqBbsOcQN19au6F+5X6xhRUdlnLcfBkG5RCHw0v DjZQ== X-Gm-Message-State: AO0yUKUEUgAkL8aeWeCI+72VApc8qieJBbUW5A4tzHAaG6p9mUTHT7GN FEhKrPXYL72sTIbtQ5/C83t1GcmNbHaqkqxQsR8= X-Received: by 2002:a05:6830:1e68:b0:68b:b96b:ec5 with SMTP id m8-20020a0568301e6800b0068bb96b0ec5mr3694855otr.9.1675361559542; Thu, 02 Feb 2023 10:12:39 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:38 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Subject: [PATCH v12 18/31] arm: Add string-fza.h Date: Thu, 2 Feb 2023 15:11:36 -0300 Message-Id: <20230202181149.2181553-19-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 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 Reviewed-by: Adhemerval Zanella --- sysdeps/arm/armv6t2/string-fza.h | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 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..50afaba038 --- /dev/null +++ b/sysdeps/arm/armv6t2/string-fza.h @@ -0,0 +1,68 @@ +/* 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 + +/* The functions return a byte mask. */ +typedef op_t find_t; + +/* This function returns at least one bit set within every byte + of X that is zero. */ +static __always_inline find_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 ones = repeat_bytes (0x01); + return __builtin_arm_uqsub8 (ones, x); +} + +/* Identify bytes that are equal between X1 and X2. */ +static __always_inline find_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 find_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 find_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 */