From patchwork Wed Feb 1 17:03:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649176 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp404738pva; Wed, 1 Feb 2023 09:04:32 -0800 (PST) X-Google-Smtp-Source: AK7set89azuoTutnKtigKEsGDjkLUHISI2X2R9HJrCFMQiKx2kbU14S0OLQ8v08HmU9V//vzkVSQ X-Received: by 2002:a17:906:5011:b0:88c:ea64:4ff0 with SMTP id s17-20020a170906501100b0088cea644ff0mr3407111ejj.19.1675271072057; Wed, 01 Feb 2023 09:04:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675271072; cv=none; d=google.com; s=arc-20160816; b=Ft51gfVfBjrHj/CAAnnSbRvrhC7b7tjr8M/jQ/E3n8CWj0t5potzi6nL8hUT5qLF98 apyPUltWubAvrKUTqxiZZcr3gEgl3uASm9qw7P5Ah7s/l4Xg/znidD8pwwYyEt18SMZX DrQ0j7qhBLMQfCL0gaNokO8zB4ga0h0g23JkZLcssjYJRfh2MHJOiplKkPmuCmvq1sLT ckCSWV/uDPI6nSk2S5MLRdEzBnTkwRWHxQ0y46Lv76BB1VKQAdKOZ6nEvD/tI/5yuxiz ieZt86m8m3Xb93DeUotMC2cRJeXEggICvM4+UbhW/so9SzHxw7bcrZUgJp4vjSNpc1YW GJrg== 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:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=/LjTbCox23HHYKAX4OyMh7S0k4Sa3TD0XJRzyxBSxpo=; b=asmIS92nNQtxK5HAd8eq0Fcnvzu7vmA4JH9fhb7bSO4xIFKorLpZkvi1lfBYNO7Jy3 NMULRZylSDeT5+EqRuNC4s+uK2FqsKE7LToZRFKHPGdRL1ecFIbM+rudLMhFh+1kCGKG mJOm4CvfXy8eRIDbL3DJ+aZ4ZCFrXnybfE1Gm9mEm0Vy7NylFaEG/5+Sm2NbY3ShOKCi DlkAke7XRQBp/bmAqvSSTmtzzvXeSoniYNSx8FWsv14q9x8mT5BnMkK6kBJsU4AlL8OD WpfiwdQp2ksvlAjHvleCxMXGsorpCvaiZVE8C7ODoVbYFoTntYUMnlvxZEPamXLzoGpQ Vb2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=WAqpG45u; 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 y42-20020a50bb2d000000b0048c7e8f3dcasi22764191ede.483.2023.02.01.09.04.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:04:32 -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=WAqpG45u; 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 DD3DD38582BE for ; Wed, 1 Feb 2023 17:04:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD3DD38582BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675271070; bh=/LjTbCox23HHYKAX4OyMh7S0k4Sa3TD0XJRzyxBSxpo=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=WAqpG45upLr4ZNxp4KtMO10zzbNe22auxAnkLL2Ct2TP4cTwj1gOkhBxdExsjw0ib YxcSOyJN0cQLPbjfaQGlRCLvZJxtCjxbkSgFK73tN3FzR6YeICPF8KmCg8PGjkfy0m y0Z9evAuXsZlDTlwRFYjD/52h5IE8faVMa2LmFM4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x32b.google.com (mail-ot1-x32b.google.com [IPv6:2607:f8b0:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id 4DF4F385840D for ; Wed, 1 Feb 2023 17:04:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DF4F385840D Received: by mail-ot1-x32b.google.com with SMTP id e21-20020a9d5615000000b006884e5dce99so6595648oti.5 for ; Wed, 01 Feb 2023 09:04:20 -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:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/LjTbCox23HHYKAX4OyMh7S0k4Sa3TD0XJRzyxBSxpo=; b=uOmmwcdcc7YfNVTKTzJrzYZRW+JOPeHx5hoJI8gdAvgrE6RAR6cuTxPO++V9TT1smp yqf0uqZMt/A1e7KaS1JSnWgc/yXtF4EJFdVkLNIhNBee3S5ykDEHOyx2HBHffeD3In5h BZeRHt8WSLLDD+v/nA0xSDd1rwWM9324vh0qdrYdVD0/ORMfElGoYLCkitlmHV61Yy6+ pcsL6oJnYvBOQpV+9KAEuFdcGZswZEnQipdIJZxrADwrYYkHqIhft1bwiMejiniB7MN5 YFi6+l/C5NTspP/V4v9wblsd9S0EDq5/ZufATY6CqPviyXAJRUb1kwa96L5bRddxDOCF zCyA== X-Gm-Message-State: AO0yUKUXpvhyP3Ncj+/09ZuWs21D02Pc4X3mZuC+UdEvUGpeGFXyYxfe JJG3cdLvQmqoj4rJx+P82/k7XD3CF48PkCbTwws= X-Received: by 2002:a9d:1791:0:b0:68b:cbcd:f7c9 with SMTP id j17-20020a9d1791000000b0068bcbcdf7c9mr6782495otj.33.1675271058907; Wed, 01 Feb 2023 09:04:18 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:d2ed:98c2:d2cc:bf06]) by smtp.gmail.com with ESMTPSA id b17-20020a056830311100b006863ccbf067sm8077090ots.74.2023.02.01.09.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:04:17 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein , Jeff Law , Xi Ruoyao Cc: Carlos O'Donell Subject: [PATCH v11 02/29] Parameterize OP_T_THRES from memcopy.h Date: Wed, 1 Feb 2023 14:03:39 -0300 Message-Id: <20230201170406.303978-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201170406.303978-1-adhemerval.zanella@linaro.org> References: <20230201170406.303978-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 Reply-To: Adhemerval Zanella 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 Reviewed-by: Richard Henderson --- 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 ea0fa03e1c..047ca4f98e 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 b5ffa4d114..e9b3f227b2 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..6f10a98edd --- /dev/null +++ b/sysdeps/generic/string-opthr.h @@ -0,0 +1,25 @@ +/* Define a threshold for word access. Generic 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_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 4f82689b84..1aa7c3a850 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 accd81c1c3..610577071d 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 384f33b029..872157e485 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 Wed Feb 1 17:03:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649179 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp408136pva; Wed, 1 Feb 2023 09:09:35 -0800 (PST) X-Google-Smtp-Source: AK7set/xHf9Dbxk4lAP0j5zDzWrpwHdPJSLeuzl/yXEgvM2VRYLIo6pmoePwmCQhNXE44dRidAW4 X-Received: by 2002:a17:907:7634:b0:872:82d3:4162 with SMTP id jy20-20020a170907763400b0087282d34162mr2637104ejc.44.1675271375025; Wed, 01 Feb 2023 09:09:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675271375; cv=none; d=google.com; s=arc-20160816; b=YITUMSzGIRJrm71Xo32klaOuHJ/G1KfIoouz7UFdA4itSun7DDl8zkQGqLYAYnF25f dOqMMoKO9/j8ApADUCzTwtD/K0h4lE3dv7XwzeCmfju1n9sIKJOh+XrNaeMRz+oa/Di3 itn53ElZJ+NGLnEs3zYD5zjFVTRvOu+gZ9hNQV4VIViVZoSrYkmWPvK+68GF+qXim6zn SN/9Y47pMnKSS60KuqGedd9argo/baICvar5ytjfB+cBWxD9iJdwQQfyFkRPelpROQPy AI3UK6VdmirU4OkUCGzIe4T/3RmeViOJbXe/pFWcAPvkyAmEL23OGH6nPR2YnmlvOS9I URKw== 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=uR+tmviJAnIQt3Uy9C/8G52NzH6k6qWZDh0/RH+zyro=; b=tEzaqiY9sgMzuOOk5goCh6T6r73tNQW1V1c9HmSIs1I5gh/nwDW4oRABKc5Ue3GJT4 YRMcVHalBViwpEHmhKblllSqEMtAmWHIGhsZJpKUK9HQ/7bhYSLCoSth6sh3SgS4ixfi Xq0DNNK9dMpMmWhUYFP5Dj1SCc5S5V/ktJ32cD+ic0LJmi8C2Yy4syeAq/aesmlTcMub 2Xjo9dkzlrAynLsaX/RCb842kVKEX+/P73u2SYHgSDAwct4l5k38rkFtX8JcSjikWd9z 3lvdyevdgNfAiifRQqLoVlkbPnSTiKXAW3foGwMCulnuQe4/nhWeWTXYfR56UV8Tds4A I/0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=QBoGgi6h; 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 ew1-20020a170907950100b0088dbb061a74si2448197ejc.217.2023.02.01.09.09.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:09:35 -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=QBoGgi6h; 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 E809C3857BA4 for ; Wed, 1 Feb 2023 17:09:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E809C3857BA4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675271373; bh=uR+tmviJAnIQt3Uy9C/8G52NzH6k6qWZDh0/RH+zyro=; 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=QBoGgi6hgN+NF2ASScdguzX6WBOzUZ+u7ATn3+tGYg77K+i2NIyvyIqjk04q6r/ww zW9XSRMH/Quicb1n+jd0A3XSOnek0wgmgPrqAARrPurQ4LOxpLl9le341qJ24Go/bd NwZJmNoYL6a/flWRF8QEqhuAxc9bR5b8ZlQrAtI0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by sourceware.org (Postfix) with ESMTPS id CC37B3858404 for ; Wed, 1 Feb 2023 17:04:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC37B3858404 Received: by mail-ot1-x333.google.com with SMTP id n25-20020a9d7119000000b0068bd8c1e836so2373783otj.3 for ; Wed, 01 Feb 2023 09:04: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=uR+tmviJAnIQt3Uy9C/8G52NzH6k6qWZDh0/RH+zyro=; b=SvZmmZgMe1LUuTXUe8Dfy+g6sSBOPpiK9a34Y6U9pueKl1ZEuioQosoC7lilFoBbta kdBgTtK5Ur3zYLUPuekCCpY15IL6F24Mbv5R6VHOmIdLD/MzTaNZIz9vnoa3LsOiszI4 3rQKgS59iWfzz/e7WXhDp0EJlkalUkOoHFk296C5j+vN9kvq4GbzNlg1IeeJ4rV7u/dv WdUoUwGRtJohG/yJA+T6sLGsvCvDv/ex5n+g/F4H2PFx6nuXCww9CS7MxUn8Uj5xb0LW 9zTMjLmviTFbHP5SGOMGxM04RoxkX7sKyzhqZ7Y9S5T0OLPD25DtfUPNDQwMWfUOKF6J KGPQ== X-Gm-Message-State: AO0yUKW2l5XnH8GrFqvAuKE8TRU4TiOA8om5MldXFf1QUkbuZob7DeY0 jbIs5lOZ0zrsU/vdDWA7FiSK918McZPFwTaJfSY= X-Received: by 2002:a9d:841:0:b0:68b:cec3:7fe5 with SMTP id 59-20020a9d0841000000b0068bcec37fe5mr1995128oty.4.1675271088450; Wed, 01 Feb 2023 09:04:48 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:d2ed:98c2:d2cc:bf06]) by smtp.gmail.com with ESMTPSA id b17-20020a056830311100b006863ccbf067sm8077090ots.74.2023.02.01.09.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:04:47 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein , Jeff Law , Xi Ruoyao Subject: [PATCH v11 14/29] hppa: Add memcopy.h Date: Wed, 1 Feb 2023 14:03:51 -0300 Message-Id: <20230201170406.303978-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201170406.303978-1-adhemerval.zanella@linaro.org> References: <20230201170406.303978-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 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..0d4b4ac435 --- /dev/null +++ b/sysdeps/hppa/memcopy.h @@ -0,0 +1,42 @@ +/* Definitions for memory copy functions, PA-RISC 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 + . */ + +#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 __always_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 Wed Feb 1 17:03:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649177 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp405170pva; Wed, 1 Feb 2023 09:05:07 -0800 (PST) X-Google-Smtp-Source: AK7set+oKgHWRZf0ncu7MyeBH7HXCQvpy3/Gzag/C9jjwySapASf5TmLCqhZxZ4V4Wkp/8WiVCLv X-Received: by 2002:a17:907:bb91:b0:885:2313:c8b0 with SMTP id xo17-20020a170907bb9100b008852313c8b0mr3269329ejc.28.1675271107338; Wed, 01 Feb 2023 09:05:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675271107; cv=none; d=google.com; s=arc-20160816; b=01MvPZwYvavA8AGqpY8q0yYrBHxTEpR1/XJpzRP3pG6VMIAenSs2/kFOzYVputRmRZ Mg9PtsRk9RLfToDXKaFn7bG2jGwOQ17D+VJVAm02WVriex9QuSuGWI86sVXDT924cj4q pqIQ0keLnD04ltXgJZ/I5boFbu7j55gjVtRWfoKKNpdBMhy9SO4uX2kTg6FeDXJ/A+E4 G+JlzUsp1gXGTB6mIV4I3Qrc279u0enjpDYBGARN5VU5HPPtENeFYVAwh7dBieSPGsbg PenwJajqdyZLThXdmNuD3Mry5QyrKq8M8TrDx6r6A+LVDJSvKd2/wjL4pKhZsuIVAW3C b2+A== 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=jpleRAWHDQCuIaPJ7tBbsrZ7+X97U0E3s7oNtI78EUM=; b=u5A9Y5wmYHYWUYNtR+D82MilpyIrM19OJgBL3gxRb1ulP9diFWRdwsmzjTg0RIhPYv Au9VwjGE+IvzO5sy93p26nPwAtEyBxwf818RhFHzx1rnDFf7kCoCPOGmJ6jUlHM7G+az et6mtmDC7zF0K4ORjkIKezKFLAR+6sV1b5FkpHPPJa8JEIW7+/cDhfi/ma0ECCWXuDjL 3nL4fj95NxLu/PgmfPYSB1dEoeGBo3XQ7Sbs3KLbtmmZL/svbh40prc54wIvJRDYrwkf b8Ole3HiPbkirsK/UA1iEqhByhl8t/CtZLvTN4g5nK2Yzrl63k/RaaM7fUmKF1FYJtRD W0Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=vxDMDMou; 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 20-20020a17090600d400b00870b95fb7c4si8364678eji.998.2023.02.01.09.05.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:05:07 -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=vxDMDMou; 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 002AC385B533 for ; Wed, 1 Feb 2023 17:05:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 002AC385B533 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675271106; bh=jpleRAWHDQCuIaPJ7tBbsrZ7+X97U0E3s7oNtI78EUM=; 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=vxDMDMouxyJ5kzIhFfcaOBqwOJbFcw6u7TtlQMAYqor6qfJtYqOM3O92j+CIPqott AcHa3A6JRji5rr6moC3CLTDyqlwlWMAJVHdABYZ5iHd6VcAYRKZbxigfrIe5yhWkd/ viMa+tMY/Lj3IjjI/fXBdLjBYL0Lcq0ei2H85B2k= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 996513858436 for ; Wed, 1 Feb 2023 17:04:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 996513858436 Received: by mail-ot1-x330.google.com with SMTP id x26-20020a056830115a00b0068bbc0ee3eeso3897271otq.0 for ; Wed, 01 Feb 2023 09:04:52 -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=jpleRAWHDQCuIaPJ7tBbsrZ7+X97U0E3s7oNtI78EUM=; b=NHYd5qovkSw7wLl6l0ZY4txq2EHj3xCqZfHE5TT8B8RGaHKYtZHHvM61dw0QSTgulH W2Noad3r0OB8JcAQJBr0DRjpbTgg+Yw1piqEJ1AvWiKNGwP72W83/yIy2bvHOHEZqZ4C xw2Ez+T7YExQjxiWx8MMiwmQClCtiukuzIIJuVAD/lRBMkXTZxVFAFNABuFbwP0Z3BwA iWIh2mbGvKu3y1Gpg7ji1A8SOHk4Y8IOLOCrJYAQYAllSeyHFZjcwMYFGit5lp31Uq/8 Mn4gqOrYg3S/hStbBROHk+H1+ITE8W19U+boMjprurjH9n5vMh/ruZzQ384/Pn6OrlM3 j2Aw== X-Gm-Message-State: AO0yUKWdA623QJrJI4w1dBG+yZZ/wfXuX83JS/OKWRCuzL5zNCseG48r bBbTnh7Ln6PfphMn/IlYSRwXGvGGta1jV9bV2mM= X-Received: by 2002:a9d:3e16:0:b0:688:4892:e1d3 with SMTP id a22-20020a9d3e16000000b006884892e1d3mr1647204otd.8.1675271090968; Wed, 01 Feb 2023 09:04:50 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:d2ed:98c2:d2cc:bf06]) by smtp.gmail.com with ESMTPSA id b17-20020a056830311100b006863ccbf067sm8077090ots.74.2023.02.01.09.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:04:50 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein , Jeff Law , Xi Ruoyao Subject: [PATCH v11 15/29] hppa: Add string-fza.h, string-fzc.h, and string-fzi.h Date: Wed, 1 Feb 2023 14:03:52 -0300 Message-Id: <20230201170406.303978-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201170406.303978-1-adhemerval.zanella@linaro.org> References: <20230201170406.303978-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 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 | 63 +++++++++++++++++++ sysdeps/hppa/string-fzc.h | 124 ++++++++++++++++++++++++++++++++++++++ sysdeps/hppa/string-fzi.h | 63 +++++++++++++++++++ 3 files changed, 250 insertions(+) create mode 100644 sysdeps/hppa/string-fzb.h create mode 100644 sysdeps/hppa/string-fzc.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..d6b234a271 --- /dev/null +++ b/sysdeps/hppa/string-fzb.h @@ -0,0 +1,63 @@ +/* Zero byte detection, boolean. HPPA 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_FZB_H +#define _STRING_FZB_H 1 + +#include +#include + +_Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + +/* Determine if any byte within X is zero. This is a pure boolean test. */ +static __always_inline _Bool +has_zero (op_t x) +{ + /* 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 __always_inline _Bool +has_eq (op_t x1, op_t x2) +{ + 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 __always_inline _Bool +has_zero_eq (op_t x1, op_t x2) +{ + 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-fzc.h b/sysdeps/hppa/string-fzc.h new file mode 100644 index 0000000000..8ff3416b41 --- /dev/null +++ b/sysdeps/hppa/string-fzc.h @@ -0,0 +1,124 @@ +/* string-fzc.h -- zero byte detection with 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_FZC_H +#define _STRING_FZC_H 1 + +#include + +_Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + +/* 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 __always_inline unsigned int +index_first_zero (op_t x) +{ + unsigned int ret; + + /* 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 __always_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 __always_inline unsigned int +index_first_zero_eq (op_t x1, op_t x2) +{ + unsigned int ret; + + /* 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 __always_inline unsigned int +index_first_zero_ne (op_t x1, op_t x2) +{ + unsigned int ret; + + /* 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 __always_inline unsigned int +index_last_zero (op_t x) +{ + unsigned int ret; + + /* 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 __always_inline unsigned int +index_last_eq (op_t x1, op_t x2) +{ + return index_last_zero (x1 ^ x2); +} + +#endif /* _STRING_FZC_H */ diff --git a/sysdeps/hppa/string-fzi.h b/sysdeps/hppa/string-fzi.h new file mode 100644 index 0000000000..b560fa1a89 --- /dev/null +++ b/sysdeps/hppa/string-fzi.h @@ -0,0 +1,63 @@ +/* string-fzi.h -- zero byte 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 +#include + +_Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + +static __always_inline unsigned int +index_first (find_t c) +{ + unsigned int ret; + + /* 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"(c), "0"(3)); + + return ret; +} + +static __always_inline unsigned int +index_last (find_t c) +{ + unsigned int ret; + + /* 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"(c), "0"(0)); + + return ret; +} + +#endif /* _STRING_FZI_H */ From patchwork Wed Feb 1 17:03:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649178 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp407011pva; Wed, 1 Feb 2023 09:07:44 -0800 (PST) X-Google-Smtp-Source: AK7set/pQoTuRHr73gktrlJq5CBCu23tpN2365zuqUqLbDvpdytNTGNLLUQ8fPvVepAYwYJSFjo8 X-Received: by 2002:a17:906:b2c5:b0:88d:2a41:2a4b with SMTP id cf5-20020a170906b2c500b0088d2a412a4bmr2991230ejb.60.1675271263943; Wed, 01 Feb 2023 09:07:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675271263; cv=none; d=google.com; s=arc-20160816; b=ztZ4EC9nXgYTCqjOTJz7ynxcNSseQK1Y64NhDcvBuxAjBcbSyYTdRpgMe+EhV5a9co Lmh0Jujdg69e0WVSmzUi5nUjeSF9riKxgqD8GUqTxPbpHr2KG+LetiSGAMFjOSEq/mWK 9qfiy8gyvyBmHGeLMyzLwRXWumFIP7GfCeGJMeOXzx7+QO2GHKmwZhlda1nFMzm1KPH1 QRi4DI2DjHGBTJlr5hMDyi9GtbGAVedE20y5N4DSB7smCHsf3m832MwZpznH4g61/56j 9k6ztWi7bkNBfwwjfEgk/LUsw+JpkzNPDEhhIKoQhwyD8lD3jeWkGjn7beskhoSteUTi MDXQ== 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=jVr6SqXl9FQsWAJ2toPTqtV+Gz4VS69QgbKHY+kPfMQ=; b=gZh2p/PQDm4xu7Jf6jicRV59cgbB+VGzQkk0lEtCANgFNXT+KXiSmgM/uAqOVzwrrW mPmZwjsmOnMI1gUjB3VYgKhQ6Wfj+D/P72ctKDXt5F0Kjw/EbWMk2anTmVohYphI+C6C NQfNNZ6fV6ycYaI7mdRKr7DX6gKInD7zw2orbbRxqsl1AZo3MnVNhZKrj/pW08S2qUS3 8G7chMneSZbNwRSi9wOde0/D2pWDX5vCIAtd0bJ5zA7QFqeSeYKWZZc6HMXSCfLwBGOP oNyJNsULwOwrpzdVSnMKk6hFbFzvQttsINB8q8w4BO/gu0WkbNMth2huJSjnNpV2Cw5i b9LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=jFqFtvTf; 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 mf19-20020a1709071a5300b0088c253e5db8si5296143ejc.269.2023.02.01.09.07.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:07:43 -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=jFqFtvTf; 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 90DDD3948819 for ; Wed, 1 Feb 2023 17:07:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 90DDD3948819 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675271262; bh=jVr6SqXl9FQsWAJ2toPTqtV+Gz4VS69QgbKHY+kPfMQ=; 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=jFqFtvTfFGBJjvJvPkVVWj6pO4Q43tpUOgyJZIV+mtUsUF6ZlbHvcIkWmP4LxawF+ kxYbTlCBBkqgYUM3iMWKG5Yq2wgbzEWwKwNKVj9RG4DzYo16xqQJVgpHeVxx+tycNc 34fz53HOyo6eG/pVNP37SOn+Y8h3y8YRsi8HjUvc= 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 0EC5D385C301 for ; Wed, 1 Feb 2023 17:04:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0EC5D385C301 Received: by mail-oi1-x234.google.com with SMTP id s17so5322072ois.10 for ; Wed, 01 Feb 2023 09:04:55 -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=jVr6SqXl9FQsWAJ2toPTqtV+Gz4VS69QgbKHY+kPfMQ=; b=YCWTgTi1eOVPsI+EFVS4Neyk93Lhajx6iNY/pkD4t+vmZoOCgc/WEPfm7yDpijLTwF CyAZZkVpFGP9ON8Q+R7w7pmA8Medazyr56GmCF2SNP34HieFx/WFOQJiOD2G+4j7kStP dw0Ci04Xu+ZriOOEYrJj0S9HiriULRUHZbjEqDlJr4idoRfhv0QGug95T12lh8OszOU8 Ataw0O85Uby51K1GFohSmhdlOAz6EWkGT/fOSswNNnKh0ReOGjx6SKghvEM0YMaMK6y6 wA7Mfs4/xGwtY+fgvB0oZmotp7etH8qDUUpMLAWHnMZUv9dQeBro1IB80ClysCvs0J87 lnfA== X-Gm-Message-State: AO0yUKWBQt6obkFxVBAkGfl8HMKqWswO6NRUkt+9BUIuaV8G7/Wm6jkj mLf/GnfffqC8KOTMsOv6ISu97XZyJJ5LQ6XBEBI= X-Received: by 2002:a05:6808:bc5:b0:378:528:d83b with SMTP id o5-20020a0568080bc500b003780528d83bmr1478571oik.55.1675271093473; Wed, 01 Feb 2023 09:04:53 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:d2ed:98c2:d2cc:bf06]) by smtp.gmail.com with ESMTPSA id b17-20020a056830311100b006863ccbf067sm8077090ots.74.2023.02.01.09.04.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:04:52 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein , Jeff Law , Xi Ruoyao Subject: [PATCH v11 16/29] alpha: Add string-fza, string-fzb.h, string-fzi.h, and string-shift.h Date: Wed, 1 Feb 2023 14:03:53 -0300 Message-Id: <20230201170406.303978-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201170406.303978-1-adhemerval.zanella@linaro.org> References: <20230201170406.303978-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 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. Co-authored-by: Adhemerval Zanella --- sysdeps/alpha/string-fza.h | 61 +++++++++++++++++++++++++++++++++++ sysdeps/alpha/string-fzb.h | 52 ++++++++++++++++++++++++++++++ sysdeps/alpha/string-fzi.h | 62 ++++++++++++++++++++++++++++++++++++ sysdeps/alpha/string-shift.h | 44 +++++++++++++++++++++++++ 4 files changed, 219 insertions(+) create mode 100644 sysdeps/alpha/string-fza.h create mode 100644 sysdeps/alpha/string-fzb.h create mode 100644 sysdeps/alpha/string-fzi.h create mode 100644 sysdeps/alpha/string-shift.h diff --git a/sysdeps/alpha/string-fza.h b/sysdeps/alpha/string-fza.h new file mode 100644 index 0000000000..b4a7080c44 --- /dev/null +++ b/sysdeps/alpha/string-fza.h @@ -0,0 +1,61 @@ +/* Basic zero byte detection. Generic C 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 CMPBGE instruction creates a bit mask rather than a byte mask. + However, if we narrow find_t to either 'int' or 'uint8_t', we get + unnecessary truncation instructions from the 'unsigned long' type + returned by __builtin_alpha_cmpbge. */ +typedef op_t find_t; + +static __always_inline find_t +find_zero_all (op_t x) +{ + return __builtin_alpha_cmpbge (0, x); +} + +static __always_inline find_t +find_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1 ^ 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); +} + +static __always_inline find_t +find_zero_ne_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | (find_zero_all (x1 ^ x2) ^ 0xff); +} + +/* 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 */ diff --git a/sysdeps/alpha/string-fzb.h b/sysdeps/alpha/string-fzb.h new file mode 100644 index 0000000000..e3934ba413 --- /dev/null +++ b/sysdeps/alpha/string-fzb.h @@ -0,0 +1,52 @@ +/* Zero byte detection; boolean. Alpha 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_FZB_H +#define _STRING_FZB_H 1 + +#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. */ + +/* Determine if any byte within X is zero. This is a pure boolean test. */ + +static __always_inline _Bool +has_zero (op_t x) +{ + return __builtin_alpha_cmpbge (0, x) != 0; +} + +/* Likewise, but for byte equality between X1 and X2. */ + +static __always_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 __always_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..5129b892e7 --- /dev/null +++ b/sysdeps/alpha/string-fzi.h @@ -0,0 +1,62 @@ +/* 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 +#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 __always_inline unsigned int +index_first (find_t 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 __always_inline unsigned int +index_last (find_t 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 +} + +#endif /* _STRING_FZI_H */ diff --git a/sysdeps/alpha/string-shift.h b/sysdeps/alpha/string-shift.h new file mode 100644 index 0000000000..4e2cb2fea1 --- /dev/null +++ b/sysdeps/alpha/string-shift.h @@ -0,0 +1,44 @@ +/* Shift unaligned word read. Alpha 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_SHIFT_H +#define _STRING_SHIFT_H 1 + +#include +#include +#include + +/* Return the mask WORD shifted based on S_INT address value, to ignore + values not presented in the aligned word read. */ +static __always_inline find_t +shift_find (find_t word, uintptr_t s) +{ + return word >> (s % sizeof (op_t)); +} + +/* Mask off the bits defined the the S alignment value. */ +static __always_inline find_t +shift_find_last (find_t word, uintptr_t s) +{ + s = s % sizeof (op_t); + if (s == 0) + return word; + return word & ~((op_t)-1 << s); +} + +#endif /* _STRING_SHIFT_H */ From patchwork Wed Feb 1 17:03:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649180 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp408559pva; Wed, 1 Feb 2023 09:10:16 -0800 (PST) X-Google-Smtp-Source: AK7set8TQV+MeqgkhLCQmf+cqDR5JySGpk8q6K2t1RRNXCYTOv8YurQv3MrIEliOEmZi29nlokJZ X-Received: by 2002:a17:906:8559:b0:884:fd73:8053 with SMTP id h25-20020a170906855900b00884fd738053mr3032186ejy.9.1675271416545; Wed, 01 Feb 2023 09:10:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675271416; cv=none; d=google.com; s=arc-20160816; b=X0JUcg25JXmCsivU32n3ZFgk3PG5eK11JYGUqaQ1uzIWQA7t0FCkGzrlUP0oWGtTSh 8W8I/MSOO2uqnFnzeIUS6Njgc3uVBdkMoanf7dHZ3kn1mygPzEI33L7eKEwGfwWergM8 nRvN7/D42HKl/Wp+DDIulKJab1smiYwySvPO+nU98m+S1P2bkgB/Kn8j03Tc0CflHm+O 5ZchJINRYiozx2W9gFnWWsSE5dg9J/mxdXUhJkT93AeGWIiB9wiEqyohd09YjxPvSCW4 GUOlmh3V5txu5XKw0UxgJfDO4QC8olZ5vkLGhnSA2rLogIwB000yxiWxV+uOowOExnQN w66Q== 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=eaPuAUW6u9EzarB15eu0qKq3XLrPgGatZ3LrJa3nfQo=; b=r3XM2m/fK3YSBDPiK4qV9pGfRdpdZ8F6rt5+cgjcT8d31Z08yI6/dOiL0X8q9Zq5Vh ptJ3jG6UDvMpnSxKsZltyfA8wRiOO0gCLp77FgX94/KfYtQ/ZcCliAHUMDkRbmAkmuQZ bOr/UzmkBuPCJLqgSZPb7zxnOyezBgaSWL9dc1UgBoEXkGXpHKWCWBDnFQjLCe4eGy3X Nvn03OMrJvuv8bPNkzE0tSuPYinvjfUeO8YmdQTWoZtbiMl8nkpTbg3rFgZ0JZFTcglJ 8UmWdbAbKwoQv9MbqWDc4r6uJL7dKNvlIbIGHY8DXS12biT/dpyOEPVrQrYrOKgI/EWy +rZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ojNAWqbV; 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 ft38-20020a170907802600b008893db9590fsi9776741ejc.856.2023.02.01.09.10.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:10:16 -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=ojNAWqbV; 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 39CD1388E823 for ; Wed, 1 Feb 2023 17:10:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 39CD1388E823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675271415; bh=eaPuAUW6u9EzarB15eu0qKq3XLrPgGatZ3LrJa3nfQo=; 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=ojNAWqbVsfeEOs8ronHNitzJI3P1xo0E34YPBeYcwRYmlYCXWVM0VkIVo1l3HL5jE PsFnIEs+EZHnjXuoyDv+cSb4Fj10A6tzS3bJKL1/Lx0Vvv6R5rkD2Hw1lY/4eY+dzU MZ7+VVZebBhLuvzw6dCrdxDmGEHqXbQaPg1QRoqo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by sourceware.org (Postfix) with ESMTPS id 344333857C4F for ; Wed, 1 Feb 2023 17:04:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 344333857C4F Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-16346330067so24358642fac.3 for ; Wed, 01 Feb 2023 09:04:57 -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=eaPuAUW6u9EzarB15eu0qKq3XLrPgGatZ3LrJa3nfQo=; b=VAq42Ro41ckcs5vJQdzvYInJHlecigy873OuNpcKIFImwNbEIl8+T1Jv9BglqjZXju Dc5nWAVSK9RNGmdp3VIz5HsAJPGo5MMEJZq3Y/5WAEitJq8OoiVD872tkjr2v0THMzCA vZ1thSlWGlm8bL/wan7cjwg//CzQa8BcKTab4NasFr4NZAxU1V30lUWfg/POamz6grlm pPZNewtGbS425usObUSk1PFoqjAmV6623lxBH0STkH9RBuKPaH9zctBtWUoJTKuXclXQ qejod7Px7YGoAyAz/biGiS/UKCzRbVtcaKhOMtYsczIt9dzhHrCkExWKkpwvm/nhQzMc XtPg== X-Gm-Message-State: AO0yUKWTp83fiTzsfdOn17UGJp6jZe9cEYZb8KqL/oXanEcoo9hM9E8r 2kRri7xS0DUjSeXrFVXbtSZM9OaZzHp06BqFdB8= X-Received: by 2002:a05:6870:c69a:b0:15b:9ee2:4c36 with SMTP id cv26-20020a056870c69a00b0015b9ee24c36mr1788517oab.35.1675271095988; Wed, 01 Feb 2023 09:04:55 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:d2ed:98c2:d2cc:bf06]) by smtp.gmail.com with ESMTPSA id b17-20020a056830311100b006863ccbf067sm8077090ots.74.2023.02.01.09.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:04:55 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein , Jeff Law , Xi Ruoyao Subject: [PATCH v11 17/29] arm: Add string-fza.h Date: Wed, 1 Feb 2023 14:03:54 -0300 Message-Id: <20230201170406.303978-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201170406.303978-1-adhemerval.zanella@linaro.org> References: <20230201170406.303978-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 | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sysdeps/arm/armv6t2/string-fza.h diff --git a/sysdeps/arm/armv6t2/string-fza.h b/sysdeps/arm/armv6t2/string-fza.h new file mode 100644 index 0000000000..50afaba038 --- /dev/null +++ b/sysdeps/arm/armv6t2/string-fza.h @@ -0,0 +1,68 @@ +/* Zero byte detection; basics. ARM version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_FZA_H +#define _STRING_FZA_H 1 + +#include +#include + +/* The functions return a byte mask. */ +typedef op_t find_t; + +/* This function returns at least one bit set within every byte + of X that is zero. */ +static __always_inline find_t +find_zero_all (op_t x) +{ + /* Use unsigned saturated subtraction from 1 in each byte. + That leaves 1 for every byte that was zero. */ + op_t ones = repeat_bytes (0x01); + return __builtin_arm_uqsub8 (ones, x); +} + +/* Identify bytes that are equal between X1 and X2. */ +static __always_inline find_t +find_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or equality between X1 and X2. */ +static __always_inline find_t +find_zero_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or inequality between X1 and X2. */ +static __always_inline find_t +find_zero_ne_all (op_t x1, op_t x2) +{ + /* Make use of the fact that we'll already have ONES in a register. */ + op_t ones = repeat_bytes (0x01); + return find_zero_all (x1) | (find_zero_all (x1 ^ x2) ^ ones); +} + +/* Define the "inexact" versions in terms of the exact versions. */ +#define find_zero_low find_zero_all +#define find_eq_low find_eq_all +#define find_zero_eq_low find_zero_eq_all +#define find_zero_ne_low find_zero_ne_all + +#endif /* _STRING_FZA_H */ From patchwork Wed Feb 1 17:03:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649181 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp408994pva; Wed, 1 Feb 2023 09:10:58 -0800 (PST) X-Google-Smtp-Source: AK7set/I6m+yZHdRbiA+zxqLrLhTVSsy0oA7szBlt94NsIOSivmZw4GxkoZ4BD4tsFzI4bE39e/W X-Received: by 2002:a17:907:8dcd:b0:878:45e9:6f96 with SMTP id tg13-20020a1709078dcd00b0087845e96f96mr3445417ejc.49.1675271457920; Wed, 01 Feb 2023 09:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675271457; cv=none; d=google.com; s=arc-20160816; b=eYaii5DajKCfOh2nO2jy6EVBHcNkH6K/HSfr8FEPIviOzZlu2N+YhI1oNFOl2nYQ8x sZzoCsSFDcBkq/s5PDE0vL0F3+cItAFMIlrVKKUwDvTmmuGYdHBcl2xsdc+vjs1ac4TE lazuqy+H/jm8jfKW9SWRbfCpVxa9Nj8dP68VvToKM3SUHi3USIfrVtPU6OC+aA57ySVQ j8MF4OiTeqW0ql5hRLJGiL4fKn4mS4nKZ2mKymYsO8U4d9QOdfx/VLov9rxEWwt1iS5c O+byjnpmmAhfPDsvcqWYXHoHLfA930T0k1noAOBYz7Ycd6SHQLb4asHh81YDO3Le2C1n VDfQ== 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=/ldL5Mg0I3ZuGb3h/TCF9ldgWkiTF4nlu2BkAtFavko=; b=zceRZlr2TPJuszX7uyjnQDsxvL/hXibYh+EUMrZs45iejFMel91AElDsE6Yh9/uQAF f96oNZ0r/d/Cw7KyHCOOgrgZmZDN78VoD+eBA/r6Adci/hIXxpR4L3j1/Dfxf4mFkNii LDLltokO7wEZRi/NRErzWJyG2iRs8TChCOE1le+dYlV7phGWrWM0CELb3TEWpKnFqLkh SkI7aAPY8PWFvF5dj73+pP7UuGc5GusdgX9yFi1D5NDa3Bgw5sC6LoGHVr78SwkrKmJM eaReWPxAiaBf9AIIjoLbkefbsgPdkdvIoRbico2k7Vujbyp6canVyHOMBkAomzPL4p3B Mo6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=oYb+qUJo; 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 15-20020a170906208f00b0081a9c3ca498si24601694ejq.314.2023.02.01.09.10.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:10:57 -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=oYb+qUJo; 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 A7EB63893661 for ; Wed, 1 Feb 2023 17:10:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A7EB63893661 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675271456; bh=/ldL5Mg0I3ZuGb3h/TCF9ldgWkiTF4nlu2BkAtFavko=; 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=oYb+qUJoTWnxnvaun5ZmAMy7w4zRtawEUtkwE9gqUl4t3olVjD9XpKTV+FJtU1ixG 6Qo+OKP0HfPXWw7qkLgZf/rWat9cMUHnRUz+mx47UU2xMPWLOptC1wh1m0M2a9Wnm2 KOraC5CbuSvOfT/8mS/oD3dyYSmJ7ib7UNGORJIw= 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 8543E3858C83 for ; Wed, 1 Feb 2023 17:04:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8543E3858C83 Received: by mail-oi1-x234.google.com with SMTP id p133so16253552oig.8 for ; Wed, 01 Feb 2023 09:04:59 -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=/ldL5Mg0I3ZuGb3h/TCF9ldgWkiTF4nlu2BkAtFavko=; b=xMUGvrS6IL7byCwmyL8jySd12qgs8Vh83ob7y7QhPAUGdMuA4IEe6HcI+0JCFfish4 4rd9cQE+uK2fcHScUbTnxLZusp0q2HbAX0gYrjOEFnSL2DOJIqGDl6mHRTzqfxWHGrbh FCkuUeYbI4OEhUT7qO+rIl+d5ez/a+pI0RVj8QQGYjUaKtOMT2TbZ9H7UQI5XyBnWPTG wzFv9dPgT+56cnBGWCnMAjnTx8MKTh0a0O3ZFNmnUot/iJdDlOypgXPUVYU7h3ys/1fO 8aI89osPNwQFS+DZK+Qs2pzE4dhMlOTxg5wZpiHdGVYHA7jf2xBilL5bIIhqvGamZ5DV lBhA== X-Gm-Message-State: AO0yUKXkOF/mv+v5q46VbbiWO3cvLfTQaQ3xE0YKX/j46AT7MOVLQORa s7jTNQfxJvnruMCkGAtnwk8agNTk/zLENRERSro= X-Received: by 2002:a05:6808:481:b0:378:6ebe:a98b with SMTP id z1-20020a056808048100b003786ebea98bmr1350662oid.37.1675271098277; Wed, 01 Feb 2023 09:04:58 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:d2ed:98c2:d2cc:bf06]) by smtp.gmail.com with ESMTPSA id b17-20020a056830311100b006863ccbf067sm8077090ots.74.2023.02.01.09.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 09:04:57 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein , Jeff Law , Xi Ruoyao Subject: [PATCH v11 18/29] powerpc: Add string-fza.h Date: Wed, 1 Feb 2023 14:03:55 -0300 Message-Id: <20230201170406.303978-19-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230201170406.303978-1-adhemerval.zanella@linaro.org> References: <20230201170406.303978-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 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 | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 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..5dec740041 --- /dev/null +++ b/sysdeps/powerpc/string-fza.h @@ -0,0 +1,72 @@ +/* Zero byte detection; basics. PowerPC 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 _POWERPC_STRING_FZA_H +#define _POWERPC_STRING_FZA_H 1 + +/* PowerISA 2.05 (POWER6) provides cmpb instruction. */ +#ifdef _ARCH_PWR6 +# include +# include + +/* The functions return a byte mask. */ +typedef op_t find_t; + +/* This function returns 0xff for each byte that is + equal between X1 and X2. */ + +static __always_inline find_t +find_eq_all (op_t x1, op_t x2) +{ + return __builtin_cmpb (x1, x2); +} + +/* This function returns 0xff for each byte that is zero in X. */ + +static __always_inline find_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 __always_inline find_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 __always_inline find_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 */