From patchwork Tue Jan 17 20:00:06 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: 643409 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1365971pvb; Tue, 17 Jan 2023 12:03:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXvvjUgRDU1GdFjCDxr3C8CVFk+d0DZ/Ln7J4OhViC6cZDQDKgyW18EYLlJHbaN8wFD7Y72z X-Received: by 2002:a17:906:299b:b0:84d:4394:e8e with SMTP id x27-20020a170906299b00b0084d43940e8emr4154433eje.41.1673985801771; Tue, 17 Jan 2023 12:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673985801; cv=none; d=google.com; s=arc-20160816; b=B2146E46GT6xxD+FHv+DV3oFKXl2oFg+BlO/tyVfD+u1n5pnUuE28LtzHrX+95ZqxD wN2RUNlDO/a9Ze+N+TgGaiYJoNpe7bzWR+r7tw+bXZLY1pT2E3GysNztlQznv8wPm3TS WX5qJaEHlTCBquyjND5TLIMz1xp911xlj3awBUaFXzGw67nIdzTgP7CDI3TXW+C6WHfA AXqOHfG0cPl8zdoFxwrQK9EPRz6P72GKH3IkY7mGSawjemxhcqhGu7+aU6HO1FuyZYOL EfIywdU/tid/CCaiWKAUpCOQfWwtrbJY+TLneUggkJPlOd6Ak3ugDBzCjPkn0kvd2rON bOzQ== 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=HaJ+7l04b7U2bl/WHHkBz/tOSu1xV2SCXVSw6G0miYY=; b=sSFae2BvdQd7ehmiFqr/vY/2I6ezFteWJdVeTl/D0mza6eofmnPVyWg42fWnA7voN5 mEijxB7fDGto50s5Ffs/ghps1uNc3TTevY9FpV5rSY7Xx9gbpXAFaciOm6asfJT2exbt 9ELia+i9QTL3m8B4slH4bU1ynT8QfoGwPD+0MS7o9ugQLrRgy2qAMwLXFzOtP+1ZrOug nk/iv8wD2L6vY24iN+BCUz/bFthveRWQ0iQwaeeC9lw717G0lVRwuMLRuRLaEGykAFKk xgnAy0EZ/XyQZ4SjupLCfpYfb712eOHH3n/m3MCPy7hRtP99x8mG9mpSSTPjqm0aACWb bscg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=h+6Etktz; 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 dm22-20020a170907949600b00797670441desi34492011ejc.911.2023.01.17.12.03.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:03:21 -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=h+6Etktz; 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 B01F838A90AE for ; Tue, 17 Jan 2023 20:03:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B01F838A90AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673985800; bh=HaJ+7l04b7U2bl/WHHkBz/tOSu1xV2SCXVSw6G0miYY=; 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=h+6Etktz8YQaBK5Li0Y5Q0/Au/pNOeo3SHOP4MjOq7qubqJ4W2e0VLkDAY+zVxBhO 2tlizMfJxkYrp7WtptUPPmxesFQiZ5ooDim5qKto8boEduFoiaT5iOQtXBKv1qOs7a VHfVR37obJJckIBxw52BB3nZRLEYRYh7jjlvyPNw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 716AD38582AC for ; Tue, 17 Jan 2023 20:00:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 716AD38582AC Received: by mail-oi1-x234.google.com with SMTP id r9so16110698oie.13 for ; Tue, 17 Jan 2023 12:00:49 -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=HaJ+7l04b7U2bl/WHHkBz/tOSu1xV2SCXVSw6G0miYY=; b=h+n1s5j+B52QdQ5FahUk49nAJ1mOkSbc3NjDFJtmgGnlTzYgYXLpQ+3n8Qsba6B9Pc Xzco9hP2IQIzkU9YNgKwRS7qQ9+vIPzYAcaCvfTUJkKi/Njv2c7zAfjeSM8DuynIrOv4 M7P0Jv4Dh5Ax6cAFBJRqW4iGxbYfRS7llXPxnL7pImI8IOuN/krxbvS6yNqx1OijwI78 uoZOnddmVwJRV+ZwJdGL780d43q2ldKnbQ5T1w3qGq0FyJYR/+ULejXZD2zwVd6jCJvG Nw9A4a3kzZJRW5E1SAw/u4vAAD26eNOXQpRjcsRyOsox0e4ys4jBJS7kcz55reA+Ygoq 80Hw== X-Gm-Message-State: AFqh2koPmt03wwHGyzVHCdREkv/aiOHzFPbpXPi0EAF5P8qXQwxbKeb6 dwoPiNG89uU7q6UD5GbB1MwZjpGcLDkkRlmoJLw= X-Received: by 2002:a05:6808:211a:b0:35e:d234:7120 with SMTP id r26-20020a056808211a00b0035ed2347120mr2751334oiw.1.1673985648153; Tue, 17 Jan 2023 12:00:48 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1652:fbfc:c80a:f5e8:5ed9]) by smtp.gmail.com with ESMTPSA id l10-20020a056808020a00b00360e46a1edasm15095866oie.22.2023.01.17.12.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:47 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v9 14/22] arm: Add string-fza.h Date: Tue, 17 Jan 2023 17:00:06 -0300 Message-Id: <20230117200014.1299923-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> References: <20230117200014.1299923-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 --- 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..eb1b3dd058 --- /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 */