From patchwork Tue Jan 10 21:01:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 640905 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp2917125pvb; Tue, 10 Jan 2023 13:03:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXtyGwVQBljpNIO2RmATFKNRHQTaWV99HQSOigxWHsIJ9cGPs1BKowfJZw/K/Wb1xXbPgDyF X-Received: by 2002:aa7:c796:0:b0:46c:aec4:606f with SMTP id n22-20020aa7c796000000b0046caec4606fmr58085101eds.23.1673384620340; Tue, 10 Jan 2023 13:03:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673384620; cv=none; d=google.com; s=arc-20160816; b=qBo3BvmqghXrxgMYkBL1VRUFL4S3QPUR/KjT5otlUZ2ZyLlijYlRtXofOSEteVIm58 ELjV0bRx2mmBUVFgU688RZg3fqZK4VJeg+0/riklWnrU3CLyc5+IpHyNJQcfHMUvRtoT kzL7JLk/20HdQ9dfDh0cxML3EN9PXoPLsq/9qH55j2RlywUUuxby1HUu8kC/QY2W3AHh DSqjKvYEQeZDMHQ+h0K4O0PoLH93OikN1lOsF0MKzKsaVHiE7eK/ECnULSLq3OOtR2jx vbhG+lo+B54CpRURQyNyFBzfd1giQg/gQOOY83PXD3lygEqSSK+9SykJI3iv3w66zXBF UFcA== 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=oSzWUyoK6B9ka21zcdc+KYbxxMAOYmv5enSoRcADjRmA4L42bz0i31lLOEF+Rpr9M4 NjkpQD1UgZJCNHTE3BYw5L6T/bGDR1Oc5nvRVGnPxXSbrtxevy+f7mP1x5qL7gAahP8m 5J8Igv3oKMND/KZj2kUs8YJWwCvguQ/KFFlry8DNoU3XlQ7o/LhJkXkALWpeqr6/flQV KwvFGElocLSNc/OrYiHCRhTld1ehVK7aHLI+/+cMm/l5Q6bPgxfIDCmo6cIKv0DVuCtM 5pN8BGp4clfTM9eImsR7npROcKdATGHvRsKbKMP/QhknV6YKMDpneo/3uekSMRCMB5IS +NjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=yPCGHwE3; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q11-20020a056402032b00b0048d858ddabfsi11867412edw.414.2023.01.10.13.03.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:03:40 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=yPCGHwE3; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 F01473896C2A for ; Tue, 10 Jan 2023 21:03:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F01473896C2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673384619; 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=yPCGHwE3PfRDuN9zPlxWi5W9zrezXkAVPFvwNocwwlRdMiSjTR+CqmuoGRVXJ2EOj /DTUZZzmB79vPkQ9pBDs0drA6rlNZnGsULX2ibF04TyrGz7zv1am+dg89fQciw7vMW Ja2tTBo3Qv8ElJ2/SQrNREaZTIaSc1Ei7WEPMeR8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by sourceware.org (Postfix) with ESMTPS id 5077F3858414 for ; Tue, 10 Jan 2023 21:01:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5077F3858414 Received: by mail-oo1-xc29.google.com with SMTP id q20-20020a4a3314000000b004f2177e6b38so601337ooq.3 for ; Tue, 10 Jan 2023 13:01:48 -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=koFaaSxoUWe3xkXJpsUBhmpCl4zMkfgIpmtFotEJ3UcjGxgODxgYXFD7ZOHdmvhWau GOMFF33IQDYXKI0stJMEVo2aeRKU1Pr5KTH10xUdBLkBZKYHce1nry4B9L7rh49xo+Wx CuGk48spM//38nKVevH8HyePlzlPguMzEU5E2XC0oazazOZc15Apb83ZgVnr6Fpev/Bm lbIaTJ1pzIB3A0K2HG+9ZLxpxajAt0cO+q7Rd8XbB1NwfCDf4Qvj105eQDWOm3kS14XE vjU9tqhz7SBcqiZ3wor8XbMoY9qHjmm4aQvfKIf6195vjYl4W3Q5w5Ze5UWlO7jkaFxQ P9OQ== X-Gm-Message-State: AFqh2kqgT+Tdxj2gox38RMwayRIy5pW6zZXvfHbC6wiso4b0haHrjxoA QUg7rk+HAIMS4fwo9rrkrigEHYyCyEEqRcHMhPU= X-Received: by 2002:a4a:df0d:0:b0:4a3:e7ac:d31b with SMTP id i13-20020a4adf0d000000b004a3e7acd31bmr35464181oou.5.1673384507318; Tue, 10 Jan 2023 13:01:47 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a93a:e8a0:dd55:3328:997]) by smtp.gmail.com with ESMTPSA id r5-20020a4a83c5000000b0049ee88e86f9sm6202193oog.10.2023.01.10.13.01.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 13:01:46 -0800 (PST) To: libc-alpha@sourceware.org, Noah Goldstein , Richard Henderson Subject: [PATCH v6 15/17] arm: Add string-fza.h Date: Tue, 10 Jan 2023 18:01:04 -0300 Message-Id: <20230110210106.1457686-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230110210106.1457686-1-adhemerval.zanella@linaro.org> References: <20230110210106.1457686-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 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 */