From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by sourceware.org (Postfix) with ESMTPS id 2E0DC3858016 for ; Fri, 2 Sep 2022 20:40:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E0DC3858016 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-11f4e634072so7509082fac.13 for ; Fri, 02 Sep 2022 13:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; b=hRIjaCaeIGIUPTS+4yYdXrDMGVpVnWoprDGJSojs0CqgnmNzRuj6fF3+qX++sKdC/V hggW+Dg69YFmrpLqdPoK9lOvVdsIhWPJeunpK+HXwzjm8NUImblhwKgPX4jscEbIbgKF iyvGwiFex/mgBWGBcjVCPks5CWVkNRAJEXbL5bv0hXBM3OyaQzhMu9U5lGHCDUuz56cG QxRKYbCHEJHHRvBSQIWQhLJ4sFZNNBe87/LnypdBOwGYNIyfY9PSM4zm8sMAKwfyZny7 1yEJsMSvIBy3nvD25KwmTEe4OPhte1RBc8d7iY4HwaJ52EclzYY1tm7ox0x8afd6n9JO Zg9g== 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:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; b=xhEHMY7m8tNgeJaeK2/Kn1ZBP6Z6Zq3XzV+QWAwGmdscLf1cyNu82dpHzepsaJAbRz DVIkqw30X4Qz9ykbOj6ykbbdJOxQEgzzkmJvqa/Nc6w9CQOXt7SHFcXN0BoPAy07RwfW zKBzQ5m8ifOUYVHqJFF0fHSCINp0dYt921j/oDFjozojka8Ag0nY/OwgrvLZKfX9fD2Q xtl1EvMJU8SPQ302ymyZ3sKhXtY/QWw5H+VqcSRHmv8EhYicHnuEGL8cNgae7H/fkmbD jKQP/Rnee8yWfygvN4iBfS/6Z3z3F9UZzzgpCKBOwRKiOl/o757f4LLosvvfqOUwCpal pCXg== X-Gm-Message-State: ACgBeo0XFTyuUdBPof+L3ygohz8bvWoLbbcuyY/9g5vOnbpjX6DgTLro 1IofhGAzTquWSF81WTzc1+oFreKbiK7CRg== X-Google-Smtp-Source: AA6agR7/+j/SGlwokqHAyxTyzbNSUTAdVcnF1W8z6vViT65Ka4nQEB32SIE73rKT/mGjQKQ42Z5XEA== X-Received: by 2002:a05:6870:79e:b0:101:48bf:7fa8 with SMTP id en30-20020a056870079e00b0010148bf7fa8mr3073469oab.291.1662151210377; Fri, 02 Sep 2022 13:40:10 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:dfed:72d1:946c:4eb1:ce5f]) by smtp.gmail.com with ESMTPSA id i27-20020a4a6f5b000000b00425678b9c4bsm1107902oof.0.2022.09.02.13.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:10 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Joseph Myers , caiyinyu , Richard Henderson Subject: [PATCH 15/17] arm: Add string-fza.h Date: Fri, 2 Sep 2022 17:39:38 -0300 Message-Id: <20220902203940.2385967-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> References: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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..4fe2e8383f --- /dev/null +++ b/sysdeps/arm/armv6t2/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. ARM version. + Copyright (C) 2022 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 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 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 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 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 */ -- 2.34.1