From patchwork Thu Feb 2 18:11:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649662 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp394784pva; Thu, 2 Feb 2023 10:13:49 -0800 (PST) X-Google-Smtp-Source: AK7set/rtLbWLxAoEq1DS3iYK4wE03tPyUJe3O57gBmWdLIriTPvozRsr8J0+hGJLWr/EGoBsqsl X-Received: by 2002:a17:906:a893:b0:884:c45f:1c04 with SMTP id ha19-20020a170906a89300b00884c45f1c04mr6840652ejb.2.1675361629727; Thu, 02 Feb 2023 10:13:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361629; cv=none; d=google.com; s=arc-20160816; b=XhF5X+iLalCTYQ4b+qPGtsTqAdEMRkj/A0miSfztvlcsZaa3oP/IAzrTgVxVqPbVbL vnhfK78AiMcH2Axp1cPCW0SvuWyzR0Pb6PzBgfiy9Jzp4cQc3hOsVn16bWvCYugxSKgQ SKcEWQPDDf4PQfbzG21y82af5nPf84a6bk2/RWwhNsPhwPwrbNOvMUuiPUlz2IOLKop5 UdvLGqKlrIIfgxu2VyXF7w7xQ3A5r0OE7JQ5tzff9f7B6RARsS5eDqgg/C1yufX5SfeW 62jyNcVvocNZYyHMp2MCSN+qlHdiVzScq4WTLS9UmOqvs2ymorPojw4PEBU4RmUSYvYM AtHg== 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=fDlBgRZwon73eGSfpRv9lCH2FnsdFsffC09M8hr5L/B+V63zrCtTHezDkr9OMpFnH8 5puidQ+m9+q0WETa000dO2jb6syIk71tENYwOFsdITmooiJlSL/LXw/FHqgUnAsE6TZk sLxtkTyGBfL05a5NTBBjQEUdPoLPoBQRrmNRVM1ImN9oGfI5uMi6I1mZ3HDpcwvJQrL2 6bz4m5+fLOcutt9O+AUKOoblNulpyH7nsC1aSP2BilTdVCEMUOqPxMCc1juGzoEL3gNf QoE90h+Ms/dHeIta70iyZKoVQL3ZjqJ/KleRNbZPNXGXeNwf7hWXS0TFNBEhKi0FVtFe jYlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Kb3aVkXQ; 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 fw32-20020a170907502000b007c122a681d7si229012ejc.757.2023.02.02.10.13.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:13:49 -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=Kb3aVkXQ; 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 608F4388A414 for ; Thu, 2 Feb 2023 18:13:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 608F4388A414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675361628; 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=Kb3aVkXQbf1p9VfWqevWno6cctG/dQD2C8491PXcjMiOubWgg/+lKlTxU3GnRU6TR CTkMia8IEAUDC2vMmI+IUm5E1HO0yZOS6uMcfyZ+46k2FzuELAfLJpcz7on9qsFE3c afKwcT56E/CPSvMI+9BSL9abPQ8pNbj2O6LCcStc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2f.google.com (mail-oa1-x2f.google.com [IPv6:2001:4860:4864:20::2f]) by sourceware.org (Postfix) with ESMTPS id EBAFD385840D for ; Thu, 2 Feb 2023 18:12:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EBAFD385840D Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-1631b928691so3517539fac.11 for ; Thu, 02 Feb 2023 10:12:05 -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=GJ9xGqTjeWzEJUAVgv1IKPvqTiAdtIMT2XQ/ukOHcHYjtnJFDR6lrS6yDcCpXoRTD5 bHtE+arSU21rMkZeMimQRrya7Pqz8SgU0EPn1pjlO/nUjw0pdtKfOGfxuQzsKeBJSpy/ VL6PeqnChSiaclpA0JBg3hyek74bH1dPCt6l1sGkcN3aEwojk08Jq0l8BvgnYWBxchtH PQcATWme4A9X79uFHwJoRlOqxtMw3WQXJiMH+JcGoeDqOWre/xdtMXHtxUBqpYJmbPOi WJgvXn1laB541GTN+bCPzIWZOre/84gS3w7xC4Z9AVq0wGZKlCRmPBl53TzBxXVFlSDl e3aQ== X-Gm-Message-State: AO0yUKWSaBw5cckjAoUYAKHECzXkDdb9xmzUiVeJ/tODrGU+USHZlNi3 F+UmzwlW4Ch7Ndf3h4nTVJWpSXe88swOZnv73+4= X-Received: by 2002:a05:6871:721:b0:152:4c46:fa6c with SMTP id f33-20020a056871072100b001524c46fa6cmr3991349oap.17.1675361522774; Thu, 02 Feb 2023 10:12:02 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:02 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Cc: Carlos O'Donell Subject: [PATCH v12 02/31] Parameterize OP_T_THRES from memcopy.h Date: Thu, 2 Feb 2023 15:11:20 -0300 Message-Id: <20230202181149.2181553-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-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 Thu Feb 2 18:11:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649664 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp395563pva; Thu, 2 Feb 2023 10:15:17 -0800 (PST) X-Google-Smtp-Source: AK7set85MwKgoOtjx1P1H8EBsVoM368PYJ/q9aBl267uxNQJWxgG1ppuWTtq3zeeFdiHqCz8DaZ3 X-Received: by 2002:a05:6402:b27:b0:4a2:2daf:adcd with SMTP id bo7-20020a0564020b2700b004a22dafadcdmr7216367edb.27.1675361717771; Thu, 02 Feb 2023 10:15:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361717; cv=none; d=google.com; s=arc-20160816; b=hDj6DMySs4cuMWE7h2gtVejiw54G6zEbHMryh46OvRIS9hbEMSm6gWLLs83DIwlgvc /JplVlhfX3NpDkrMldo61Zr7tJiWZPw4y0UUo5XTvXWkINXxKG9iaqzTim6CVzFjhoyh WM2PHZFJdPmV+OsGT0rIIeMiuCibTTNfBfG/AR3uJ5CZ7wrEYc8BxK+Rb/StE1uLfyPQ zRZF627unwFyi319Me2YjyTF4LTcXDnZuQEaH+ZQBXELQ45TpsVElzdPH50XfnupiVcj X9oUH5XeMylRrIlrEWcbsy7YVaQGQDpWcDGna89u7bnGuQ7IVn21F+BlwEFi8pspobX8 gYTw== 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=h+vPvH7WJFuFiXaNRppqjpFasecUdh17PIqB9elepeI=; b=XviG0QHNm2UuhVLFQagAMCv2wlKikL1Sh1tFXe/lueIYyFglJMVQM2dkPlTO5BREVH 4lmbs2fVWIWFRok18rIXndPb0oCfottEV8VB0tLnlcPs6AURH+Utz3wRlWQephDfxqLC vKJ5iAY6rWbHMSzWJpLXjciGtw/egFdxup1H0rnU7up4+AK4X23xOUqKKbMycSwDAV+k 26MaQMUSq3NM+LowdmdlVWrYPvwevE0rY0N9MtIgO/m3sZVkGot2MhPKqTs4kQi2gQtk ECWqruGmQBJqCFQqmg0Ii2yXJ7HwYIu8eEfXF6V/ldYvypLaTeTwlmHzZ3+vqcL3xZwg wiwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=AuI3Yd8D; 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 fd1-20020a056402388100b004a23153d992si74513edb.238.2023.02.02.10.15.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:15:17 -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=AuI3Yd8D; 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 AC6853943417 for ; Thu, 2 Feb 2023 18:15:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC6853943417 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675361716; bh=h+vPvH7WJFuFiXaNRppqjpFasecUdh17PIqB9elepeI=; 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=AuI3Yd8DpK5T0bnkFKoMIkao+1trFD0WulaAh0bZkjwO7clQhZ/v4MpKTED2/fJiz 8OZpcwK8H6TvhGTfrtKiX1i5ZFCO/FaQOyHPhk0hEN/+uGiLhpdh+SME7IMUwfDkQY yu+1qwZa1bMnZ2SSAFkFZ7dMp858s3DgYXQpzOt0= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 4D942385700E for ; Thu, 2 Feb 2023 18:12:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4D942385700E Received: by mail-ot1-x335.google.com with SMTP id g21-20020a9d6495000000b0068bb336141dso687807otl.11 for ; Thu, 02 Feb 2023 10:12:33 -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=h+vPvH7WJFuFiXaNRppqjpFasecUdh17PIqB9elepeI=; b=BL//Gt/57RUYJJFOEn0X/j+vHwb3Mz7/u0ysqrW26i0ZXbWH4+LzpRaurDzhBma+Gz 0NGwC/UJOjKHhgggO7Gj+dUQDrfequyp0ZvI1y/5uVKW0+pGc7y1wRyLfrTgbPbRze6W 6m71HyKo9hXUTqLmXl65CqB/Hmnd8NrULuxRI86OxMnxk2nasUGBOttpIQLoFRo3T65s KHyqiHlj1ijr2UaURx/WYtu/ruR8FZ4P0oCIhhwAGtkeLGUsmuaEvzXM0lBwkp7bfPp1 5LMqqxQ/10/m/nxDvV9JuoiLr9D1NMGlbsc0/k76fQ8nP7S78YB+BqLroRQOwz/LBI7g T6Zw== X-Gm-Message-State: AO0yUKVGPqszsxG3IDa7u6let9f5tvKVyXZyukOgHUjdtKWZeAcHEmSI r/1/skfgmK/i6+oGMEufP4QcUtGs1jKeIdM5Bbw= X-Received: by 2002:a9d:6a05:0:b0:68b:cd66:2c52 with SMTP id g5-20020a9d6a05000000b0068bcd662c52mr3202226otn.5.1675361552460; Thu, 02 Feb 2023 10:12:32 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:31 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Subject: [PATCH v12 15/31] hppa: Add memcopy.h Date: Thu, 2 Feb 2023 15:11:33 -0300 Message-Id: <20230202181149.2181553-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-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. Reviewewd-by: Adhemerval Zanella --- 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 Thu Feb 2 18:11:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649665 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp396441pva; Thu, 2 Feb 2023 10:16:51 -0800 (PST) X-Google-Smtp-Source: AK7set9GTMO9hGRbhtXhpBiZeCUGMFqz/j+5109CruWnPclE2uoVa540XCoVDG50/KdvQquocpe2 X-Received: by 2002:a17:906:c08f:b0:88c:a2cb:d06d with SMTP id f15-20020a170906c08f00b0088ca2cbd06dmr7479517ejz.31.1675361811232; Thu, 02 Feb 2023 10:16:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361811; cv=none; d=google.com; s=arc-20160816; b=C+NMJgZQsjtEu99gVyuhqjkyEtTcVPd7bUHaXk940SwOrbCrlwIvoiNMLlqOdUS46n xx1eH8h9/0hzCzjKAUUinn2QbqWNGCanaQUhhNJQAmk7xSQnHbXDE1axVp5NTx8/C66m oqBwTKc0gpLQgwkBcBEO0RRQlOlBPdEA7mEZFYFpuKYFzmIUowYETgRyTHy9S5ZY4m9s RfOx4WFHWspj6Ws+1ra+K5IazooCvwIbntmuNDF5+5J7XaQsScSXC/s5gBr5pvutmliq e3evGbnL8vedmzdH11bcmrnFCmo2pGTj67clRRn20mHWJomkesEa3tYoMVgl78XkENxQ maPg== 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=idrqENDX2WuyAiQLTdhPSJ6g6u6MMmWmcKCanb7PO1g=; b=UCVE8snq9PLJMLnTwnWEVWk64JwfgJNAdYaA7n9d65yLhuRVCrDKFNklxoemNGcgLt EXE2XyUaitrZxVp7Y7OAANiviCaHG7OVdUTInBgNpxOanfx9T3dsDwE6KsAzlyzHzU9M sLzAMYFdfyUuzjK6gYDDbTpv/5RuUr0Gh3uY7qOaVvnNowgGtOLwwNiat92Gzvc75Bch XLN6mIWqF1c4wwXcSBU25Ftu2Lq35BRFNSjFYmK5phl3yZqjS1u6VU3Ya9VHMranalA4 F2Zoek31kaZxMvqmUQ2+uvuUifCHlRdAFPJsk2eximDZwsTqFG7KNiu2rPenkgxMvY4O wQbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=bOHrmX3Z; 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 vz14-20020a17090704ce00b008838fdcfbbesi250671ejb.22.2023.02.02.10.16.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:16:51 -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=bOHrmX3Z; 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 E2EFB385B538 for ; Thu, 2 Feb 2023 18:16:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2EFB385B538 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675361809; bh=idrqENDX2WuyAiQLTdhPSJ6g6u6MMmWmcKCanb7PO1g=; 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=bOHrmX3Z54Ira993ecvX5LryVUOdiQlKnbDaS5fqIZMltE8xqD8qBKR7FR9ts4MWH al8JUXebj25b6V3m9vAMYSt/fw4YZAoduuKt0FjPzl3gRLdAYfZvEBC/5ITvBvyuSw /L+7ogU/1iOm7RzTbVmONiles17R1YmTouhRb998= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id D3BAA385828D for ; Thu, 2 Feb 2023 18:12:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D3BAA385828D Received: by mail-ot1-x336.google.com with SMTP id v24-20020a05683011d800b0068bdd29b160so681331otq.13 for ; Thu, 02 Feb 2023 10:12:35 -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=idrqENDX2WuyAiQLTdhPSJ6g6u6MMmWmcKCanb7PO1g=; b=Y16MK9KO2x6lNWVON124px8gYkqNsfBE/6FU0SwpF9QttGoyZE1bbOeiMH1vdCFsJp CdtSid2NCyqkBM/6jza2ZQp1zlrN8A4tS38dHXciHxmIbdTSlbXRwy/WxdLsz3CM4pd4 E8itfk2PtAwXDXtnXrUOBbfK9GGs9Pxz6pghrojBWvgiOCIgSJwRV/7oAqi6+x1tVMtx qCyqvfnH1Fq8Zt2A8YOB/VtrXXv+rc7sa0NKPdWUqZ0SVHtIi2d6AviLV20AQt/6Bpzi S9rDHg9VUV34ka2m7PwJYqerdx8C3i+/l2+DwLAlaVxASFNpHSSvcx8gH1P9ud0pPX7W Alhg== X-Gm-Message-State: AO0yUKUbx+FnjigzslO9Px6W9db0xHZGCMTMNXbvwzlkRpJchKdgj/4q 5FfTBSWUKHxt0WSSSquewXKE8FHpTXJ/gPMXCMM= X-Received: by 2002:a9d:6a05:0:b0:68b:cd66:2c52 with SMTP id g5-20020a9d6a05000000b0068bcd662c52mr3202277otn.5.1675361554777; Thu, 02 Feb 2023 10:12:34 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:34 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Subject: [PATCH v12 16/31] hppa: Add string-fza.h, string-fzc.h, and string-fzi.h Date: Thu, 2 Feb 2023 15:11:34 -0300 Message-Id: <20230202181149.2181553-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-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. Reviewed-by: Adhemerval Zanella --- 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..c4e2e11550 --- /dev/null +++ b/sysdeps/hppa/string-fzc.h @@ -0,0 +1,124 @@ +/* string-fzc.h -- zero byte detection with indexes. 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_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..08cdace416 --- /dev/null +++ b/sysdeps/hppa/string-fzi.h @@ -0,0 +1,63 @@ +/* string-fzi.h -- zero byte indexes. 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_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 Thu Feb 2 18:11:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649666 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp396816pva; Thu, 2 Feb 2023 10:17:32 -0800 (PST) X-Google-Smtp-Source: AK7set9qv3RjuRwxxxCITy3w63OF9aA46h2eg4tXWvcMJ94+Ch2xhn2j0T61TQMZJhIqrQseEiaG X-Received: by 2002:a17:906:694d:b0:88c:3cc7:37d6 with SMTP id c13-20020a170906694d00b0088c3cc737d6mr8506806ejs.53.1675361852311; Thu, 02 Feb 2023 10:17:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361852; cv=none; d=google.com; s=arc-20160816; b=eeCp9riSWDPQxcqfbpSK0ksW7ZglRhPmI9yojfPBAuFu2LmiI4hZvoMf85fjlzNAuK GkXT/BGEaQlnWPR4ss7eyCPM5fIQiUYuJtQWE2XrFuQvUTV0a7jd2iKtawFVbo6kbYuR OnqrQpeBKLi+buE+oxHOeyS3C7mtqb33BVwtBkbo7K/YiLRb4F78reCOhxQeaOPVQChh 3dtl1UCqBa0EqmNy7M54ESmqhzHITSoiKqlVakRxDh/VuQgKpU9RsDO/Fxq6puF+AVKW 8UOC6S6NY35hIQumlrZap64RDTav1wdy14/z4ipNoC8Mw492pScm5tOanh3PKdYLkWkb fNjw== 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=3fXaGuwJOwgZL6V5OO2V4xLMuaQnwW5wgOb9uE8jyn4=; b=vODR4HdLFzLFG/b3sgsOoTjepy2jJAT187m8v6Yp/3Tw7gb3SuLhxzTK9pCN9aNp5p FbVpdZu0iruvgI2uo8SQFfKeL6r4zCjTgj6rB4BoXiJBVJ2pShPlctHv7Svsb0Fztuye oGmxPJVcy+hVq5leP+bD9BH/Eqra+sUdKeiiRNWKexf46/jbCYlaEOZCJmlnmiNEzf05 nD1Gyz5IXQ9Ug9gOp3xYnK+TIgR6WXeTb83J/x8BO23oV0awa8kIptc0LhyxBdSMW1GM AE1DK2cqdkT9w2pXZsdyapdvn47UhHlz8riO6qv1+uk9WRxTQw/AefN6evP/IXo3S05i u4Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=BdxgKJjO; 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 cm22-20020a170907939600b008835feef9a6si231910ejc.491.2023.02.02.10.17.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:17: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=BdxgKJjO; 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 29949389838F for ; Thu, 2 Feb 2023 18:17:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29949389838F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675361851; bh=3fXaGuwJOwgZL6V5OO2V4xLMuaQnwW5wgOb9uE8jyn4=; 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=BdxgKJjO/cUubDdKR1GZkQB1msLFl/FJlbsVDKRf3PqFO75KDFTaa7gcJb1/0omoG SVSq9ecaDuUltAUOVmv5C4yARdtn9nPg35DBj7wF4+w4QJRXM9XjraV9Yl6kBSLY3m IxBtG5qw3nFPce2msZ4h9muJ5giG/YBoyUVo7q3Q= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id A2AEE385B533 for ; Thu, 2 Feb 2023 18:12:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A2AEE385B533 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-1636eae256cso3638462fac.0 for ; Thu, 02 Feb 2023 10:12:38 -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=3fXaGuwJOwgZL6V5OO2V4xLMuaQnwW5wgOb9uE8jyn4=; b=hlTn9JTrXCJamKD+lFplmGHtIURfYCQTy3/Osas9vsYwVZvJ+7HukqLyHupBke1l5R igtIoeLBrfP0Nn5x2zsPpKHqzt7XGQamhJLm+aXwwdXoWA1na5VHVwswtQEW5sbOGRi0 De6PRrBdv75WABq0JcJnDUZosNH3/Wv0yMayCrJc++ZIJEbQpM34SJBiXPYpH+G0arVf CHMqARRQ2S6YgfHaYuw5HeYQT6YiTv28Z6U8SliLpcz7GLCkzS1kHZMIYGGix1phgJDS aBaT9j0czq3c33OCeS8CC9xs3c060CUmEZUGzo/aAArUxTHqUTfz3CbZyYUByqAVI5o/ r6tA== X-Gm-Message-State: AO0yUKXACJbePoSVJSWZfmescuhRuaAspYrUcjQN/6IDhe5cIFeRJk0B Na/AEUCIc7p2Zhe8ja5XlsB4FZU8o5L8qXCjEfY= X-Received: by 2002:a05:6871:714:b0:163:49a0:5557 with SMTP id f20-20020a056871071400b0016349a05557mr3907827oap.6.1675361557137; Thu, 02 Feb 2023 10:12:37 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:36 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Subject: [PATCH v12 17/31] alpha: Add string-fza, string-fzb.h, string-fzi.h, and string-shift.h Date: Thu, 2 Feb 2023 15:11:35 -0300 Message-Id: <20230202181149.2181553-18-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-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 Reviewed-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..aba7ca4f3d --- /dev/null +++ b/sysdeps/alpha/string-fzi.h @@ -0,0 +1,62 @@ +/* string-fzi.h -- zero byte detection; indices. 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_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 Thu Feb 2 18:11:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649667 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp397236pva; Thu, 2 Feb 2023 10:18:13 -0800 (PST) X-Google-Smtp-Source: AK7set/TLQkSGPbohXEdNB/dDUd4/pNJQTIIyUgFy/u7qrRwCu+H/YBWI+DK5/56kcKW5HV6ON0Q X-Received: by 2002:a17:906:184a:b0:7c0:e30a:d3e5 with SMTP id w10-20020a170906184a00b007c0e30ad3e5mr8079222eje.18.1675361893764; Thu, 02 Feb 2023 10:18:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361893; cv=none; d=google.com; s=arc-20160816; b=GedlXqsv7orEWhIOl4kH/5+Y9vskKJ00/tJTh+JnBkT3aJFwF+gwIEPE1HUGKHBd6m p0HTVcjyn1u1+9SmGxHv8+AE+4YLbXh8LzmEyv2jBqGMWgIn852Ki2O2t7I+KgV1ruwE ME8A5zubH8CagmelIHLT7FMafm4/k3Hc04gG9RwKmlZhmG43YL0THrWibXTsdGWFDdFr Ux6t8fQU0x1v6ho2gxc0wGaS+9zK5hb42CeJiHgOVI0K7d/RnA7ysrmDh7nn+16z2mSg Vcgra3kR50F+lVK2CqLqMmKEtjudLkJxiB4YAN1fCg/slJXZfLrmZ5oE2sZvIvELlN+9 objQ== 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=4YbYZoIUJG5C/9HOQop3Df8+9J6Xk8b5bFDcEadWMBU=; b=p2YKubVNPdSjCjzr3da8LwWzw9xKf2phOkUqvm6VDpeoiOEbGL3JPEtHzqcQ1kP9Oy xutgjok3KXk95szXXnv6rHZm8pCG7rKzaOE4spQ2Dqh4Yo6wqZR/EPS5TdDDRFV5cGfT wA5Yx2lZTsWyYE8aktJijF88ligyW6TynwTbJkqESOQurjaSrBFKBVnKmjh07iQWAKbY B0cXa6TJP61ytmzrp/ZLodqGD1yp/IP58SzuI9zUzt13ADxfrMgWYMVLpiSyckWlQAMl IZZgbpNuQXqZyy3QtrasdpUafFE6Sxb3X02T59TFkFrIChjdIV2E2H9/xBCJ1JxM8GG7 r27g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=CiXlFhGT; 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 n12-20020a056402060c00b004a0afc59d41si53905edv.410.2023.02.02.10.18.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:18:13 -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=CiXlFhGT; 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 8A04038A90A0 for ; Thu, 2 Feb 2023 18:18:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A04038A90A0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675361892; bh=4YbYZoIUJG5C/9HOQop3Df8+9J6Xk8b5bFDcEadWMBU=; 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=CiXlFhGTO5ojymQNDywDXTeU9bkZMV/Bw0B7thoJ7lQeT3B8u0H5rYo2hEo5xexX8 01oHq09hRsl658y4DFZ49mrB1JkA/YO/0+AH1SD+11rwcxzThF17QUkoyIzGKqnItR BIRLun4N5ULQsyfIF1kztDIcLBY70Te/olIrrYJw= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id 7AB2A38493EB for ; Thu, 2 Feb 2023 18:12:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AB2A38493EB Received: by mail-ot1-x334.google.com with SMTP id 14-20020a9d010e000000b0068bdddfa263so696246otu.2 for ; Thu, 02 Feb 2023 10:12:40 -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=4YbYZoIUJG5C/9HOQop3Df8+9J6Xk8b5bFDcEadWMBU=; b=kf67v98KjnPZMb9Wup7AKKHebAIt/lkYSJyGf0nru6KRmqcG7NT9LeNnb9oiuPL+6p lJ/7CwvVj5svBEOTM71Np4L2Tj08ysjnkeUSOheCxUyBrgx7fJSGwZiJAyhjUdYU8xhX CDHWBlAoJxC2lt/yBH+lH4GfkX2iq/7h0KsoVZ0AKI6He2bShnY52SXr6+wdOkTiuD5a XSB+QstD0fi9+2JSsdYKUs0qYN56MYW2T2KqX13VYYAnble8S6g0GU48bSy0NceEew9W t3bizjZxiI+HVnnikWzeqvYVgy4e4VqBbsOcQN19au6F+5X6xhRUdlnLcfBkG5RCHw0v DjZQ== X-Gm-Message-State: AO0yUKUEUgAkL8aeWeCI+72VApc8qieJBbUW5A4tzHAaG6p9mUTHT7GN FEhKrPXYL72sTIbtQ5/C83t1GcmNbHaqkqxQsR8= X-Received: by 2002:a05:6830:1e68:b0:68b:b96b:ec5 with SMTP id m8-20020a0568301e6800b0068bb96b0ec5mr3694855otr.9.1675361559542; Thu, 02 Feb 2023 10:12:39 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:38 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Subject: [PATCH v12 18/31] arm: Add string-fza.h Date: Thu, 2 Feb 2023 15:11:36 -0300 Message-Id: <20230202181149.2181553-19-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-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 Reviewed-by: Adhemerval Zanella --- 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 Thu Feb 2 18:11:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 649663 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp394896pva; Thu, 2 Feb 2023 10:14:01 -0800 (PST) X-Google-Smtp-Source: AK7set95Pt1PoJJYzKJJP/ual0J3tTFBK0/JPznp/TcYOQ/Prv7Ndro0TIVnlhPiFbOLTrw4QjBv X-Received: by 2002:aa7:c70c:0:b0:4a2:6c9a:ad19 with SMTP id i12-20020aa7c70c000000b004a26c9aad19mr7068008edq.17.1675361641205; Thu, 02 Feb 2023 10:14:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675361641; cv=none; d=google.com; s=arc-20160816; b=Fm11QTnBSF7FH4aPxysStQzCcLxXGN0479aU2FW1deDDsgRSqDks3FnwoK48w4qPol afR1FInMw+vsaSYUplQ2S4diIAfPu4I3pq4hHNB3rz4bDuhum7s5yojZ1KdGVfgmz+nT NlqaaklF+oI3TxYq5+JM6iL5HQL2PcTZInCnpwZs2NgOIuGoOauQg5+7Us8mS+GApApR 6g1Cjp/wBDVFRjhyxVi85tG1x31S+TRC8HZSI8VfLmLFHXLiAcKRdgYLjzR+vPVs9ofp rUP/eBiUTURG72yrdoglsPSQJloNzShnG++IZey+9Mah6uNvp8ijLagqSIcFTuVP3iYF /GdQ== 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=iBGDBU1LOIu4kx/c1fhVkLNNrKP6X4acltTDNOqXoVA=; b=aEHC705LDA6ekAiu2B5hjZXfQmuAD/UDXOeJkQV2pOMfK61nWHJCZxU+5scN9sBzDs KeMvH/7amOvlt1eYOIJSj/vF7uYRFDoZyB8Sh0YrYYDLLKa9JFRHKJY4FTJIgI97UkQj Y05EiMd7a42CZApN4R7MuaxxZbTpl65o4ilqKf5qLmyqviA10HCFmlxEVjLvi1COMMG0 FbmGtMpeYb8WNi6sjHIS+gBTLo4zhLr5Io8Um3ByyYVuvnh94Z20NW9g5mbERfa33el9 2Y9tmUbkTgmULqBblSSswUlKb64pNMRwZzlHAm8QrKic7G4XQCPkF+53wDVUcliZF39S 7Oug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=i3B1qOaq; 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 cs12-20020a0564020c4c00b004a0e30998b8si101514edb.55.2023.02.02.10.14.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:14:01 -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=i3B1qOaq; 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 D7F5D388214C for ; Thu, 2 Feb 2023 18:13:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D7F5D388214C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1675361639; bh=iBGDBU1LOIu4kx/c1fhVkLNNrKP6X4acltTDNOqXoVA=; 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=i3B1qOaqpiAUZRePf8/5p+ePHPrp5OGkGK2YTg9za56JLEtwkG+hHM0Nrqbt6z4Ly JUcZeGei2YFOJZe2DT3T1tQCwlewVpiwn8TOqgUk6DORfPA+IBbOY1mDhXk/W+XhKw IxbBkbZZrX89+5grrqOkjTVyzBpbC6+wjuWrwcoM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id D812238582BE for ; Thu, 2 Feb 2023 18:12:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D812238582BE Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-163bd802238so3591089fac.1 for ; Thu, 02 Feb 2023 10:12:42 -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=iBGDBU1LOIu4kx/c1fhVkLNNrKP6X4acltTDNOqXoVA=; b=FfRyLpeTbnXCaDOxLFOqOoYIVk+zv2oEr2c+l2E6vn7t/pdihXgn4AfjtKWohtK1Jk Vz1lGkMBWUX3tqFEQSohCVXeRPpEVXWs72+Q4y4m0oNwwpMvdxZwx43vt2TGrFnixoR1 NMSF4BiOzZquEeh6TJg4jeztTh2ivliL5nmTNWgN2hEYrCv3AJ3M7AZAAVVY+f3IhOvP pgOe+b5YPwxiM/4SSv28FabjZP8p5D4W5wACtOB/fJTa46TXHDo+pZpEOE+Ubo5oK2qS WASxg9LPt1+ZVQyXSyQvtQStsoAs0AMqSOmkn24DK6W2vo0X9NNR6JNSEPGeS962uKks D/yg== X-Gm-Message-State: AO0yUKWbRcjEjRkAE2QF9nY5GQ19wWW1w07bfdFCIIp10GHjkgIKRGkl AniFm4lNofXe3H4sJFYcwEOybboXsFwDc67LyIg= X-Received: by 2002:a05:6871:b10:b0:162:9d70:2f59 with SMTP id fq16-20020a0568710b1000b001629d702f59mr4209307oab.52.1675361561767; Thu, 02 Feb 2023 10:12:41 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c2:1887:da12:b9d3:2162:a28c]) by smtp.gmail.com with ESMTPSA id ci10-20020a05683063ca00b00684a10970adsm126689otb.16.2023.02.02.10.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:12:41 -0800 (PST) To: libc-alpha@sourceware.org, Richard Henderson , Jeff Law , Xi Ruoyao , Noah Goldstein Subject: [PATCH v12 19/31] powerpc: Add string-fza.h Date: Thu, 2 Feb 2023 15:11:37 -0300 Message-Id: <20230202181149.2181553-20-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230202181149.2181553-1-adhemerval.zanella@linaro.org> References: <20230202181149.2181553-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. Reviewed-by: Adhemerval Zanella --- 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 */