From patchwork Mon Sep 19 19:59:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 607323 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp1666834lth; Mon, 19 Sep 2022 13:00:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6r6TrfqkKteZiA7qrHFJ0X/XU0jEPPvb1cYhYw4NxZHZzYWMWDYUmWUvRzC+mQo2Isti/V X-Received: by 2002:a17:906:fe46:b0:73d:939a:ec99 with SMTP id wz6-20020a170906fe4600b0073d939aec99mr14132813ejb.169.1663617625261; Mon, 19 Sep 2022 13:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663617625; cv=none; d=google.com; s=arc-20160816; b=s4J8i0SkfiDpiq/ukqO5gRe6tDTRxSVcKHeHRiTdfmc8sCUzom0hTNySWGsuERU7fv Svo3EsPJMY9YEONoOHugwyR2O2qzMzXsokd6XWUObu6aVtJvtORsmUIl0B0l31ZbdsgA J2Ox1z5c2WSCY4Qu3nffQpjwpiDrjkcsjvjoO7CsRYPv7QO/3X3QzxmnoXkh+j/3xTzb Yws7M4WAYqA2rO4Gy9l7Q7NPYh2/CUlvXy61QikvbpxN59AYxAGFu8RBhFh/kNeBSa3y TKkvKwprx3gtPCSw56L+JebQrx6sZrfhreAz2etkLsa0kh6WsWKz4tumqAGJYQyKxGuL n6yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=uyhyLz38LFlPYNj6QCjH8NWe1tXKsAkhUH/RV/4H9fs=; b=LCCdQeHPbZG5w7EfM2crUxnT5Ca229zCFMRgFqqw7SB4aBLZbPznnrLiEHIyjLZKb+ IGFQJ3QP4c+JDG45cIxcb97iUQ5lgkP3jDcHDdI7iOLMrEuF63gkR8o31lWCkZPXvrDJ lPi2yvFES9FnfDY5Kc3KJc4obeAy+/3/tF7usj7ar2akxBH3X7DD2PxzF/3WzeCHDQ9x ue3guvVx510MonwcIpf1WCkBjIy0n6N9tWzDl9cGiHk3IYSmURVLZ82vofKNVT6Kjs8+ GS+Qwm6vDTnuPXghfdKX+wDWmKlDwAySTd9/sRmysRpUns3WHu2a1KYBT30I/Tf/K+Ol UghA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=dh8uhXm4; 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 hg3-20020a1709072cc300b0077d589c4055si15877731ejc.735.2022.09.19.13.00.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 13:00:25 -0700 (PDT) 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=dh8uhXm4; 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 3D936385B83C for ; Mon, 19 Sep 2022 20:00:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D936385B83C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663617624; bh=uyhyLz38LFlPYNj6QCjH8NWe1tXKsAkhUH/RV/4H9fs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=dh8uhXm4V10ctnI33oIqVyaFE2XQGShaGkAUvfXeIbXNVbSfoOH+C+DBCxzWfvP2/ Cx1+BHf8SV8aMM3qBz1QQyLYQKrgFgwK3TBnIbhbmpA7nNFliW3czg8agMbtqi5TPO LtrxoJfSEaGr4HY8uW76YyaqHmbSHYkGH5WZlySU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x30.google.com (mail-oa1-x30.google.com [IPv6:2001:4860:4864:20::30]) by sourceware.org (Postfix) with ESMTPS id 983D33858D32 for ; Mon, 19 Sep 2022 19:59:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 983D33858D32 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-1274ec87ad5so1092732fac.0 for ; Mon, 19 Sep 2022 12:59:28 -0700 (PDT) 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=uyhyLz38LFlPYNj6QCjH8NWe1tXKsAkhUH/RV/4H9fs=; b=M5nTOKeov0D4M6GBnfDajO8c9Hm41OWTrUqAmM00Q+EHWuqSAnA9Ogtlp29cGHtKZN SCSxBqz8GRGO0KjiNG4pcLJxMbJ2GuMiffB6JtbszdM8ZUhpF9zSZz+3GYd9+TNTspp4 MidQr0nhLAmfotAPrv6kAJ2G9FGiB7vNAXOesT3jUdA+Pbx3bb/ehnDKF+mDvdp0fCtr sZoaWR58PigiNPAYMH34RzxunMYndD6Vz6ADu8PEXWTQMh6ycjlv2mYo7mVowPRdSOAF 1nvzrqtFSJoqWHOHNWB3xU/HJr6xg/eqP7xmgCpcD+cIR//mcgpScYnjOxuEnXFmfGhI iDQw== X-Gm-Message-State: ACgBeo16cBGn24deONr7Wc2Pqu1AX+pQa8Hmt5+FGyAXiFNLfK0iGRmi jNcu4FXIJGhHjEKgp1a1NIin01qwUad3Gwa9 X-Received: by 2002:a05:6870:d625:b0:127:db0a:c4ac with SMTP id a37-20020a056870d62500b00127db0ac4acmr16288094oaq.75.1663617567780; Mon, 19 Sep 2022 12:59:27 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:b3ad:a56d:1ca:d6ea]) by smtp.gmail.com with ESMTPSA id l7-20020a4ab0c7000000b00475dc6c6f31sm4532291oon.45.2022.09.19.12.59.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:27 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 01/17] Parameterize op_t from memcopy.h Date: Mon, 19 Sep 2022 16:59:04 -0300 Message-Id: <20220919195920.956393-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919195920.956393-1-adhemerval.zanella@linaro.org> References: <20220919195920.956393-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 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 Cc: Richard Henderson Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson It moves the op_t definition out to an specific header, adds the attribute 'may-alias', and cleanup its duplicated definitions. Checked with a build and check with run-built-tests=no for all major Linux ABIs. Co-authored-by: Adhemerval Zanella --- string/memcmp.c | 1 - sysdeps/generic/memcopy.h | 6 ++---- sysdeps/generic/string-optype.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 sysdeps/generic/string-optype.h diff --git a/string/memcmp.c b/string/memcmp.c index 40029474e6..6a9ceb8ac3 100644 --- a/string/memcmp.c +++ b/string/memcmp.c @@ -46,7 +46,6 @@ /* Type to use for aligned memory operations. This should normally be the biggest type supported by a single load and store. Must be an unsigned type. */ -# define op_t unsigned long int # define OPSIZ (sizeof (op_t)) /* Threshold value for when to enter the unrolled loops. */ diff --git a/sysdeps/generic/memcopy.h b/sysdeps/generic/memcopy.h index 251632e8ae..efe5f2475d 100644 --- a/sysdeps/generic/memcopy.h +++ b/sysdeps/generic/memcopy.h @@ -55,10 +55,8 @@ [I fail to understand. I feel stupid. --roland] */ -/* Type to use for aligned memory operations. - This should normally be the biggest type supported by a single load - and store. */ -#define op_t unsigned long int +/* Type to use for aligned memory operations. */ +#include #define OPSIZ (sizeof (op_t)) /* Type to use for unaligned operations. */ diff --git a/sysdeps/generic/string-optype.h b/sysdeps/generic/string-optype.h new file mode 100644 index 0000000000..fb6d67a19e --- /dev/null +++ b/sysdeps/generic/string-optype.h @@ -0,0 +1,31 @@ +/* Define a type to use for word access. Generic 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_OPTYPE_H +#define _STRING_OPTYPE_H 1 + +/* Use the existing parameterization from gmp as a default. */ +#include + +#ifdef _LONG_LONG_LIMB +typedef unsigned long long int __attribute__ ((__may_alias__)) op_t; +#else +typedef unsigned long int __attribute__ ((__may_alias__)) op_t; +#endif + +#endif /* string-optype.h */ From patchwork Mon Sep 19 19:59:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 607322 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp1666459lth; Mon, 19 Sep 2022 12:59:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM788lqr8H3Z5qst5kpnD5yB5Lf2/2Ow3LtfHBoMzvmP4HiTKTzmEy78aUWXSNYOdSw4bqPB X-Received: by 2002:a05:6402:190f:b0:452:d6ba:a150 with SMTP id e15-20020a056402190f00b00452d6baa150mr16975034edz.126.1663617580402; Mon, 19 Sep 2022 12:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663617580; cv=none; d=google.com; s=arc-20160816; b=E+7b8C0xI5jPPBF+huZkZ29Z6OieLMkRT41XRb3C2GMK2fjNYHpOf3yVgqmd1KQbdL Vy2Yr5anZm+qYRJNFBGAQv0ZsDevOVTqDIJ90Vgv8Vnqy9TFhH8M7wOIJP/9UeXDWo/k tgeQAqVam7W3WYz7oiwWmuntFDXFrBLiq5Hyq3+NEwu1j05Zt8bzfI1dIYuyoW7niG5K SDJ8rq9yTsEYYKxiAKZVAXl6TY8ioXlmNqfivzu8um5MfQTXKRdFwR8DsT7bWhxkbW8O fOCVYO4ZzCarmMbN4ppoKRd4xHoTrXXZIOO0Lc4hrLhN/i/0p5xitjNE5ObU4mJSO5hS dnyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=sH7XP65dr4Y5FSbOljjOPzXkAP0NsQyXcAoyHJedZ9k=; b=Q8NJGxp/wacI5XHNaXiZPPmFmq5v8tSFtO5+7E75goOG+5mAl94RPNM8AFKMfm0NoF /WLEsLVFYf0LajG9mezPC/PMJZoE3z1gtvYH4cNpQ9Ae+EovX0/u/ug9t7qNICUhcJxO YTOGYAO9/H2cc0u1COHMVwuyk1h612F1YQ73EOdoZJzi2rRyorBb2a7BE6y9tFtOnXHl BNi+XrgVZznD1I7rdcdz9nMgBKY9TNef00/avLsmS0ivaTu91s9C2ZrzRqD4WjB3UU4y HsRCGKUEIuPxjSTzphHk1M9mdu5u7py7IPEuXczyhsaGAevPoz3vheiskb5gTZptaiLY uu+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=FFKa54we; 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 sd23-20020a1709076e1700b0077b771999absi957163ejc.870.2022.09.19.12.59.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:40 -0700 (PDT) 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=FFKa54we; 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 5F1FF385801E for ; Mon, 19 Sep 2022 19:59:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F1FF385801E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663617579; bh=sH7XP65dr4Y5FSbOljjOPzXkAP0NsQyXcAoyHJedZ9k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=FFKa54weXxi3d5Ggi2HwKcya/B5nx5lfocQY91UltAsOHtFp47dWWYELcaORAU31r xWNjPNT5zM3ILz5TkzQq2Uv4vnJczCDfQNadNuyFFsBY57x9nMLzZPlrZKLf/H6tyg fv+8nGndJ99F4yk1fAZFQLuGFiRi6FKKGMhJoEMc= 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 327AD3858C2F for ; Mon, 19 Sep 2022 19:59:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 327AD3858C2F Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11eab59db71so959621fac.11 for ; Mon, 19 Sep 2022 12:59:30 -0700 (PDT) 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=sH7XP65dr4Y5FSbOljjOPzXkAP0NsQyXcAoyHJedZ9k=; b=GzvyZPa8DdqxiJli2IGVcZ4dMugDbXK9m8SsdQYLWuUVfYKC3WoJLo3dsG4D0cYRyz uqi4ZzOvp18L+kSWGwr6GgRm+CwVLNp/ZrFVKLgB1ii8L0+eoOFNrvFJ5D+YZtEMIGSh yFkV0LYp+SSHMl7rJr+5QaBYmNiPl7XZexDboQqlIz3Y9PyQOELeD9uLYUx/SDdCRIAo zcOvAEM+rF2iCfejWlfbtb/SsUcnG6iYWPejcDUGCqRgPZF9JbXIi5WP8WvnEMjo7fC5 1P2A68ElogAx0Btc5st6+WwEN23GC9H07hfmvqOBg/ywdd6oih/zrZD7Aim1+EHeKf7x LoIA== X-Gm-Message-State: ACrzQf17Bbt8bYowx8nWOfWFPZ7CgO+ICY0Gls2FzrzQ82c63Y5r8/lv 4wEBrZCbXJfDSF+xWZX6iGUnaCz2bTZ27Kea X-Received: by 2002:a05:6870:6195:b0:12b:7db:d7ba with SMTP id a21-20020a056870619500b0012b07dbd7bamr10491677oah.82.1663617569005; Mon, 19 Sep 2022 12:59:29 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:b3ad:a56d:1ca:d6ea]) by smtp.gmail.com with ESMTPSA id l7-20020a4ab0c7000000b00475dc6c6f31sm4532291oon.45.2022.09.19.12.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:28 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 02/17] Parameterize OP_T_THRES from memcopy.h Date: Mon, 19 Sep 2022 16:59:05 -0300 Message-Id: <20220919195920.956393-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919195920.956393-1-adhemerval.zanella@linaro.org> References: <20220919195920.956393-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.4 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 Cc: Richard Henderson Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson It moves OP_T_THRES out of memcopy.h to its own header and adjust each architecture that redefines it. Checked with a build and check with run-built-tests=no for all major Linux ABIs. Co-authored-by: Adhemerval Zanella Reviewed-by: Carlos O'Donell --- string/memcmp.c | 3 --- sysdeps/generic/memcopy.h | 4 +--- sysdeps/generic/string-opthr.h | 25 ++++++++++++++++++++++ sysdeps/i386/memcopy.h | 3 --- sysdeps/i386/string-opthr.h | 25 ++++++++++++++++++++++ sysdeps/m68k/memcopy.h | 3 --- sysdeps/powerpc/powerpc32/power4/memcopy.h | 5 ----- 7 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 sysdeps/generic/string-opthr.h create mode 100644 sysdeps/i386/string-opthr.h diff --git a/string/memcmp.c b/string/memcmp.c index 6a9ceb8ac3..7c4606c2d0 100644 --- a/string/memcmp.c +++ b/string/memcmp.c @@ -48,9 +48,6 @@ and store. Must be an unsigned type. */ # define OPSIZ (sizeof (op_t)) -/* Threshold value for when to enter the unrolled loops. */ -# define OP_T_THRES 16 - /* Type to use for unaligned operations. */ typedef unsigned char byte; diff --git a/sysdeps/generic/memcopy.h b/sysdeps/generic/memcopy.h index efe5f2475d..a6baa4dfbb 100644 --- a/sysdeps/generic/memcopy.h +++ b/sysdeps/generic/memcopy.h @@ -57,6 +57,7 @@ /* Type to use for aligned memory operations. */ #include +#include #define OPSIZ (sizeof (op_t)) /* Type to use for unaligned operations. */ @@ -188,9 +189,6 @@ extern void _wordcopy_bwd_dest_aligned (long int, long int, size_t) #endif -/* Threshold value for when to enter the unrolled loops. */ -#define OP_T_THRES 16 - /* Set to 1 if memcpy is safe to use for forward-copying memmove with overlapping addresses. This is 0 by default because memcpy implementations are generally not safe for overlapping addresses. */ diff --git a/sysdeps/generic/string-opthr.h b/sysdeps/generic/string-opthr.h new file mode 100644 index 0000000000..eabd9fd669 --- /dev/null +++ b/sysdeps/generic/string-opthr.h @@ -0,0 +1,25 @@ +/* Define a threshold for word access. Generic 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_OPTHR_H +#define _STRING_OPTHR_H 1 + +/* Threshold value for when to enter the unrolled loops. */ +#define OP_T_THRES 16 + +#endif /* string-opthr.h */ diff --git a/sysdeps/i386/memcopy.h b/sysdeps/i386/memcopy.h index 8cbf182096..66f5665f82 100644 --- a/sysdeps/i386/memcopy.h +++ b/sysdeps/i386/memcopy.h @@ -18,9 +18,6 @@ #include -#undef OP_T_THRES -#define OP_T_THRES 8 - #undef BYTE_COPY_FWD #define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \ do { \ diff --git a/sysdeps/i386/string-opthr.h b/sysdeps/i386/string-opthr.h new file mode 100644 index 0000000000..ed3e4b2ddb --- /dev/null +++ b/sysdeps/i386/string-opthr.h @@ -0,0 +1,25 @@ +/* Define a threshold for word access. i386 version. + Copyright (C) 2018 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 I386_STRING_OPTHR_H +#define I386_STRING_OPTHR_H 1 + +/* Threshold value for when to enter the unrolled loops. */ +#define OP_T_THRES 8 + +#endif /* I386_STRING_OPTHR_H */ diff --git a/sysdeps/m68k/memcopy.h b/sysdeps/m68k/memcopy.h index cf147f2c4a..3777baac21 100644 --- a/sysdeps/m68k/memcopy.h +++ b/sysdeps/m68k/memcopy.h @@ -20,9 +20,6 @@ #if defined(__mc68020__) || defined(mc68020) -#undef OP_T_THRES -#define OP_T_THRES 16 - /* WORD_COPY_FWD and WORD_COPY_BWD are not symmetric on the 68020, because of its weird instruction overlap characteristics. */ diff --git a/sysdeps/powerpc/powerpc32/power4/memcopy.h b/sysdeps/powerpc/powerpc32/power4/memcopy.h index a98f6662d8..d27caa2277 100644 --- a/sysdeps/powerpc/powerpc32/power4/memcopy.h +++ b/sysdeps/powerpc/powerpc32/power4/memcopy.h @@ -50,11 +50,6 @@ [I fail to understand. I feel stupid. --roland] */ - -/* Threshold value for when to enter the unrolled loops. */ -#undef OP_T_THRES -#define OP_T_THRES 16 - /* Copy exactly NBYTES bytes from SRC_BP to DST_BP, without any assumptions about alignment of the pointers. */ #undef BYTE_COPY_FWD From patchwork Mon Sep 19 19:59:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 607328 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp1668784lth; Mon, 19 Sep 2022 13:03:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5sTCA+dARjrrAuqRysJ4kqNfVHuUDbSyCUYBfwxnTswAiVoQiCKBr00YN4phPhaJ/vidn5 X-Received: by 2002:a17:907:a06:b0:77b:6eca:c089 with SMTP id bb6-20020a1709070a0600b0077b6ecac089mr13554442ejc.362.1663617804367; Mon, 19 Sep 2022 13:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663617804; cv=none; d=google.com; s=arc-20160816; b=kAa3E8bboSIqHCnVdb7+WDMePZpcZNI5QpD5Tn6Xi8MDwIGtKZcQnUs0Th2PZyxYJQ eDYNoahHHNpxVHRVjWcCFt68Lb9j8VFmG8Ud/3td49TZk6MoXCz+TXwCWdbACK4484jZ lgPccFxfPRFDcaCA2HsBklNmybgMK6WRs+UJl+iqJvk9ZcVUZZLvBpcehz8JKCcsonG3 R6q0TIj+kEbGRaERTvhGz8R44/xUTev/eD/wdJesmDL4KP3HZ35Yu40ahQalNamkWjM6 DVuTrO2eUMkWvZ8msPwxmgRyimbKFanN4bGk6sKih6PV57ImZLA8N7pQKmlOFsTYvpZK nsuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=yaswVVzodwomNg7OJoqsjfX9xQUObSy00raw0PfY2Ys=; b=nKvNt5mZxk/ls5lxgfhgKS3xMhTAa6xYJBVx/k9MNc+Srd59pS46JS8Tsb+17zRFXE 2i8Ssqpsi2S4BMCaQ60630l43mvaR62szk8gM5ze5wvbKFKlMhQBNBwWSqlfRAg/uP2b H7nzotRpqIUhHbELvMNDjze/vZuDmn7L9lzqvUZtZmD0ItaYub4V5WndEX7oJYxw33sw bXELH81YtDS2qMHqQp2nRCtIK7dFeVdAqnbaw1VShbqtWYK2UHE2pTxuVaFxCNUmzYcM LGD+bwi/qF8ufN7eV78PkEkAfSHS5tdQxzdAccj3wn/YD5irafPf6XMJSN+EyIlfX83X WKxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lK4aLiuq; 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 hd19-20020a170907969300b0077d8a49f36dsi23902272ejc.691.2022.09.19.13.03.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 13:03:24 -0700 (PDT) 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=lK4aLiuq; 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 5A3A5384D1A7 for ; Mon, 19 Sep 2022 20:03:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A3A5384D1A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663617803; bh=yaswVVzodwomNg7OJoqsjfX9xQUObSy00raw0PfY2Ys=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=lK4aLiuqc1Q/2emkiVdTHM4rkxrGISpdEM1KlBrMVNrUig0qroCJ2D5SkekA5lAW5 6Mk1YXZWGeegxP5txzffoTIPYI7EWtCgZ3tWniN8d1KfzrVuTTk3ERYtZJJLxNELlx T51hdC9EnWGrK7ZeBoigKs73gwHPNZq/0AxYHutY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 3455A3858282 for ; Mon, 19 Sep 2022 19:59:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3455A3858282 Received: by mail-oi1-x22b.google.com with SMTP id v130so909796oie.2 for ; Mon, 19 Sep 2022 12:59:44 -0700 (PDT) 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=yaswVVzodwomNg7OJoqsjfX9xQUObSy00raw0PfY2Ys=; b=ZW7+mynIxYtKN3OWPIPQu+mzZT9W0a1ejYhn/4fsNCFepplasFHF5bj2/4LDS/oJUR BvpF0U8s2yT/tF0/BISdLZLs+z2MQvw8dObLHnJUmxJSH8fnaNQtyDna7nrg8HX5ykix CF82lY8zoySbshzwbl23x3e5k3SR8pbVkliDKAIrx7ByYT6Y5fG/Q/g/QOzOhaUUEppu enKCm7+vJpR8Kv27kO4n65Qp8rxUItiOrFJGiqFUuJmbxzgqHWzlr+dYbEs71FiWP4cN sxBMGH3FUQnmWN0ZIwvOV9AlEuDqQqc3sEIEjXEEJdT8G3r3NE8WdjJV/EXed/u5kEbA Y0Mg== X-Gm-Message-State: ACrzQf0YhKXd2wbT3ZW9GzHhOtgsSoEykj1BPw7DssMqqKwuYKWGREwR iMxY8bVzpIli6+YvY9iJSodXYLWjFPGOWgpn X-Received: by 2002:a54:4482:0:b0:34f:b980:e74a with SMTP id v2-20020a544482000000b0034fb980e74amr8842453oiv.32.1663617582466; Mon, 19 Sep 2022 12:59:42 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:b3ad:a56d:1ca:d6ea]) by smtp.gmail.com with ESMTPSA id l7-20020a4ab0c7000000b00475dc6c6f31sm4532291oon.45.2022.09.19.12.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:42 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 12/17] hppa: Add memcopy.h Date: Mon, 19 Sep 2022 16:59:15 -0300 Message-Id: <20220919195920.956393-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919195920.956393-1-adhemerval.zanella@linaro.org> References: <20220919195920.956393-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 Cc: Richard Henderson Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson GCC's combine pass cannot merge (x >> c | y << (32 - c)) into a double-word shift unless (1) the subtract is in the same basic block and (2) the result of the subtract is used exactly once. Neither condition is true for any use of MERGE. By forcing the use of a double-word shift, we not only reduce contention on SAR, but also allow the setting of SAR to be hoisted outside of a loop. Checked on hppa-linux-gnu. --- sysdeps/hppa/memcopy.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 sysdeps/hppa/memcopy.h diff --git a/sysdeps/hppa/memcopy.h b/sysdeps/hppa/memcopy.h new file mode 100644 index 0000000000..288b5e9520 --- /dev/null +++ b/sysdeps/hppa/memcopy.h @@ -0,0 +1,42 @@ +/* Definitions for memory copy functions, PA-RISC 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 + . */ + +#include + +/* Use a single double-word shift instead of two shifts and an ior. + If the uses of MERGE were close to the computation of shl/shr, + the compiler might have been able to create this itself. + But instead that computation is well separated. + + Using an inline function instead of a macro is the easiest way + to ensure that the types are correct. */ + +#undef MERGE + +static inline op_t +MERGE (op_t w0, int shl, op_t w1, int shr) +{ + _Static_assert (OPSIZ == 4 || OPSIZ == 8, "Invalid OPSIZE"); + + op_t res; + if (OPSIZ == 4) + asm ("shrpw %1,%2,%%sar,%0" : "=r"(res) : "r"(w0), "r"(w1), "q"(shr)); + else if (OPSIZ == 8) + asm ("shrpd %1,%2,%%sar,%0" : "=r"(res) : "r"(w0), "r"(w1), "q"(shr)); + return res; +} From patchwork Mon Sep 19 19:59:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 607326 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp1667837lth; Mon, 19 Sep 2022 13:02:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7aLXbUH6VTv5DXrQ9ZDJ9hrT6xA1s4KmvFwSNkscik2yBU8QI036cRNYLQvHKsBrGKq3Ei X-Received: by 2002:a17:907:6d03:b0:780:6fdd:974e with SMTP id sa3-20020a1709076d0300b007806fdd974emr14118986ejc.288.1663617722719; Mon, 19 Sep 2022 13:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663617722; cv=none; d=google.com; s=arc-20160816; b=iZQ86Bm75x7IxMqgASNV/Qbtjotdu5HQTUFW26J8tU8knbThC3YeI+oQ3Rci9Xdqsn abjSlBqoIWCoJAAG0gO3nm3KfFFmPTLEuSol0YH3/Mip203AU5isuL8GBf0T7WNq0okt Zjg7bqk/wNuggjC6YV8Ya0a8KL6qgpdNTpSqazIV4dk9lfiPI7D/vpHXaY5Dz+YRllfQ 16CakLOJzV3WzUSzRF4CrkmbAYKUt3YasNOEpe/B6xkuZl/wYQpXj9cPyLjs7A/waIBt cagdT8tx0vyqURM56PC7Xr8C/ccpfWfIqmCAZalGn1ARbgG1SMPmQJsDE4zrOpLNbx1N 2eUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=sDu6dXCh51vSXKzuam85YiH4DXB+TeTXnosOsjvQ8vg=; b=L+UIOhJROf1ldUAFOxdYWN6WXnzrQJgtmU8f99VVP2huQOmZm0QQg4G4cXoZOJeKKD bqOC9zT1l/DDmr7Mnz6bPMJfYB1iZqXytkVFGM9vwWJMSJBqi+9yhPuRSspxU+zcMQk1 JYoTqkNJb6UhBXMDZxUy6URFuI3X/9IU8aFrwCllrFFuxaRJvXNI7IYJX6p3bCDvJ7IY WiCouzKQqZAJ1cU28q1IhpF9a4BC0/NkkCBQrfkDCaPOWyfXGxLKA8vI5EQhwquC2Z/+ Nl9kfFbmoqjVK0tZWvmxO+qTh1I+Z7hkAd1a+7nnYtT/72Nj15wVPXP+6TC+TGl+rI3l 8dZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ozZFM8ku; 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 xg12-20020a170907320c00b0072ab4b5ffe5si24578717ejb.987.2022.09.19.13.02.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 13:02:02 -0700 (PDT) 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=ozZFM8ku; 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 943A83857BA4 for ; Mon, 19 Sep 2022 20:02:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 943A83857BA4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663617721; bh=sDu6dXCh51vSXKzuam85YiH4DXB+TeTXnosOsjvQ8vg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ozZFM8kueVC1r+dCzAy7xxCSYFJLh5kojDvc14P0YOnie8y4GwPrYRqfvKfJxVBwU h+W4Bc+ENIuIvgUm85fI0k6+0qeOEB0H1SlsSNvWxzyjq2fjx7+HmG3wp5nmqShteL iATrql0WSRkJpP3T2EyfQa5hBDtrjvcQ3J1lykLg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id E915738582BA for ; Mon, 19 Sep 2022 19:59:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E915738582BA Received: by mail-oi1-x22a.google.com with SMTP id t62so853032oie.10 for ; Mon, 19 Sep 2022 12:59:46 -0700 (PDT) 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=sDu6dXCh51vSXKzuam85YiH4DXB+TeTXnosOsjvQ8vg=; b=uN6tY1lQZq7sQKWIoAMe38m7gtUAbnPuq9AQLd+c+tSz0wkafceLAiBB6ch37DDFtE eKtvVsBfDNbse2UN83Z/RNiAJYIVLGwRYb39nJ7xoljjrm0vsAH/L+AzO8jI1ABJA92F GaGUWU7HuWOOYXxv0uh7wznRSOMZZckfuGTQJgP1pJNSkCb7V3BXpdM1/FSNiUH3Bnxl OiBQM43xxanJXoGm42LUAPWO34kH3IDwGTedeiBPVqwFxwfB9UibkbnLnRoB223wc7a1 UQOFWZCtJAIOK0hRSRVobU6+4UP0ZGbEQmf9pkz1Lc8IVKDAHDqqODbVDWyJMbyILXzb as6Q== X-Gm-Message-State: ACgBeo0m5lhILSHvToE5QOYgGW/umuR72NN91VFckX5h+VDOFcrXdRZd Nm/n3Wa9Dr8i4YvwJYdh2csWJJ1klj8CYNs0 X-Received: by 2002:aca:2808:0:b0:2f7:34db:691e with SMTP id 8-20020aca2808000000b002f734db691emr12732641oix.252.1663617586239; Mon, 19 Sep 2022 12:59:46 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:b3ad:a56d:1ca:d6ea]) by smtp.gmail.com with ESMTPSA id l7-20020a4ab0c7000000b00475dc6c6f31sm4532291oon.45.2022.09.19.12.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:44 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 13/17] hppa: Add string-fzb.h and string-fzi.h Date: Mon, 19 Sep 2022 16:59:16 -0300 Message-Id: <20220919195920.956393-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919195920.956393-1-adhemerval.zanella@linaro.org> References: <20220919195920.956393-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 Cc: Richard Henderson Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson Use UXOR,SBZ to test for a zero byte within a word. While we can get semi-decent code out of asm-goto, we would do slightly better with a compiler builtin. For index_zero et al, sequential testing of bytes is less expensive than any tricks that involve a count-leading-zeros insn that we don't have. Checked on hppa-linux-gnu. --- sysdeps/hppa/string-fzb.h | 69 +++++++++++++++++++ sysdeps/hppa/string-fzi.h | 135 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 sysdeps/hppa/string-fzb.h create mode 100644 sysdeps/hppa/string-fzi.h diff --git a/sysdeps/hppa/string-fzb.h b/sysdeps/hppa/string-fzb.h new file mode 100644 index 0000000000..dc02757522 --- /dev/null +++ b/sysdeps/hppa/string-fzb.h @@ -0,0 +1,69 @@ +/* Zero byte detection, boolean. HPPA 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_FZB_H +#define _STRING_FZB_H 1 + +#include + +/* Determine if any byte within X is zero. This is a pure boolean test. */ + +static inline _Bool +has_zero (op_t x) +{ + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* It's more useful to expose a control transfer to the compiler + than to expose a proper boolean result. */ + asm goto ("uxor,sbz %%r0,%0,%%r0\n\t" + "b,n %l1" : : "r"(x) : : nbz); + return 1; + nbz: + return 0; +} + +/* Likewise, but for byte equality between X1 and X2. */ + +static inline _Bool +has_eq (op_t x1, op_t x2) +{ + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + asm goto ("uxor,sbz %0,%1,%%r0\n\t" + "b,n %l2" : : "r"(x1), "r"(x2) : : nbz); + return 1; + nbz: + return 0; +} + +/* Likewise, but for zeros in X1 and equal bytes between X1 and X2. */ + +static inline _Bool +has_zero_eq (op_t x1, op_t x2) +{ + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + asm goto ("uxor,sbz %%r0,%0,%%r0\n\t" + "uxor,nbz %0,%1,%%r0\n\t" + "b,n %l2" : : "r"(x1), "r"(x2) : : sbz); + return 0; + sbz: + return 1; +} + +#endif /* _STRING_FZB_H */ diff --git a/sysdeps/hppa/string-fzi.h b/sysdeps/hppa/string-fzi.h new file mode 100644 index 0000000000..2b8747ddbd --- /dev/null +++ b/sysdeps/hppa/string-fzi.h @@ -0,0 +1,135 @@ +/* string-fzi.h -- zero byte detection; indexes. HPPA 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_FZI_H +#define _STRING_FZI_H 1 + +#include + +/* Given a word X that is known to contain a zero byte, return the + index of the first such within the long in memory order. */ + +static inline unsigned int +index_first_zero (op_t x) +{ + unsigned int ret; + + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* Since we have no clz insn, direct tests of the bytes is faster + than loading up the constants to do the masking. */ + asm ("extrw,u,<> %1,23,8,%%r0\n\t" + "ldi 2,%0\n\t" + "extrw,u,<> %1,15,8,%%r0\n\t" + "ldi 1,%0\n\t" + "extrw,u,<> %1,7,8,%%r0\n\t" + "ldi 0,%0" + : "=r"(ret) : "r"(x), "0"(3)); + + return ret; +} + +/* Similarly, but perform the search for byte equality between X1 and X2. */ + +static inline unsigned int +index_first_eq (op_t x1, op_t x2) +{ + return index_first_zero (x1 ^ x2); +} + +/* Similarly, but perform the search for zero within X1 or + equality between X1 and X2. */ + +static inline unsigned int +index_first_zero_eq (op_t x1, op_t x2) +{ + unsigned int ret; + + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* Since we have no clz insn, direct tests of the bytes is faster + than loading up the constants to do the masking. */ + asm ("extrw,u,= %1,23,8,%%r0\n\t" + "extrw,u,<> %2,23,8,%%r0\n\t" + "ldi 2,%0\n\t" + "extrw,u,= %1,15,8,%%r0\n\t" + "extrw,u,<> %2,15,8,%%r0\n\t" + "ldi 1,%0\n\t" + "extrw,u,= %1,7,8,%%r0\n\t" + "extrw,u,<> %2,7,8,%%r0\n\t" + "ldi 0,%0" + : "=r"(ret) : "r"(x1), "r"(x1 ^ x2), "0"(3)); + + return ret; +} + +/* Similarly, but perform the search for zero within X1 or + inequality between X1 and X2. */ + +static inline unsigned int +index_first_zero_ne (op_t x1, op_t x2) +{ + unsigned int ret; + + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* Since we have no clz insn, direct tests of the bytes is faster + than loading up the constants to do the masking. */ + asm ("extrw,u,<> %2,23,8,%%r0\n\t" + "extrw,u,<> %1,23,8,%%r0\n\t" + "ldi 2,%0\n\t" + "extrw,u,<> %2,15,8,%%r0\n\t" + "extrw,u,<> %1,15,8,%%r0\n\t" + "ldi 1,%0\n\t" + "extrw,u,<> %2,7,8,%%r0\n\t" + "extrw,u,<> %1,7,8,%%r0\n\t" + "ldi 0,%0" + : "=r"(ret) : "r"(x1), "r"(x1 ^ x2), "0"(3)); + + return ret; +} + +/* Similarly, but search for the last zero within X. */ + +static inline unsigned int +index_last_zero (op_t x) +{ + unsigned int ret; + + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* Since we have no ctz insn, direct tests of the bytes is faster + than loading up the constants to do the masking. */ + asm ("extrw,u,<> %1,15,8,%%r0\n\t" + "ldi 1,%0\n\t" + "extrw,u,<> %1,23,8,%%r0\n\t" + "ldi 2,%0\n\t" + "extrw,u,<> %1,31,8,%%r0\n\t" + "ldi 3,%0" + : "=r"(ret) : "r"(x), "0"(0)); + + return ret; +} + +static inline unsigned int +index_last_eq (op_t x1, op_t x2) +{ + return index_last_zero (x1 ^ x2); +} + +#endif /* _STRING_FZI_H */ From patchwork Mon Sep 19 19:59:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 607327 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp1668411lth; Mon, 19 Sep 2022 13:02:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TwfyjQhhGzjquL+RaUdl+iBfmGXL/TR6ueVZlBZcPJgnA+ZNGzV8XlmFqEOuiLxFrIl6M X-Received: by 2002:a05:6402:4019:b0:44e:e530:30f4 with SMTP id d25-20020a056402401900b0044ee53030f4mr17344896eda.183.1663617765139; Mon, 19 Sep 2022 13:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663617765; cv=none; d=google.com; s=arc-20160816; b=dGb0YscpxI0PpyWYlrB3jcPNJ6fUr1O0zGG2dr3lZInsuRbBWPOO+pr7OitmK3q0rZ n3JAx2XFQYJ+Rciym+fKx31uMW1l7isPFF8U9OxNVH/PHGWoQ8j1M+wCSjtsVzNCp/cg qQ+YA+6roJTi14bpkMIhPXp5CzxVtzOPn/Bt5rjeFt4qZLTYZLuFFdqaS8d+7hBs/eq3 mYhnq7iEqPfGOognDJO6Yp1gBEB+uyRqKfPwHANcvyLvPpcg3cdtMYYmWgowK3EjOdUR LMDgV3x4X/2QmMNBwJ9qh2O1+RGPrM9iE3jNJBzRS3A2fTHjpnKZElRNgegTY9bE2/OL y8fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=VPl5idg7nmu4rl+u9SzggIv0yZg5ORisPUXbpJXo8Kk=; b=axv8VyAbbP7u238Y6onyBq4L7IM2iRhJ/VBPu5vS91vY9Ptti2bgfJDVLCE0TeBUyn vcH1fFySLYU5w8DjUJwRde/sC/1EQn39g3usdU8s/2V2/ba/MAwwMYsMIcBuriFI/wgH brmrjcwOVBBw7HZo8bFPh0dIcgBtUrkKZY4tNW0hHfA0v8rLYsFHh0+mIHlsCDFs9CC2 I0vaeAiqyjptUF8pIKmkyhxNLgjrZsHEBCY6Z/N94ixQD6euK9UH5SbTTRV2+qRdjSPl UBL0lVbnokTA1OcBYti4vT0wkTSK5yl0er6Kq9C/8w6Ftofit3aBNvcWDKs3EgcK9NXF 7wow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="DhU/Y3qE"; 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 v21-20020aa7cd55000000b004512f3e3e03si8411678edw.146.2022.09.19.13.02.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 13:02:45 -0700 (PDT) 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="DhU/Y3qE"; 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 E4823385040C for ; Mon, 19 Sep 2022 20:02:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E4823385040C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663617763; bh=VPl5idg7nmu4rl+u9SzggIv0yZg5ORisPUXbpJXo8Kk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=DhU/Y3qE4tlz8+eqZ4ZgZnJuoaH1tKlM5C5g3uAGMhoNpYjba9ahzX906GyFwU7gr H52O6mE26gjm2P0b6rfdNhN46cCkAbvi3dd8NveP2EJBVc+sDXq7Wkv+cDxbxZUBIC 2s816h6fdUMtQUM+6+z3lXqtxH06JX3Tcs4sfymc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 4CA6D3857BB5 for ; Mon, 19 Sep 2022 19:59:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4CA6D3857BB5 Received: by mail-oi1-x22b.google.com with SMTP id v130so910050oie.2 for ; Mon, 19 Sep 2022 12:59:48 -0700 (PDT) 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=VPl5idg7nmu4rl+u9SzggIv0yZg5ORisPUXbpJXo8Kk=; b=nWHQh7EoYVXwoPngHpEQpMHTSYMhUot0my+BK5j6J84upbDGZMnDwLXm2UR81au5fD 8pXSMxU50o7salkE2CAIKc0USNwrlO5gS7kpnPAwurBnnRAQ1JcDEUyvV7yR0CPBYKSL P/sQQL3yJYAlW0ls7E1JaV5tVGKEQ3FxHvL5JSnbhsFMf86gGzJf0ztdHzWV2d+AsAUd a2t/+o3O8qOWHqv4QzIuEdO+b1LHkT+RhqS6jdJkRuhUv51EPGfs/SsnV1vKsToI8ApX LfPDOFYBcd95QpN2QaPbq1gHH+S2/206QDaDU6jdYN2RP5JxYMQMYokRVAPgTzlmz1oC Z49g== X-Gm-Message-State: ACrzQf2oSpdRFzt5VPu1pG5aprzP74n8hrhATchzC0NMDrqxFEAUs7Xn jd43tA719lkpebihc6jWmrjJNRSRpLs6PxXt X-Received: by 2002:a05:6808:144b:b0:350:a06a:f8b7 with SMTP id x11-20020a056808144b00b00350a06af8b7mr3516441oiv.272.1663617587637; Mon, 19 Sep 2022 12:59:47 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:b3ad:a56d:1ca:d6ea]) by smtp.gmail.com with ESMTPSA id l7-20020a4ab0c7000000b00475dc6c6f31sm4532291oon.45.2022.09.19.12.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:47 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 14/17] alpha: Add string-fzb.h and string-fzi.h Date: Mon, 19 Sep 2022 16:59:17 -0300 Message-Id: <20220919195920.956393-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919195920.956393-1-adhemerval.zanella@linaro.org> References: <20220919195920.956393-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 Cc: Richard Henderson Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While alpha has the more important string functions in assembly, there are still a few for find the generic routines are used. Use the CMPBGE insn, via the builtin, for testing of zeros. Use a simplified expansion of __builtin_ctz when the insn isn't available. Checked on alpha-linux-gnu. --- sysdeps/alpha/string-fzb.h | 51 +++++++++++++++++ sysdeps/alpha/string-fzi.h | 113 +++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 sysdeps/alpha/string-fzb.h create mode 100644 sysdeps/alpha/string-fzi.h diff --git a/sysdeps/alpha/string-fzb.h b/sysdeps/alpha/string-fzb.h new file mode 100644 index 0000000000..6b19a2106c --- /dev/null +++ b/sysdeps/alpha/string-fzb.h @@ -0,0 +1,51 @@ +/* Zero byte detection; boolean. Alpha 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_FZB_H +#define _STRING_FZB_H 1 + +#include + +/* Note that since CMPBGE creates a bit mask rather than a byte mask, + we cannot simply provide a target-specific string-fza.h. */ + +/* Determine if any byte within X is zero. This is a pure boolean test. */ + +static inline _Bool +has_zero (op_t x) +{ + return __builtin_alpha_cmpbge (0, x) != 0; +} + +/* Likewise, but for byte equality between X1 and X2. */ + +static inline _Bool +has_eq (op_t x1, op_t x2) +{ + return has_zero (x1 ^ x2); +} + +/* Likewise, but for zeros in X1 and equal bytes between X1 and X2. */ + +static inline _Bool +has_zero_eq (op_t x1, op_t x2) +{ + return has_zero (x1) | has_eq (x1, x2); +} + +#endif /* _STRING_FZB_H */ diff --git a/sysdeps/alpha/string-fzi.h b/sysdeps/alpha/string-fzi.h new file mode 100644 index 0000000000..c1a4683590 --- /dev/null +++ b/sysdeps/alpha/string-fzi.h @@ -0,0 +1,113 @@ +/* string-fzi.h -- zero byte detection; indices. Alpha 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_FZI_H +#define _STRING_FZI_H + +#include +#include + +/* Note that since CMPBGE creates a bit mask rather than a byte mask, + we cannot simply provide a target-specific string-fza.h. */ + +/* A subroutine for the index_zero functions. Given a bitmask C, + return the index of the first bit set in memory order. */ + +static inline unsigned int +index_first_ (unsigned long int c) +{ +#ifdef __alpha_cix__ + return __builtin_ctzl (c); +#else + c = c & -c; + return (c & 0xf0 ? 4 : 0) + (c & 0xcc ? 2 : 0) + (c & 0xaa ? 1 : 0); +#endif +} + +/* Similarly, but return the (memory order) index of the last bit + that is non-zero. Note that only the least 8 bits may be nonzero. */ + +static inline unsigned int +index_last_ (unsigned long int x) +{ +#ifdef __alpha_cix__ + return __builtin_clzl (x) ^ 63; +#else + unsigned r = 0; + if (x & 0xf0) + r += 4; + if (x & (0xc << r)) + r += 2; + if (x & (0x2 << r)) + r += 1; + return r; +#endif +} + +/* Given a word X that is known to contain a zero byte, return the + index of the first such within the word in memory order. */ + +static inline unsigned int +index_first_zero (op_t x) +{ + return index_first_ (__builtin_alpha_cmpbge (0, x)); +} + +/* Similarly, but perform the test for byte equality between X1 and X2. */ + +static inline unsigned int +index_first_eq (op_t x1, op_t x2) +{ + return index_first_zero (x1 ^ x2); +} + +/* Similarly, but perform the search for zero within X1 or + equality between X1 and X2. */ + +static inline unsigned int +index_first_zero_eq (op_t x1, op_t x2) +{ + return index_first_ (__builtin_alpha_cmpbge (0, x1) + | __builtin_alpha_cmpbge (0, x1 ^ x2)); +} + +/* Similarly, but perform the search for zero within X1 or + inequality between X1 and X2. */ + +static inline unsigned int +index_first_zero_ne (op_t x1, op_t x2) +{ + return index_first_ (__builtin_alpha_cmpbge (0, x1) + | (__builtin_alpha_cmpbge (0, x1 ^ x2) ^ 0xFF)); +} + +/* Similarly, but search for the last zero within X. */ + +static inline unsigned int +index_last_zero (op_t x) +{ + return index_last_ (__builtin_alpha_cmpbge (0, x)); +} + +static inline unsigned int +index_last_eq (op_t x1, op_t x2) +{ + return index_last_zero (x1 ^ x2); +} + +#endif /* _STRING_FZI_H */ From patchwork Mon Sep 19 19:59:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 607325 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp1667503lth; Mon, 19 Sep 2022 13:01:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6PZtlaLkwm/CbO3NXxGL3ZEaLMC4RiJjv//5ClvMpz6nIWvRCwJzNYFHEtqFlNYk50R2zu X-Received: by 2002:a05:6402:520c:b0:451:4213:49db with SMTP id s12-20020a056402520c00b00451421349dbmr17176746edd.130.1663617689908; Mon, 19 Sep 2022 13:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663617689; cv=none; d=google.com; s=arc-20160816; b=CAno3p7wdDwb4+UJ8T06qtHVg1taYpeb4pBSggPLaWQEFL1FtA1LpzXl4imt5Dym1L B4aXvaDTBLQ7wZ1Ckopsem1CR6YdjNECqI+Al4WMnBC3cfXq01EjiHska1ovfOtc5m56 xd0C/rOObU5EVdCXS/yOSJXy/gBM6nVjbZ5Wdi27CSd5BczuEPryK3uCZCLTGBSc8//X PX5PrQM7i+rl42Es9fojI2cV3pSezKOT+PAkPrcYVZkzkbn8M8WePFzY89rGnRNVlOU9 w5+YO+1YHejOqyxce4DfYhByLWqHL/wDMt6HUO3LjA++J6haP4zzshax0A7UczktLgit o+/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; b=lbRusI7coexcfXpyon6+JiJfvuc+nzdj7PtcsfyOPbXsnpWEA/4zW5kxM706AYFvFp sFe3fA7kS50+CTnZhJcjM95DN3Tp1UZgOFtl9HWnOv00IrwPeH9GJNhOoj7KZv8d3HKW +aERWO2L2t2Xxn2vFhqcqeFdKYm4PfPdasctX0MltoSDhxfNZJtyqhyvaF0GzRGZ/H3Q gWTnqzWk4bh249IZD2Esw0uU3r8vzuK2vfUO+2mapH3EQk8hxWwno4sPEzHb5XR635yV Q+Pqa3RdGGuLrW7Sv0AtexUzMLJW29FF2ZQwfd2lbxuU+pTt6U9eYHCaw5uO7cZ0C01I ++Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=AfKnAQg+; 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 j10-20020a05640211ca00b0045306aa1e63si12422584edw.614.2022.09.19.13.01.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 13:01:29 -0700 (PDT) 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=AfKnAQg+; 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 C7812383FBA3 for ; Mon, 19 Sep 2022 20:01:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C7812383FBA3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663617688; bh=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=AfKnAQg+AvavoRb85Rvg9Iyz0nSuhyE48l5z9GOSe8H1u2SGjNXOrcrJHIAfFCYlK SpwWfaaS6zAdrZMyQABNSA+uMASkOMsWYB/xB4QYAtHxVQKJvkseO6w3CICvbnqtEs 3Gi9vOt6t5POneCb0VbA+U8DCRtkNccG7cGfkSDY= 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 07288385842B for ; Mon, 19 Sep 2022 19:59:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 07288385842B Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-12b542cb1d3so936561fac.13 for ; Mon, 19 Sep 2022 12:59:49 -0700 (PDT) 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=PAeYF20PNZnVgQ+lVCq6w4A4LH4OtjZEpn+yK107ftAgyXJe9ghI8P3NetSk2zM3Nl ZpOXwuqpqhbx6m8sGYr44k8R3eTYrPEX+I8lMEJmvkY+E1NsScZf8O7Sg4+23CFSj4dq QYkSFYdLCNhnlojrp4aNPmXW/b+ocdKYGHwsCSMa8xjLOnHQnU2iZWvDRNIrtO/8++lZ ZM9qA6FrUJhTtXWLx78gfXougtipMv1YiIgbi3DK+q2NMPaim3G7EIaD+XoJkhAhyWHd fCcn781wpGWUzVAUP9sHY6zKjwHKaHO7FhonYE4qI8upA4nbLhP3xzHCugYX3G4lgnLO G6WA== X-Gm-Message-State: ACgBeo0IPJpWmTVTvDLesKS4637u2jxla353ONnVit7x/iiTypk6eolO ZJ1rKIqszC4yMIBdSAb7mPVZanQOudvg/d0i X-Received: by 2002:a05:6870:64a2:b0:12b:7db:b8e1 with SMTP id cz34-20020a05687064a200b0012b07dbb8e1mr16088997oab.212.1663617589194; Mon, 19 Sep 2022 12:59:49 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:b3ad:a56d:1ca:d6ea]) by smtp.gmail.com with ESMTPSA id l7-20020a4ab0c7000000b00475dc6c6f31sm4532291oon.45.2022.09.19.12.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:48 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 15/17] arm: Add string-fza.h Date: Mon, 19 Sep 2022 16:59:18 -0300 Message-Id: <20220919195920.956393-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919195920.956393-1-adhemerval.zanella@linaro.org> References: <20220919195920.956393-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 Cc: Richard Henderson 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..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 */ From patchwork Mon Sep 19 19:59:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 607324 Delivered-To: patch@linaro.org Received: by 2002:ab3:1c02:0:b0:1e7:4ce8:c350 with SMTP id u2csp1667340lth; Mon, 19 Sep 2022 13:01:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5iiEaBT+3CUsJNtxqmzKcdu1lpDnbAJ7dW/A6oB95d1Jxa5ijDzmu4xzpemmYIj+mBVJCS X-Received: by 2002:a17:907:d8b:b0:779:3642:acbc with SMTP id go11-20020a1709070d8b00b007793642acbcmr14081413ejc.429.1663617674316; Mon, 19 Sep 2022 13:01:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663617674; cv=none; d=google.com; s=arc-20160816; b=H3TqwiFhbyNJt/iqUtc5LYCVUc7XrYpAm0fvBI0pQq+tixFNe6ZqzltFTBgn8c0CZZ wUOwS+kzXJXcn1M+DUOO4AyIp7WmzfhvEWllN0Q3hlnMI2sqoudw8gwNYZzbdISXpBtX DYJ6+YKOtUa7LfOUzEy+5FYz3QHTutU7/xvyhlPTdIpYdtWZ9EMwDPheE2eMtQZge9AX bKbq57EnhAYPFIeL7NOULqKxs6xAyh8CQaYVHcl5vNH6LauJOqPhTGe3mYMOFGKSVyTJ 2qJ+xFWXcegahTW9eA6rrrrbbYQkS1dsdMXYAKePBVyJZewSsTt3OCuVzu0ZaGAYT/9H Em0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=5Q75peyS5l0VDpGdS8vy98EFqHj2so5KzVl/+o8GJjk=; b=AOAPeF25Gou5XmZVToPehuP5918oak9n9LqEGgGRgjdD6l1x6n6f2LBZ56i+zOz5FC yQGh7BkrwAJ028HHZhoxfRWv1XALrUPkzwIZMcPMv7q4G9Nf3ffqhxGa/kvJL1qNbjvU 2NgXCnnDi2SrAUdwkIQfmhHKrdo9Xhc0v8YUZcuwUKdgev/EbqXjlgS5nKnC5WQD48Fx MPNvxxzGrhmeUVd96u/WiiCRtjKz2NPcli+r9PvLjWeIdWKxrsx76sfratPbdVlhgsD1 tP9qBnJCsHKjyatcQudzA8O1ZhcU/LOrydD3txHiw1aDxOkmiZwxcSOwwLHQVtec2Cwx CvJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=SqPxqJMy; 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 cw9-20020a170906c78900b0073d9b010076si17784280ejb.822.2022.09.19.13.01.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 13:01:14 -0700 (PDT) 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=SqPxqJMy; 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 147EB3850200 for ; Mon, 19 Sep 2022 20:01:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 147EB3850200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1663617673; bh=5Q75peyS5l0VDpGdS8vy98EFqHj2so5KzVl/+o8GJjk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=SqPxqJMyMWPXoNeSIH2IxZ7dfFVJlBDXpZoQv6HKekId3CuwCGaiawN3RmNTrKuVt C0Hkgx/CwzZJA7M64G2bwjZuACIheepMekgBYbdKZB76pWR0VPrGGFBeYgGiOoz5J8 llgw5MyYZvPZm3QkzM0GHOEXUuTGBbzUmi1R7KAE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by sourceware.org (Postfix) with ESMTPS id 02FAF3858415 for ; Mon, 19 Sep 2022 19:59:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 02FAF3858415 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-11e9a7135easo999489fac.6 for ; Mon, 19 Sep 2022 12:59:50 -0700 (PDT) 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=5Q75peyS5l0VDpGdS8vy98EFqHj2so5KzVl/+o8GJjk=; b=Hf1sGhWMDE+U6ryQDvvHE+gA7yKuY2Bxvryp3SEURjV5MO5DcDPIdEEGpQlR5aFYOi Bh8ut0xiiXm1lxDMngmwXES9LR6A0SZXqUvYWm5MeS228Etri3WLWBWflZYiUtEDafVz 93zGld1trjr4/wBzKgvU0BOSuKMBAGNCBFG2sxH/hzSCnbko4ooQCW3I2IbbOzY3GPj4 SuQMwTkO1hnMHsCFcP0Vfmg6MZwZlgt0Vn5o9pKN0SI1+ZXXvvH3qJGNdfDRltyWq5KA Shsy3A7KjnlYZVUplwtPa/LYEdTJuBfDZMOjsHX+ywEJbkn9VyQkeMF11Vb4AvwBnOmK SKQw== X-Gm-Message-State: ACrzQf36kqt7xLlYSZcqOlYKU+omChHhyqlea0MN9eWv5xEdG8En2Tvj GQPqKn4PBoTJq85I33HEfav9QI/jLYq0b2kh X-Received: by 2002:a05:6870:701f:b0:127:8afc:e62c with SMTP id u31-20020a056870701f00b001278afce62cmr10475935oae.234.1663617590420; Mon, 19 Sep 2022 12:59:50 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c1:c266:b3ad:a56d:1ca:d6ea]) by smtp.gmail.com with ESMTPSA id l7-20020a4ab0c7000000b00475dc6c6f31sm4532291oon.45.2022.09.19.12.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 12:59:50 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v5 16/17] powerpc: Add string-fza.h Date: Mon, 19 Sep 2022 16:59:19 -0300 Message-Id: <20220919195920.956393-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220919195920.956393-1-adhemerval.zanella@linaro.org> References: <20220919195920.956393-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 Cc: Richard Henderson Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While ppc has the more important string functions in assembly, there are still a few generic routines used. Use the Power 6 CMPB insn for testing of zeros. Checked on powerpc64le-linux-gnu. --- sysdeps/powerpc/string-fza.h | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sysdeps/powerpc/string-fza.h diff --git a/sysdeps/powerpc/string-fza.h b/sysdeps/powerpc/string-fza.h new file mode 100644 index 0000000000..21fc697a9c --- /dev/null +++ b/sysdeps/powerpc/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. PowerPC 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 _POWERPC_STRING_FZA_H +#define _POWERPC_STRING_FZA_H 1 + +/* PowerISA 2.05 (POWER6) provides cmpb instruction. */ +#ifdef _ARCH_PWR6 +# include + +/* This function returns 0xff for each byte that is + equal between X1 and X2. */ + +static inline op_t +find_eq_all (op_t x1, op_t x2) +{ + op_t ret; + asm ("cmpb %0,%1,%2" : "=r"(ret) : "r"(x1), "r"(x2)); + return ret; +} + +/* This function returns 0xff for each byte that is zero in X. */ + +static inline op_t +find_zero_all (op_t x) +{ + return find_eq_all (x, 0); +} + +/* 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_eq_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) +{ + return find_zero_all (x1) | ~find_eq_all (x1, x2); +} + +/* 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 +#else +# include +#endif /* _ARCH_PWR6 */ + +#endif /* _POWERPC_STRING_FZA_H */