From patchwork Tue Jan 17 19:59:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 643406 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1364267pvb; Tue, 17 Jan 2023 12:00:39 -0800 (PST) X-Google-Smtp-Source: AMrXdXveVKncQcc+UwX9DA5mukjbnj0CacALB/jQSdArF8utHi4dwx6iBCA0MidLQAJgB7syQUwo X-Received: by 2002:a17:906:5fcb:b0:870:df7:300b with SMTP id k11-20020a1709065fcb00b008700df7300bmr4105970ejv.52.1673985639675; Tue, 17 Jan 2023 12:00:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673985639; cv=none; d=google.com; s=arc-20160816; b=siDRAGXw1eSSofi701jE8h8CA1Vez8Ar2WkBw2M/uriWtbRHx7u9908/BMYaHgZUrI TXLjV4GRUB3gB4hnnK0jVIaqOekm4jPWrYPz2AlAYvMuyt1PGl+QFuAOEELq5crLOXKe UvlIb/P4FhkTze9nG+JSuNOZdkSgsWAIcm1zOOk9Rq8uEMULMvBPl4ULcunrJB42pE2C 3Fc1MLKvLP7zg503b8sJoMJ1q5/XLDgjxuXWQV7G/bWzXb/DRcK/QWEQzXnFCqZYoNgK JpRNFLzoO4fVeDmndn/sole1ySd5anHBwWWVrDQCETRQ1VVcSVEZ8+P5TT0Le58+V9Zk XHTg== 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=Msm1OMyclvJ5NyV+P0tV7Hp6Krr3Jea6EjfGtC9B+SiZXWKQFSMUTNoDdNxD1kQeMA sqyGcPpoEFDMTA1VV9vAvilfmf/LTBGmOXqemxouW6OJ6zaNZjtd5JM/4mY6iYde89nW RVwYz9EhSemCmsdu9++zw06sjWr8JOCIMcSQ3rWTXyG3kuCF+0EDHXCIVPR/MgoN4lke IUDhdOI7yaKyEZx3v0xZKD/ikCDkFqDg/zvpE8baraL2w5cO1aw4SFldz29hyBXSSBTq hVYdLWBL+eiG2/DM31LEoSy66vwraZgpow0ng2m5wlQUS0vTr6ojuuCKYbW11p15EaKU GwIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=kLenC4YO; 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 cf20-20020a170906b2d400b0086d49129346si9834026ejb.264.2023.01.17.12.00.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:39 -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=kLenC4YO; 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 93BE338582BC for ; Tue, 17 Jan 2023 20:00:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93BE338582BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673985638; 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=kLenC4YO2IFy3w72Vfwp4T/yzlTxBxw/9DDfZjNNgYS24FzzLlQZ67HA7z1P+rruv iF5O6/r27JrpF0R5/wxQddYfcpCKw85rmpy/J30Nz02Iv6TfCvOz6G6SsdWnwihHeW M4KU0GMVG5FcoSRYCYASmALinkeeybBcygvPiLRw= 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 CB6123858C53 for ; Tue, 17 Jan 2023 20:00:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CB6123858C53 Received: by mail-oi1-x22b.google.com with SMTP id p185so5782293oif.2 for ; Tue, 17 Jan 2023 12:00:25 -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=IgawEThkcvyA+XHreiYc09XDa1/8tdH5bC0GPxVaMAROLNrWNyp5QJEd3YtDlezo4E gREkxuwD617ovoKAOlF/dEbX4xFdEBx+82yLUr9KEdv+giTZd7ndu/uwRqgBHLT//cZX DMjO5m83MTSw6EskWcJe0CnMULsBVf+IjXeRELNed6yPSz2HEtF2m1agFQM9qxFULyKI cxPmsgcgv+BLga2G/CxTAQhlcjo1PRpus3JT6VCpWOFU1UgFjtiEWUMDZr8jsjjQjc5E be1/hcnuDF0w9DV3j35UUDbHB9zOPlvR4nOVbwZDCck5QBC7TszaaJXaicbJ9aiZtj9i hS0A== X-Gm-Message-State: AFqh2krjIrXFLQR3TmXivBKaDsk46wcKnsHmw6izVeW37zpwO6chXimI 1/N3TM3GA/r+VXXC2KpfVg1vLTfHoATtg3MhFyo= X-Received: by 2002:a05:6808:179d:b0:35e:b4c3:3708 with SMTP id bg29-20020a056808179d00b0035eb4c33708mr2975780oib.5.1673985624528; Tue, 17 Jan 2023 12:00:24 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1652:fbfc:c80a:f5e8:5ed9]) by smtp.gmail.com with ESMTPSA id l10-20020a056808020a00b00360e46a1edasm15095866oie.22.2023.01.17.12.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:24 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Cc: Carlos O'Donell Subject: [PATCH v9 02/22] Parameterize OP_T_THRES from memcopy.h Date: Tue, 17 Jan 2023 16:59:54 -0300 Message-Id: <20230117200014.1299923-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> References: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.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 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 Tue Jan 17 20:00:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 643410 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1366129pvb; Tue, 17 Jan 2023 12:03:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXuGDBlBA/++BzbkbUuZaf1gvWhT3SXnMDwLUyDJS5ClRME8GCX8Di2cLN47bmChF5jbVpZz X-Received: by 2002:a17:906:3487:b0:843:770e:777d with SMTP id g7-20020a170906348700b00843770e777dmr3888100ejb.11.1673985816891; Tue, 17 Jan 2023 12:03:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673985816; cv=none; d=google.com; s=arc-20160816; b=DDFtv1aZyQEZK6gnbR88dO+6/IpinaqeZVhI/w4BsB6WtV3J0RrAICV3U3lkhFrbc8 XmLXIMFg2vjZO7xdzd37c8Lq4EV23UAfD//ZSt5uGbSQnAT2nnUxD+5LvpYXaNV0UqYU L/dt/xS6wyzU2eaLTu6IvuPpoIEMHkFHhXe+hpD6wZoKQj0QjabPvWkzNb9MM7M+XLhB 3c/H8OJUClfbVViRU3DTtWofmagRTbgNSrjlqHBJBW37d+DrBtHbt0OdyPPPztQUXE8s E/0ohvVRO5uLWnOT2JzaVY2ykLxB+lZVU/36g1XGS/amPw1E7OOlB+KXzE3CX00RGpQf PvPw== 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=Mq1SjUWZ+UjmM7yval62LkQmxQlT/BAGNYwkWx3wO1OYRIVuEqS9rOJPpi/A4jXU++ vAu19Qu5O71XE70PDwc+S3TYWQylT92b5nYBx4bpiQLVxdrj67ZeyLZoKXrDBysvHL+Q pIDacX+kCMmvnJ+qTKXSETrBafREdVg6YB4Y2im0MQXSwGOpjhaMlkJhzbnNqH1rq2TL l4n8b6pOpyqXBtAVJlOlLu2csjwppWtrezRuQNqS2Otyjdk3lBTJG+OwXPyCXvgYAaYp I3+r9lPKhqubGHce4xDgDm7dwfftTaYIWRbVysN6HRtd84LVEgAABI2FtdkhriOW9qqG Emig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=lnuYZBHQ; 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 l15-20020a170906794f00b00875abc669casi712928ejo.572.2023.01.17.12.03.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:03:36 -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=lnuYZBHQ; 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 BE52D3858031 for ; Tue, 17 Jan 2023 20:03:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BE52D3858031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673985815; 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=lnuYZBHQeXLvoQyg5Civ0Vo413KPjune4Xektz8DDoYWqyoOd6B0w6Q9bfKqJZ+7i xd1v0ODWByIrAJZs6Ns7SgWyc93ETuL06L0muw+ZGPYsbz/gKB6SVtUUxRezCpPBI9 Tj53ZeQXZflVCA5csj0L0qiwIAQsjt9XmqgJldTY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 562C3385800C for ; Tue, 17 Jan 2023 20:00:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 562C3385800C Received: by mail-oi1-x233.google.com with SMTP id o66so26870262oia.6 for ; Tue, 17 Jan 2023 12:00:43 -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=ykHeY5svgim3IDg77bBL+N9ll4tJ9p2BVlkakwXtNmrhPx53JcKlVXOhooRFrfUFbZ mi2B27h49mh8MO1Y67U0dFgGc69O53cIMutncjv8OHmZZhg+t+05ol8Fi07xkJkfeckI WKn5NXzGCvU16xapYffJp0gPsDa/ru1w3f/GF5BrvmUrMOKk441XgQ+/jUwj5eN4UwPO 1IBScLz2K+YbolJ2eP7d1PukEvnFqaz6Ve8lDSosyM00YpTW4CKfPzbqNgJ6C/iNDtbq GE3UWTHLJCnQjQEaGdme5ie9yfbOrBD4mgOspJEcfBmImdYNIDalO1u6KSkw36K24Xg6 4g1A== X-Gm-Message-State: AFqh2kr8Fzr5jTlG7T8ArjJnN9tVAAUVhqRMds+cSVRrFi/lbTNheTV+ 9iA2b1u0adnDXKEXIhZbpeC9FezH0nO8BdNRXac= X-Received: by 2002:a05:6808:1687:b0:364:c2a9:5584 with SMTP id bb7-20020a056808168700b00364c2a95584mr2941953oib.32.1673985642204; Tue, 17 Jan 2023 12:00:42 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1652:fbfc:c80a:f5e8:5ed9]) by smtp.gmail.com with ESMTPSA id l10-20020a056808020a00b00360e46a1edasm15095866oie.22.2023.01.17.12.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:41 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v9 11/22] hppa: Add memcopy.h Date: Tue, 17 Jan 2023 17:00:03 -0300 Message-Id: <20230117200014.1299923-12-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> References: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson 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 Tue Jan 17 20:00:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 643407 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1365478pvb; Tue, 17 Jan 2023 12:02:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXuQ9lJ9Mhpfrh4q5/UlWa3nxpMDbIJvHBovv4gtj5vEcK/6GpTAuJHj463t23GDV3Pe6Fs7 X-Received: by 2002:a17:906:29d8:b0:86f:a1fe:237a with SMTP id y24-20020a17090629d800b0086fa1fe237amr4481477eje.54.1673985755265; Tue, 17 Jan 2023 12:02:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673985755; cv=none; d=google.com; s=arc-20160816; b=SzcBG+BYXrrVy1fLaguur/k24WAs8x1BLZy3fos3GofJEKdOzz+MfuZMV3FkN1qH+n Tr6X06kSZ2xkG9Omrx2nXjnyKtbWM+lq6Mz+mqmjG7V43/Plpun1CJ//OIIvAvl89bPx fi3kAYpswnzQdEE04nXWnHJBPfo9At8CAWP9/v2QCLiJd4A1TjhIg2H/vMlKqpRKoXhL SppQJVLKetAQ5isymr4JDGqn/+/IYGmDmL6MK4Di71IGcw1Yzmya6WXHdjgdi/VYGSmB oSSgBD/8fKj8T5rW7AcOGHCj7WR6rSXUaVCuSqpPB+wp+cukYPDJJdBCT8M3lnEeMB++ WdqQ== 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=twdo6QujejuZ8L/LB6eu/+3VhUFQsN+9ED9W3Y4kE3g=; b=vL2JnKGDzHmDgqFwIDenYF1ugv0sMvLuToR0xYE+VO68toyJmguICr1mG5tPBxCp23 MIn/jPGV3q9a5ononoAjTAi6NXl+LaQrx31vLkVR46pWQtkrB0ntdvsXywI/s7XInzWM SO97NP7Q+3xXFWoOGT2Q3Fjj9m9ZEtEHppKg2Ek+xcGGNWdWZ7DeOoy5iHHErnBDowEc YGHJNmcEyFXbLA9J3c6rsrMFt4Xjb5TY63zIMAMxduPYAiBBZOo//HaIwRbgJepM6TBj l5QL1EtofCosel7G4Ae4y6ND+OC4ERXt+cLIt0+9OApQrShX2KQyHGYwIqIXNMLv1K01 Q+Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=wxmCDz2W; 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 xj4-20020a170906db0400b0084c6c09e713si36536989ejb.464.2023.01.17.12.02.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:02:35 -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=wxmCDz2W; 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 E7F0B3839DFB for ; Tue, 17 Jan 2023 20:02:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7F0B3839DFB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673985753; bh=twdo6QujejuZ8L/LB6eu/+3VhUFQsN+9ED9W3Y4kE3g=; 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=wxmCDz2WWXsacuPZ5sK91z4UOQhfF5dvzQ/k6wA1nuFA1/mbNdLjAaJJhGJ9FX5NI vgGeKQJLEJmTPelDrIHH4lH+YAapgGgY/h56OyXtq0XJn6WOXD1X5FbdgM270MVOPb UYaHatXG4xI6EWJA/SYZuzRvbVCGrGftx5nal6kI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 3718B385841E for ; Tue, 17 Jan 2023 20:00:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3718B385841E Received: by mail-oi1-x233.google.com with SMTP id o66so26870353oia.6 for ; Tue, 17 Jan 2023 12:00:45 -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=twdo6QujejuZ8L/LB6eu/+3VhUFQsN+9ED9W3Y4kE3g=; b=cWmHpCbv1k5ngM+cBa2oM8Bo4jdk5YuiH5m3BVMwzG6KBCXbPe7vX0ek3AaDxDg7MZ /xmr7sLqnsue/ssDoqbG2MvJe67Ygg1Kxet1SXvDT97nZgviP6iyT06Ik6JUwj4W5TCz 2tv+24xbW7TJC6NPLN3pXylkOH4nYSWVqogPfVpcDzErgGia/bI1xhbhxIk3Z4MyaHrI g/67/usxPjwwFnVep536JCWLbqGC8RxN1BZIeVtCVDxc+hWe1cyQFzLXfokGKPF5Sq8m afPOOWxoWWGggJ8mEv+1JbPU719ixWKjzSYMWpJieS4ZKwrfHpLtXmIb5pYFuRTfoDIB APiA== X-Gm-Message-State: AFqh2kp8tO73rm1+gy2G1aOz7hmdta83SJqqWZ83cu32gj3/e5r3WnOW rDvcWpj8/k5iPu3SFunW6HWKtMWT8bkif/dkb+Q= X-Received: by 2002:aca:654c:0:b0:364:8dcc:58ec with SMTP id j12-20020aca654c000000b003648dcc58ecmr1953521oiw.3.1673985644178; Tue, 17 Jan 2023 12:00:44 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1652:fbfc:c80a:f5e8:5ed9]) by smtp.gmail.com with ESMTPSA id l10-20020a056808020a00b00360e46a1edasm15095866oie.22.2023.01.17.12.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:43 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v9 12/22] hppa: Add string-fzb.h and string-fzi.h Date: Tue, 17 Jan 2023 17:00:04 -0300 Message-Id: <20230117200014.1299923-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> References: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson 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 | 70 +++++++++++++++++++++ sysdeps/hppa/string-fzc.h | 124 ++++++++++++++++++++++++++++++++++++++ sysdeps/hppa/string-fzi.h | 63 +++++++++++++++++++ 3 files changed, 257 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..865e548492 --- /dev/null +++ b/sysdeps/hppa/string-fzb.h @@ -0,0 +1,70 @@ +/* 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 + +/* Determine if any byte within X is zero. This is a pure boolean test. */ + +static __always_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 __always_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 __always_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-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 Tue Jan 17 20:00:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 643408 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1365963pvb; Tue, 17 Jan 2023 12:03:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXswetZQC3c3HGjpZJgO2AbV2qczLHcbRbcCd6dbMkl221+ZpgCHYDHfGPqgUbFyhlqfcu7j X-Received: by 2002:a05:6402:5419:b0:463:9193:404a with SMTP id ev25-20020a056402541900b004639193404amr4663247edb.21.1673985801241; Tue, 17 Jan 2023 12:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673985801; cv=none; d=google.com; s=arc-20160816; b=sMoqBpBUsV2xWr0ngPZfEjxdMYX5hJKYiE/7nus6XF2aGLmiMn1XJgwCzvR2l9px8K pZqNNVaJveFbqWQQs9PACQg846hcqgHIoSCELdFn50JYgcQWKy0GGd2frqmPOfD5j1bf R9m8aBagTaibFdFkxtl1Il5DGk895Ij0aBdep11ljh29j6Rv2tPlrMPR9q+UmCLCU955 41hN3++xxjCBu6pNL9RsD2Jf4EDxCAeTxh1HYrX7aElq5e/5Prp7Q/3zF+wPFvB/a06+ n2UKym8ulB2M7iPZYZC3eH5oLF0XbTgn+4TSE9faOz+T9Ny/Au9VqtdH0YZqcKoluzyM pc4w== 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=H1Ba7wyvrWguPb2/gXj5yGt4y75vi4gIJcf6q+ir4L8=; b=iGTwdv+wtFbJhFEnbSTslL/M4Ri3KRKu3PU+/tcbUz+rpygscXG1rV6SN9lOwKpe8q bEVLFFiJP59TEgLoTkrvHDOqaXnCm1CPtlC6nt+ZmrfX0DENZwl3VsYVbekSaw5HT9rH mecPS+qRnQpUWYCFLRAxtGWWY83UWfIVIV7cv0JSQj+NvUTQzhmVjEF0wingLoR7XggI q8AqMuNa3eQELFVYisEA/gYxWIwjjMbuaSiJhDWxPf7n8XdOhjjhjX8EYWJ367AhneMW bEkRqM+9DyjSldUFPn5y9HTfJ1yaqOvoJwwXOSDzbx9z2fgqk0J9vBYoAIdM/imY5zL3 UL0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=sePW2rkX; 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 bb5-20020a1709070a0500b008621404f1d6si10998931ejc.892.2023.01.17.12.03.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 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=sePW2rkX; 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 E16C638A90A7 for ; Tue, 17 Jan 2023 20:03:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E16C638A90A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673985799; bh=H1Ba7wyvrWguPb2/gXj5yGt4y75vi4gIJcf6q+ir4L8=; 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=sePW2rkXcew6ohSGstVI6FWTJp+1TIG4rwcFVHIq630jCefxeL+mH3fUTJ2+ktsGL sQgq/SWE5a8O8K25uQ0/jDDtfa5rc60C0r560Xn8f5wCrr6O6IVEsxTLb3xvNeEq/t TNboih5xsk/Osw5DpaYflQbDKEByIHNJKpEoE0SI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by sourceware.org (Postfix) with ESMTPS id 313FC3858434 for ; Tue, 17 Jan 2023 20:00:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 313FC3858434 Received: by mail-oi1-x22d.google.com with SMTP id d188so15734034oia.3 for ; Tue, 17 Jan 2023 12:00:47 -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=H1Ba7wyvrWguPb2/gXj5yGt4y75vi4gIJcf6q+ir4L8=; b=2Caocha2YPnjDokO7lMGcbiY//67rjvZBm+P/0vfj44UCI2fEXI+K1bt+3JoBeS90r iDDhROEGQwvwJYDN9DPw7HALKGSFYTevzhzn8/+i+RknQNSQQhGDAEiuDHDZLbkOc7wP GSXoVnIw/bqOf2xz6PUlJtH/+OYshiaOoA8a8XBVPqn6dtnED9Rvgjs2vRWdnBNKcYSl IXXYESNVtkrnGTmHVdd6xRtHohOu+J43bnJy5cO7FkDBA0MzT5HL56QTeCUWz61moKua 8/2rAMbAaFaifeTr29dWUiZ5kNN/w0EDaBPyfL3SrLAM8u2TgcU03i+1t8j4yIJSyVyv Li3g== X-Gm-Message-State: AFqh2koFkE8luosd6Zq6HCZVIvn7568zFLG5wUSzumsPBCI5snA1N/q3 t7TB2VxtkWl3v5B6u2hlBf7f7mcA2WhRAI9AzA8= X-Received: by 2002:aca:b909:0:b0:364:9fbc:f197 with SMTP id j9-20020acab909000000b003649fbcf197mr2165277oif.35.1673985646152; Tue, 17 Jan 2023 12:00:46 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1652:fbfc:c80a:f5e8:5ed9]) by smtp.gmail.com with ESMTPSA id l10-20020a056808020a00b00360e46a1edasm15095866oie.22.2023.01.17.12.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:45 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v9 13/22] alpha: Add string-fzb.h and string-fzi.h Date: Tue, 17 Jan 2023 17:00:05 -0300 Message-Id: <20230117200014.1299923-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> References: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While 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 | 42 ++++++++++++++++++++++++ 4 files changed, 217 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..94c699e3b1 --- /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..f442428c6c --- /dev/null +++ b/sysdeps/alpha/string-shift.h @@ -0,0 +1,42 @@ +/* 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); + return word & ~((op_t)-1 << s); +} + +#endif /* _STRING_SHIFT_H */ From patchwork Tue Jan 17 20:00:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 643409 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1365971pvb; Tue, 17 Jan 2023 12:03:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXvvjUgRDU1GdFjCDxr3C8CVFk+d0DZ/Ln7J4OhViC6cZDQDKgyW18EYLlJHbaN8wFD7Y72z X-Received: by 2002:a17:906:299b:b0:84d:4394:e8e with SMTP id x27-20020a170906299b00b0084d43940e8emr4154433eje.41.1673985801771; Tue, 17 Jan 2023 12:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673985801; cv=none; d=google.com; s=arc-20160816; b=B2146E46GT6xxD+FHv+DV3oFKXl2oFg+BlO/tyVfD+u1n5pnUuE28LtzHrX+95ZqxD wN2RUNlDO/a9Ze+N+TgGaiYJoNpe7bzWR+r7tw+bXZLY1pT2E3GysNztlQznv8wPm3TS WX5qJaEHlTCBquyjND5TLIMz1xp911xlj3awBUaFXzGw67nIdzTgP7CDI3TXW+C6WHfA AXqOHfG0cPl8zdoFxwrQK9EPRz6P72GKH3IkY7mGSawjemxhcqhGu7+aU6HO1FuyZYOL EfIywdU/tid/CCaiWKAUpCOQfWwtrbJY+TLneUggkJPlOd6Ak3ugDBzCjPkn0kvd2rON bOzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=HaJ+7l04b7U2bl/WHHkBz/tOSu1xV2SCXVSw6G0miYY=; b=sSFae2BvdQd7ehmiFqr/vY/2I6ezFteWJdVeTl/D0mza6eofmnPVyWg42fWnA7voN5 mEijxB7fDGto50s5Ffs/ghps1uNc3TTevY9FpV5rSY7Xx9gbpXAFaciOm6asfJT2exbt 9ELia+i9QTL3m8B4slH4bU1ynT8QfoGwPD+0MS7o9ugQLrRgy2qAMwLXFzOtP+1ZrOug nk/iv8wD2L6vY24iN+BCUz/bFthveRWQ0iQwaeeC9lw717G0lVRwuMLRuRLaEGykAFKk xgnAy0EZ/XyQZ4SjupLCfpYfb712eOHH3n/m3MCPy7hRtP99x8mG9mpSSTPjqm0aACWb bscg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=h+6Etktz; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Return-Path: Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id dm22-20020a170907949600b00797670441desi34492011ejc.911.2023.01.17.12.03.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=h+6Etktz; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B01F838A90AE for ; Tue, 17 Jan 2023 20:03:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B01F838A90AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673985800; bh=HaJ+7l04b7U2bl/WHHkBz/tOSu1xV2SCXVSw6G0miYY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=h+6Etktz8YQaBK5Li0Y5Q0/Au/pNOeo3SHOP4MjOq7qubqJ4W2e0VLkDAY+zVxBhO 2tlizMfJxkYrp7WtptUPPmxesFQiZ5ooDim5qKto8boEduFoiaT5iOQtXBKv1qOs7a VHfVR37obJJckIBxw52BB3nZRLEYRYh7jjlvyPNw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 716AD38582AC for ; Tue, 17 Jan 2023 20:00:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 716AD38582AC Received: by mail-oi1-x234.google.com with SMTP id r9so16110698oie.13 for ; Tue, 17 Jan 2023 12:00:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HaJ+7l04b7U2bl/WHHkBz/tOSu1xV2SCXVSw6G0miYY=; b=h+n1s5j+B52QdQ5FahUk49nAJ1mOkSbc3NjDFJtmgGnlTzYgYXLpQ+3n8Qsba6B9Pc Xzco9hP2IQIzkU9YNgKwRS7qQ9+vIPzYAcaCvfTUJkKi/Njv2c7zAfjeSM8DuynIrOv4 M7P0Jv4Dh5Ax6cAFBJRqW4iGxbYfRS7llXPxnL7pImI8IOuN/krxbvS6yNqx1OijwI78 uoZOnddmVwJRV+ZwJdGL780d43q2ldKnbQ5T1w3qGq0FyJYR/+ULejXZD2zwVd6jCJvG Nw9A4a3kzZJRW5E1SAw/u4vAAD26eNOXQpRjcsRyOsox0e4ys4jBJS7kcz55reA+Ygoq 80Hw== X-Gm-Message-State: AFqh2koPmt03wwHGyzVHCdREkv/aiOHzFPbpXPi0EAF5P8qXQwxbKeb6 dwoPiNG89uU7q6UD5GbB1MwZjpGcLDkkRlmoJLw= X-Received: by 2002:a05:6808:211a:b0:35e:d234:7120 with SMTP id r26-20020a056808211a00b0035ed2347120mr2751334oiw.1.1673985648153; Tue, 17 Jan 2023 12:00:48 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1652:fbfc:c80a:f5e8:5ed9]) by smtp.gmail.com with ESMTPSA id l10-20020a056808020a00b00360e46a1edasm15095866oie.22.2023.01.17.12.00.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:47 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v9 14/22] arm: Add string-fza.h Date: Tue, 17 Jan 2023 17:00:06 -0300 Message-Id: <20230117200014.1299923-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> References: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While arm has the more important string functions in assembly, there are still a few generic routines used. Use the UQSUB8 insn for testing of zeros. Checked on armv7-linux-gnueabihf --- sysdeps/arm/armv6t2/string-fza.h | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sysdeps/arm/armv6t2/string-fza.h diff --git a/sysdeps/arm/armv6t2/string-fza.h b/sysdeps/arm/armv6t2/string-fza.h new file mode 100644 index 0000000000..eb1b3dd058 --- /dev/null +++ b/sysdeps/arm/armv6t2/string-fza.h @@ -0,0 +1,68 @@ +/* Zero byte detection; basics. ARM version. + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_FZA_H +#define _STRING_FZA_H 1 + +#include +#include + +/* The functions return a byte mask. */ +typedef op_t find_t; + +/* This function returns at least one bit set within every byte + of X that is zero. */ +static __always_inline find_t +find_zero_all (op_t x) +{ + /* Use unsigned saturated subtraction from 1 in each byte. + That leaves 1 for every byte that was zero. */ + op_t ones = repeat_bytes (0x01); + return __builtin_arm_uqsub8 (ones, x); +} + +/* Identify bytes that are equal between X1 and X2. */ +static __always_inline find_t +find_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or equality between X1 and X2. */ +static __always_inline find_t +find_zero_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or inequality between X1 and X2. */ +static __always_inline find_t +find_zero_ne_all (op_t x1, op_t x2) +{ + /* Make use of the fact that we'll already have ONES in a register. */ + op_t ones = repeat_bytes (0x01); + return find_zero_all (x1) | (find_zero_all (x1 ^ x2) ^ ones); +} + +/* Define the "inexact" versions in terms of the exact versions. */ +#define find_zero_low find_zero_all +#define find_eq_low find_eq_all +#define find_zero_eq_low find_zero_eq_all +#define find_zero_ne_low find_zero_ne_all + +#endif /* _STRING_FZA_H */ From patchwork Tue Jan 17 20:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 643411 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp1366365pvb; Tue, 17 Jan 2023 12:04:04 -0800 (PST) X-Google-Smtp-Source: AMrXdXsp9Uq06yosQeKgP/eMH0MXchUkkRQp1aVk0hayA9WA6T/UJHV07KlxRAP5gPeSNyhwWJBh X-Received: by 2002:a17:906:1450:b0:7ad:c5b7:1c79 with SMTP id q16-20020a170906145000b007adc5b71c79mr4288492ejc.45.1673985844347; Tue, 17 Jan 2023 12:04:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673985844; cv=none; d=google.com; s=arc-20160816; b=kzLHkcBbYuzGlwGdzXLJQqIwX1KFqrssNaOYNvED6JJSXrKvmEwUJGbqPGLV4wtUMP 29taEpsuk67GIP857JiM2q7u+QMu2/wQ9iJk12bmVzNviJJSZehqGOVj/n2t2aWmgkF+ xSXSpSash9bi5g5wuxli7ZmZoZQA/P0DBt4ftawwzkeMtRBu3wj3IQW86YDTwF0XoHGL caqQbTHyq2xNlcPqakF1NTmNwjCgYB18FWc3LIJzIpZ6H3x6i9asZOd/MCBdwbxjCqXU C4xwHWXM+skvwIYImuMyFbRyTxDruLHl0BbLTzRgozUb7VOHTOrv9glUloYAcXMYPkVL yzRg== 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=kkMVjcQtif0+aGBkPM2pYkem/SVecldr0MLVq9MfSD4=; b=Nn2BflWLdg9ran4RRd617n7VGxPlTzte9ecAd0upsL0YATOLxQbg/JV+StzCnKlr0m NFEmvzVIjzPZ0VSHtYc4dV/GuQxvAFlfQ/3/EhUdP5K7vKav62GXCGR6PHS7D/fMMi2z ZC0Q/2Tf60ZkpgOyn03ZA0nR1I2D9RI7/dmJoqW4Vlp4GUdlYk4fFoTAIPelLkIaQ2qu RugCDumv6qilCGvapIwyhsowbqnRM98DFGt66RVvLmsWfHpAPBASCcMQxgPR2uppIz94 lPNpsnB1KUBCyRQ/IeBbe+Mrej2x/XsPAZnvo8QEXhT/lS9+o1bRYMSe5zTggj9WLerg q08Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="gzVqr/no"; 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 qw42-20020a1709066a2a00b007ad943d0608si10911901ejc.630.2023.01.17.12.04.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:04:04 -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="gzVqr/no"; 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 041893854395 for ; Tue, 17 Jan 2023 20:04:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 041893854395 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673985843; bh=kkMVjcQtif0+aGBkPM2pYkem/SVecldr0MLVq9MfSD4=; 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=gzVqr/not3Bke+FUq74KCzZ7p3r50/5D2DTI7wkNw8aO3uJDzfZUBcV95q5pMWLd8 tHxFnS7cmbcicqaEeLPd8gFc1E1Kvpy6fFpgxUEqyeSyk9XIi8kSPB5ARlg+58F975 8fG+MxSWiDciEeaZTXaZ6zJynYc0wLSEvLCp2VZU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x232.google.com (mail-oi1-x232.google.com [IPv6:2607:f8b0:4864:20::232]) by sourceware.org (Postfix) with ESMTPS id CBF8F3857C45 for ; Tue, 17 Jan 2023 20:00:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CBF8F3857C45 Received: by mail-oi1-x232.google.com with SMTP id j130so26885457oif.4 for ; Tue, 17 Jan 2023 12:00:50 -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=kkMVjcQtif0+aGBkPM2pYkem/SVecldr0MLVq9MfSD4=; b=GXX3coZXq2vx5gxmcnL2HL2qYbGaDbhD74Mpys/PQ/zm2vdYMgCPY6MnZ0zYIgWked WgQWj5FtdyxzHIKyJfv7TSYGljT2IG6s51cNHzuRGXdAzCaVFbXjcQbBIfQzGfWoJYT1 drzzK7L9um5128t98ETHAQs6ETKORD3TCRpRxcRlXsukwsatZPITxJ8ADYXyKRLydZF8 RpW5bD71qiMPL1PSBWu6VJpLTPQ1pgsCus1zDdbrkhsYZ+Oj/XWBNG4TSwodx7wgxhvH Y3nYUKlgM0vIu6OB7dOdxQh16TH21rqapznSLMFBlF+L0n/xm23E6/Z8eY+89UQmemzM DR0w== X-Gm-Message-State: AFqh2kppizcKskTVyNUF4nKbM0aDDkgRUsQF3eQXBaIZ4Op063uNsQfi /mUre0t4X7EL8ZD7HU7atUCgcRlwCR8jI8+W+eA= X-Received: by 2002:a05:6808:1810:b0:35e:1be8:2354 with SMTP id bh16-20020a056808181000b0035e1be82354mr2939035oib.48.1673985650014; Tue, 17 Jan 2023 12:00:50 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:1652:fbfc:c80a:f5e8:5ed9]) by smtp.gmail.com with ESMTPSA id l10-20020a056808020a00b00360e46a1edasm15095866oie.22.2023.01.17.12.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 12:00:49 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Noah Goldstein Subject: [PATCH v9 15/22] powerpc: Add string-fza.h Date: Tue, 17 Jan 2023 17:00:07 -0300 Message-Id: <20230117200014.1299923-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> References: <20230117200014.1299923-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While 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..ff0a1ac2c9 --- /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 */