From patchwork Fri Sep 2 20:39:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 602181 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1789294mae; Fri, 2 Sep 2022 13:40:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR6eAFCYQTesgRQmBJnOqkkZDtBQUb7dgzrvzGNYTVxz94rGJ8hJig+FH1PIRg+n4PYcmwZe X-Received: by 2002:a17:906:c150:b0:751:2181:87a6 with SMTP id dp16-20020a170906c15000b00751218187a6mr3097373ejc.692.1662151201989; Fri, 02 Sep 2022 13:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662151201; cv=none; d=google.com; s=arc-20160816; b=njRTtHPlY5BX+RH+/tLCx64fLoTbbEoFyfpLY8cIpE78xyU6XnmJ9Qry2p5Hv6y6ji l+h4ZVkMc3s4d3i8AILpuNVqTM5uGRNK23R3Eghx68OJg3ijh9T/p8Y3cBTF/lHUX694 R2/FoZOBC2v8ZI+NJUIxFknGn45HRoyaNJMg2ZoSpHjy4Hq4gIXxfyebgdqchReaKCqN JMKwhnWxOJFNSaSCT+Ph9vYcqoE/sWwKWX2nxW2lrYYfsfh3w5XSNIyf1sewmrhfsldj NTmDpIM7wgnoU3dFGswzQwWBpSnusKrmVhztRfPqcAfop+aZdWOHoj0WUAhrKF/kTILC +z5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=uyhyLz38LFlPYNj6QCjH8NWe1tXKsAkhUH/RV/4H9fs=; b=erTQ5PnGguYB793DNmZdn97x1tyInLd1f4EVaLlm57PTwkDlIvWqVkjqa6cOFbJMiP 5WUq05bwUVjwvyvmnpHC+z+fXbaab19Yf8cp+8WEVfj6Gcwaw9eRTZjwtBgWyLuzglmS n+apz39hhapvyUghCaZJDf96XPWqo7ca0JOrq4++e1NAOQC1afqmopP4lVjLTxNSi6yx FTiwj5CK2w3QEMRf5JGcG/hvPrHkqG9xMdyXs19UtRhaodjYhKKyIjKOrO4te1/hx5g1 8ErKbaq17W84bGhd2dxwEJGdGoSqhCHHjyfZhis2OmtqAteZgv17lkg3eXsvROkoYCQe TeDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=OvbbsAFj; 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 hg7-20020a1709072cc700b007307bde1f23si2323276ejc.716.2022.09.02.13.40.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:01 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=OvbbsAFj; 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 AEC1C3857C5B for ; Fri, 2 Sep 2022 20:40:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AEC1C3857C5B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662151200; bh=uyhyLz38LFlPYNj6QCjH8NWe1tXKsAkhUH/RV/4H9fs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=OvbbsAFjc4z7i67XD8xkK7tf8PESyo6BBRQQrno335uzmSM88q9r5JcDGT2arwWb1 CHMVuQcnAFOn1k5Vv6Rvr1oBX/GC+2HxsRIEUFJ1jZC+Y1UJjzvuELcfbeZy3MDN0W AfsvKlr9RE+RnC3TbjGDxfhRAkPflNoJH/zFxijo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2b.google.com (mail-oa1-x2b.google.com [IPv6:2001:4860:4864:20::2b]) by sourceware.org (Postfix) with ESMTPS id 18B263858D39 for ; Fri, 2 Sep 2022 20:39:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 18B263858D39 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-11f11d932a8so7639244fac.3 for ; Fri, 02 Sep 2022 13:39:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=uyhyLz38LFlPYNj6QCjH8NWe1tXKsAkhUH/RV/4H9fs=; b=flgViO2sRMaVroWWObXpqUatP7tPmRkHj8oGWD3gPnfJK5+eOIY3DxM3acyhohf3t+ UjGULE5WYVTTbVck/TEmk1z6tBz3SKrjA/EktCkGjErVk0SvMcGY0gp6NlHpRYWRV9i4 VsnkASfz29JrBeWhoojldZ33my+DXmSrcyKEJnakaXT4xTnSmbF4RB98VHqUJW5+jydO pYtghzdgoMGrQHw2pkOxezBXcVPFC75zl+eoc7CsFeTHNGZ9ZjsrY1tqH1RtI6NXcZtI kRxIRZGg5kdnDBw97KVrNyFIV7jBHOLgOBY/TF4D4994PdU96SvMKadDJp5/n8TUPO1N VUVg== X-Gm-Message-State: ACgBeo08JR7pnPk1SljC0mQMb1+RB/Y11TjPd7xdmLqT/9IuHXyl6uPs 3YLpW/lTw9tyaF/ZuHW9PbNspsf39W5gJw== X-Received: by 2002:a05:6870:f5a9:b0:11d:cbad:301d with SMTP id eh41-20020a056870f5a900b0011dcbad301dmr3016421oab.202.1662151188302; Fri, 02 Sep 2022 13:39:48 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:dfed:72d1:946c:4eb1:ce5f]) by smtp.gmail.com with ESMTPSA id i27-20020a4a6f5b000000b00425678b9c4bsm1107902oof.0.2022.09.02.13.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:39:48 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 01/17] Parameterize op_t from memcopy.h Date: Fri, 2 Sep 2022 17:39:24 -0300 Message-Id: <20220902203940.2385967-2-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> References: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 Cc: Richard Henderson , Joseph Myers , caiyinyu Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson It moves the op_t definition out to an specific header, adds the attribute 'may-alias', and cleanup its duplicated definitions. Checked with a build and check with run-built-tests=no for all major Linux ABIs. Co-authored-by: Adhemerval Zanella --- string/memcmp.c | 1 - sysdeps/generic/memcopy.h | 6 ++---- sysdeps/generic/string-optype.h | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 sysdeps/generic/string-optype.h diff --git a/string/memcmp.c b/string/memcmp.c index 40029474e6..6a9ceb8ac3 100644 --- a/string/memcmp.c +++ b/string/memcmp.c @@ -46,7 +46,6 @@ /* Type to use for aligned memory operations. This should normally be the biggest type supported by a single load and store. Must be an unsigned type. */ -# define op_t unsigned long int # define OPSIZ (sizeof (op_t)) /* Threshold value for when to enter the unrolled loops. */ diff --git a/sysdeps/generic/memcopy.h b/sysdeps/generic/memcopy.h index 251632e8ae..efe5f2475d 100644 --- a/sysdeps/generic/memcopy.h +++ b/sysdeps/generic/memcopy.h @@ -55,10 +55,8 @@ [I fail to understand. I feel stupid. --roland] */ -/* Type to use for aligned memory operations. - This should normally be the biggest type supported by a single load - and store. */ -#define op_t unsigned long int +/* Type to use for aligned memory operations. */ +#include #define OPSIZ (sizeof (op_t)) /* Type to use for unaligned operations. */ diff --git a/sysdeps/generic/string-optype.h b/sysdeps/generic/string-optype.h new file mode 100644 index 0000000000..fb6d67a19e --- /dev/null +++ b/sysdeps/generic/string-optype.h @@ -0,0 +1,31 @@ +/* Define a type to use for word access. Generic version. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_OPTYPE_H +#define _STRING_OPTYPE_H 1 + +/* Use the existing parameterization from gmp as a default. */ +#include + +#ifdef _LONG_LONG_LIMB +typedef unsigned long long int __attribute__ ((__may_alias__)) op_t; +#else +typedef unsigned long int __attribute__ ((__may_alias__)) op_t; +#endif + +#endif /* string-optype.h */ From patchwork Fri Sep 2 20:39:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 602182 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1789300mae; Fri, 2 Sep 2022 13:40:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR5XJJ1SQuQboclRTC33hHV9NpNgQ9l/Tqv56iz0IrVQx/YtpACeYV2kjXTtVEaS74cgyMBK X-Received: by 2002:aa7:c84f:0:b0:446:2bfb:5a63 with SMTP id g15-20020aa7c84f000000b004462bfb5a63mr4129905edt.172.1662151202372; Fri, 02 Sep 2022 13:40:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662151202; cv=none; d=google.com; s=arc-20160816; b=Rx2rzY7KG4GGKS1spPTnB7Xyohr+B7W6SARpD1jKBXSY9CJL6XiFJ82ix3PCHgqomy /gemzexs5hdAUZDtT4pYo5Ax9n9iPtFUOpyQI6jph+qLusgnJHv8hRrbAqq+m6VYslXi 9uC04/NIBfExwK0oEetv9Orw7Bgq13xvP6SyRkEZhwMNqa7PyHx95lyIGXTMLjUvnJWZ 8RmqNnW6GCB4zINfKo5mA2r/oJMJUWRtHxGbLRTOEh+lXWqNUOsdDO9MkDr8nI41Lozp c1ti/w0eh+TiQxk+Y1w0H/jSvHpU9E+h/ywxdAmbkeMivJLnOmdcZGEukHcGuKbk41De al8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=sH7XP65dr4Y5FSbOljjOPzXkAP0NsQyXcAoyHJedZ9k=; b=Y2jJX4N6H/JYHL08wOFuZ47L1RRwN6qjG5NbKl3zWZP+ELJg1nJivh6CpKmYaCtAIa qisYhrbFpC2IkXfbpfXe9iL79RBUjR5L51PNTFzJ1puDrnGqaLjbRBvPYfaPPXvB/POl Ul53FnocgBeMOUmLCQnCD4od2/ViKMIX+yGCpTraEKHwpdLf59sDGdwZSSwKVieS9wEq YYkkVMkQL1UES1tJzS49pFrlkcb3d0XnFJ97LcRZti1E6bdTsX4qIj2gPwEACXT8kd+U rdSRjXPLAZxTp98jThGC9BvYjHsd1djB5ryYt+wjsLW7ZLWzKso/QCH238ZSfXCac+dj bdrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=M31xFZ+N; 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 ho34-20020a1709070ea200b0073dcc5ebf4asi2731029ejc.397.2022.09.02.13.40.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:02 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=M31xFZ+N; 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 1696B385829E for ; Fri, 2 Sep 2022 20:40:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1696B385829E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662151201; bh=sH7XP65dr4Y5FSbOljjOPzXkAP0NsQyXcAoyHJedZ9k=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=M31xFZ+N2SbDxGAPQvFBGIeF5VyOZpAD8WUUNGUio6Q/o2qrv2I0IJYXtMQv7WUlv VcfAxVU7ib3syGn4VgexvLtfpd2I0tJ56/ni3OEesnYb5MgocKzVvBvVw076GG5FFs q6cfchLZ6stjXdZIwyzoIU80NdeAXZHbSHdEkFh4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by sourceware.org (Postfix) with ESMTPS id C7AC8385829E for ; Fri, 2 Sep 2022 20:39:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C7AC8385829E Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-11f34610d4aso7563604fac.9 for ; Fri, 02 Sep 2022 13:39:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=sH7XP65dr4Y5FSbOljjOPzXkAP0NsQyXcAoyHJedZ9k=; b=ozAkwfVyiANYwURphZBLmNQL9dsTnPoHLVFBUVVhCFabJaJd9xMugIYV1IB/gHytbD eIc6scI3hRGuggGLiCScp389GyEbpxFYjjFWg357Y7yetFaBdmYLZb5npsvQ0B52oZw6 ymsCt1pRkUoXuM4NlqMxQIR5kqvHw7xTELAzNDCdtSJVwc7axf8N46suAxzFjgKogLl3 yGupyjtpej5W4hYCj0n63+etSh73MDjo087gCnGGHi+v+GDWf69A6zRsX+A1+FMNLMAk Vb10lxj8FEKpvsZ5/RZqj60kEQkGecAng70k0bOHccw0k7r0Ir0vj5cHJaw0fJ1XMe/k Npwg== X-Gm-Message-State: ACgBeo070BLN73sQX3cyyyFpHOD7/yg8GhHWREcmk8zHEnGGuT1jsbtc gAiBOKOZEvV8NFFnLqV/m7UrpXwf40X9ow== X-Received: by 2002:a05:6808:10d5:b0:342:fde4:3766 with SMTP id s21-20020a05680810d500b00342fde43766mr2655723ois.123.1662151189910; Fri, 02 Sep 2022 13:39:49 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:dfed:72d1:946c:4eb1:ce5f]) by smtp.gmail.com with ESMTPSA id i27-20020a4a6f5b000000b00425678b9c4bsm1107902oof.0.2022.09.02.13.39.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:39:49 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 02/17] Parameterize OP_T_THRES from memcopy.h Date: Fri, 2 Sep 2022 17:39:25 -0300 Message-Id: <20220902203940.2385967-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> References: <20220902203940.2385967-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, T_SCC_BODY_TEXT_LINE 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 Cc: Richard Henderson , Joseph Myers , caiyinyu 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 --- string/memcmp.c | 3 --- sysdeps/generic/memcopy.h | 4 +--- sysdeps/generic/string-opthr.h | 25 ++++++++++++++++++++++ sysdeps/i386/memcopy.h | 3 --- sysdeps/i386/string-opthr.h | 25 ++++++++++++++++++++++ sysdeps/m68k/memcopy.h | 3 --- sysdeps/powerpc/powerpc32/power4/memcopy.h | 5 ----- 7 files changed, 51 insertions(+), 17 deletions(-) create mode 100644 sysdeps/generic/string-opthr.h create mode 100644 sysdeps/i386/string-opthr.h diff --git a/string/memcmp.c b/string/memcmp.c index 6a9ceb8ac3..7c4606c2d0 100644 --- a/string/memcmp.c +++ b/string/memcmp.c @@ -48,9 +48,6 @@ and store. Must be an unsigned type. */ # define OPSIZ (sizeof (op_t)) -/* Threshold value for when to enter the unrolled loops. */ -# define OP_T_THRES 16 - /* Type to use for unaligned operations. */ typedef unsigned char byte; diff --git a/sysdeps/generic/memcopy.h b/sysdeps/generic/memcopy.h index efe5f2475d..a6baa4dfbb 100644 --- a/sysdeps/generic/memcopy.h +++ b/sysdeps/generic/memcopy.h @@ -57,6 +57,7 @@ /* Type to use for aligned memory operations. */ #include +#include #define OPSIZ (sizeof (op_t)) /* Type to use for unaligned operations. */ @@ -188,9 +189,6 @@ extern void _wordcopy_bwd_dest_aligned (long int, long int, size_t) #endif -/* Threshold value for when to enter the unrolled loops. */ -#define OP_T_THRES 16 - /* Set to 1 if memcpy is safe to use for forward-copying memmove with overlapping addresses. This is 0 by default because memcpy implementations are generally not safe for overlapping addresses. */ diff --git a/sysdeps/generic/string-opthr.h b/sysdeps/generic/string-opthr.h new file mode 100644 index 0000000000..eabd9fd669 --- /dev/null +++ b/sysdeps/generic/string-opthr.h @@ -0,0 +1,25 @@ +/* Define a threshold for word access. Generic version. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_OPTHR_H +#define _STRING_OPTHR_H 1 + +/* Threshold value for when to enter the unrolled loops. */ +#define OP_T_THRES 16 + +#endif /* string-opthr.h */ diff --git a/sysdeps/i386/memcopy.h b/sysdeps/i386/memcopy.h index 8cbf182096..66f5665f82 100644 --- a/sysdeps/i386/memcopy.h +++ b/sysdeps/i386/memcopy.h @@ -18,9 +18,6 @@ #include -#undef OP_T_THRES -#define OP_T_THRES 8 - #undef BYTE_COPY_FWD #define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \ do { \ diff --git a/sysdeps/i386/string-opthr.h b/sysdeps/i386/string-opthr.h new file mode 100644 index 0000000000..ed3e4b2ddb --- /dev/null +++ b/sysdeps/i386/string-opthr.h @@ -0,0 +1,25 @@ +/* Define a threshold for word access. i386 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef I386_STRING_OPTHR_H +#define I386_STRING_OPTHR_H 1 + +/* Threshold value for when to enter the unrolled loops. */ +#define OP_T_THRES 8 + +#endif /* I386_STRING_OPTHR_H */ diff --git a/sysdeps/m68k/memcopy.h b/sysdeps/m68k/memcopy.h index cf147f2c4a..3777baac21 100644 --- a/sysdeps/m68k/memcopy.h +++ b/sysdeps/m68k/memcopy.h @@ -20,9 +20,6 @@ #if defined(__mc68020__) || defined(mc68020) -#undef OP_T_THRES -#define OP_T_THRES 16 - /* WORD_COPY_FWD and WORD_COPY_BWD are not symmetric on the 68020, because of its weird instruction overlap characteristics. */ diff --git a/sysdeps/powerpc/powerpc32/power4/memcopy.h b/sysdeps/powerpc/powerpc32/power4/memcopy.h index a98f6662d8..d27caa2277 100644 --- a/sysdeps/powerpc/powerpc32/power4/memcopy.h +++ b/sysdeps/powerpc/powerpc32/power4/memcopy.h @@ -50,11 +50,6 @@ [I fail to understand. I feel stupid. --roland] */ - -/* Threshold value for when to enter the unrolled loops. */ -#undef OP_T_THRES -#define OP_T_THRES 16 - /* Copy exactly NBYTES bytes from SRC_BP to DST_BP, without any assumptions about alignment of the pointers. */ #undef BYTE_COPY_FWD From patchwork Fri Sep 2 20:39:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 602183 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1790028mae; Fri, 2 Sep 2022 13:41:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR4pB/jRTngBrR1dnVZN5HgrmmrgYlfEG02JqF0fe/RNmhkVPWePnrI0DUjWJ7h3y1Ch+jFy X-Received: by 2002:a17:906:3fc3:b0:750:5e2b:ff1b with SMTP id k3-20020a1709063fc300b007505e2bff1bmr3530993ejj.233.1662151293547; Fri, 02 Sep 2022 13:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662151293; cv=none; d=google.com; s=arc-20160816; b=vOk3fC/LM4N09QBdL4uZMVRk2JwXM0FiIFMtOetdjEixF7VJheVm4f2QC6vTpym/fL frCewnm06zCd68lbkEaQJCdRASwprOajrIeFZo4H3L8d0KjBhL+x6c0kFxIlbQMbWkLj 2voEDvq9zBuiLTEZ2zSaOsciFYZnQWy0JOaytKB0ju2kdnsakD7fmjGEmGsI0DC1jedV xiT3dsiVcsRQtF2JZonAffGqLISdhFP2k9yAF+wob9+xa4i3E3IJBF5nxFqyO65MJcdd zHL8LpQ+mwdSTVKVj0OQDL3jW5av+QczBadb9Z6086tbAWMWMP0hqHvHyQuIwtIxiOKq iwZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=yaswVVzodwomNg7OJoqsjfX9xQUObSy00raw0PfY2Ys=; b=hN0o5cPGf4zIG+Vz1Qt7C4nbfucnwiiWsc7kH0+XP8zwEQeFTYt11z+7O0UD+fYhcm w3dnA5QAEeXfiZm/c642N/ycuB/drg9LZKsWpmRIuh8M8EUkVBdoOAvnKyMVFh5G73tu Ufj8LB0IaTG29GcVpfLiCfo/P4y7BMeMWVXmrWQqMAsfO81+RTd/ZOjXhHpMh+xOKBfG iFgWdTAzn0KZkVfCcxYcnEg5RyuACWWtl2U/pKNXTtGZzPQ0gWsABf18GESnWsCbwGxK 53Kh2AcdxQGl43rmH94xkldowQ50C+uBXghjVW0mt0b06aueZ0O1zfP4OK7X2dO1vzuA 3QBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=MYk3h2p+; 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 v11-20020a1709067d8b00b00741521e9a3esi2393780ejo.235.2022.09.02.13.41.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:41:33 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=MYk3h2p+; 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 455293884F0C for ; Fri, 2 Sep 2022 20:41:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 455293884F0C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662151292; bh=yaswVVzodwomNg7OJoqsjfX9xQUObSy00raw0PfY2Ys=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=MYk3h2p+4dXFII3w+KR9kxdfE5GaUFL2qylDAI9BrnWmDnko2W3SbYR8+qgdf2SqQ XgDZJ03CPpY9vLJ8Epvrb+Iq3W0hrz0IlU8TulMayyipI/K+kXdOfwI6hYqNe1zBNL DXqif/trv8xM3QNwW3JZOW5QtKADYgF5/0Q+aAQs= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x31.google.com (mail-oa1-x31.google.com [IPv6:2001:4860:4864:20::31]) by sourceware.org (Postfix) with ESMTPS id 148B13857349 for ; Fri, 2 Sep 2022 20:40:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 148B13857349 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11ee4649dfcso7673160fac.1 for ; Fri, 02 Sep 2022 13:40:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=yaswVVzodwomNg7OJoqsjfX9xQUObSy00raw0PfY2Ys=; b=I6o5dG6UK3BDXN+v3FmePCn3bx2r58gOFlKhPXhU4dPmnHj7loySPNFLnonNSI9eiE 9aiq9/20Le1SOhAM8PCcIocY1BMORVLTu4wmzsai4DRQXkiKsDHNcRaS7PlV/87L2wZX wLueYsKr1qDGyOigoDynjHAY5fAD4RfGRK6kG3cK/o47LoYbbmjKWmswJ3IYmDw7HlqT w6JqhH2nH+J/lF0DN/NEquqeQ65sUvQH0rnBEt/4pF6sGNqjsgTnoVHqyiAaHnMJeN+D cMEd73K0zlrvzFnMgXI4aQuWyyGPCdzFbi4V8sVvelJ1/hYJH3vTR4XuryiiDS55Xl9f Odsg== X-Gm-Message-State: ACgBeo3bHOX+HVKJ4moHz8dgUmDbJUwf+yzB8DtW2mksEB5Lf0b4jjSo NIzhpsk628RmfLOvacyFZF0R2hHLe5IjrA== X-Received: by 2002:a05:6870:b00f:b0:11f:b1e:6142 with SMTP id y15-20020a056870b00f00b0011f0b1e6142mr3077773oae.234.1662151205632; Fri, 02 Sep 2022 13:40:05 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:dfed:72d1:946c:4eb1:ce5f]) by smtp.gmail.com with ESMTPSA id i27-20020a4a6f5b000000b00425678b9c4bsm1107902oof.0.2022.09.02.13.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:05 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 12/17] hppa: Add memcopy.h Date: Fri, 2 Sep 2022 17:39:35 -0300 Message-Id: <20220902203940.2385967-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> References: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 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, T_SCC_BODY_TEXT_LINE 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 Cc: Richard Henderson , Joseph Myers , caiyinyu Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson GCC's combine pass cannot merge (x >> c | y << (32 - c)) into a double-word shift unless (1) the subtract is in the same basic block and (2) the result of the subtract is used exactly once. Neither condition is true for any use of MERGE. By forcing the use of a double-word shift, we not only reduce contention on SAR, but also allow the setting of SAR to be hoisted outside of a loop. Checked on hppa-linux-gnu. --- sysdeps/hppa/memcopy.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 sysdeps/hppa/memcopy.h diff --git a/sysdeps/hppa/memcopy.h b/sysdeps/hppa/memcopy.h new file mode 100644 index 0000000000..288b5e9520 --- /dev/null +++ b/sysdeps/hppa/memcopy.h @@ -0,0 +1,42 @@ +/* Definitions for memory copy functions, PA-RISC version. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library. If not, see + . */ + +#include + +/* Use a single double-word shift instead of two shifts and an ior. + If the uses of MERGE were close to the computation of shl/shr, + the compiler might have been able to create this itself. + But instead that computation is well separated. + + Using an inline function instead of a macro is the easiest way + to ensure that the types are correct. */ + +#undef MERGE + +static inline op_t +MERGE (op_t w0, int shl, op_t w1, int shr) +{ + _Static_assert (OPSIZ == 4 || OPSIZ == 8, "Invalid OPSIZE"); + + op_t res; + if (OPSIZ == 4) + asm ("shrpw %1,%2,%%sar,%0" : "=r"(res) : "r"(w0), "r"(w1), "q"(shr)); + else if (OPSIZ == 8) + asm ("shrpd %1,%2,%%sar,%0" : "=r"(res) : "r"(w0), "r"(w1), "q"(shr)); + return res; +} From patchwork Fri Sep 2 20:39:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 602186 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1791334mae; Fri, 2 Sep 2022 13:43:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR4kuzAZ3rhu87QOlK1EmGaZd8q+Zsd9zFZUz4are4KYPTT0NxAUgnVq8fFyVsTRHWPPyS4m X-Received: by 2002:a17:906:ee8e:b0:730:3646:d178 with SMTP id wt14-20020a170906ee8e00b007303646d178mr29141936ejb.426.1662151432216; Fri, 02 Sep 2022 13:43:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662151432; cv=none; d=google.com; s=arc-20160816; b=aLHmw1CWqBrzTZboydNw5gfFPf9hcyTH4KxYwsO5JdhxsbhRnPWYIaJlDJHwkKoOnW BLU18+L7aTkxT9hlpU0/A8SE3FEJjOqO6+LetxH8Pgzep0ZmmaZeU/22yxf/73Cuy1f7 KvgMYY0o769J/P+IWtX7cA5Hm8ta9r/2Nf9yEjuK203HsNp2oVP2YbXw+in9IoWlxhC/ /E+Nof5Ic4lrCh6P1VcTiaw2uI4TYVr1FWtuwdwYMICylf6st5brD6yNHqDriZzT3aCi 2Cu0vrrGxHn9WNL5mPnLn5M3w+L7Bvfc4UYUy0QfwdbPS53or2FGgQPvNGjRozhOqdOP hcFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=sDu6dXCh51vSXKzuam85YiH4DXB+TeTXnosOsjvQ8vg=; b=FaJXlK7Tib/DTrWRWHEplxECxa81aGb0qPTyUnZx5G1iatXIb7xSzp+KA/Q55K5WDR wYUWoqNP+iEmJAc0c2QqS+n0hsTQQcEXoWsT5xDZIuc/lPsb1MSiyrmE7hfkZQTTZDNY IXYhYv9TOSesezMMCzSt8yp0lyGqLz0CoZUpcqMpaTayXkl8m4fB40o0Qrvmi/YeYPm5 yHWTll/6AaUssDWO0UcBswYTQIWduLOgfVV20eur96eZs7KMRWvdbUgj8QZsPlCApaYu fROHjwZOTVFnEADupu9ljtfSTO25nu0OKD/ib5b4urMFv9/m8Cu+vAP2Ix3DaRjA63Ge 5GYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=i2+Cvdvb; 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 dm16-20020a170907949000b0074152543c0esi936045ejc.725.2022.09.02.13.43.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:43:52 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=i2+Cvdvb; 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 C832838327C9 for ; Fri, 2 Sep 2022 20:43:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C832838327C9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662151430; bh=sDu6dXCh51vSXKzuam85YiH4DXB+TeTXnosOsjvQ8vg=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=i2+CvdvbsvUdkrkxMC8I/zA+snJw23BMHc4nlJMYd6yjtvuw0SxZk0DiOS8YrGnBh HcIzRTZQMsITLA1+cvENKevGQfL1hELoBGLNqIAB1PGGwW2gCMO4hpnsk28NR+wOFV qj5AjqxuWsrrp4+cwpABZcb8/ZBBoXBdgT7lhczc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by sourceware.org (Postfix) with ESMTPS id 11DBC38582A1 for ; Fri, 2 Sep 2022 20:40:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 11DBC38582A1 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-11eb44f520dso7565741fac.10 for ; Fri, 02 Sep 2022 13:40:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=sDu6dXCh51vSXKzuam85YiH4DXB+TeTXnosOsjvQ8vg=; b=yv+QPPLSzrc4q0QH0ZggPmh4t5kpgC2zeBdpCKDWFnbNPQu4Rx8aou7whH1jVBSX0i spmcSfsrnAkUbmwk3+4YR/HG8pvybbuEB7m4FmHwg8wc4nAvcaY04h1+w5YmjfGbQpXH a3Qak3FUNR/uLXimYBXh7iy9SVaJBed5w7UUoezxAyYhEkYJOLH5ieYwrV8vs5+u6reg +xPMmF4ahlgeibmVEI6g0lPv8pIAw6yvcBISXNmG88kRm/L2IhtFIhLpLAoDJWDm8CnF HJ7au+h5rMq2o+t301eXua4pWPqU5haSBRxveuR336692cMAkYYALJqrUW0hhuIFihQD 0n4g== X-Gm-Message-State: ACgBeo3zagA2tdSdIPvi3jPldMBBihCAG0awfs6KgmAU0ui2s+6L1+Sj igQXhf3lZR4kcXXOqeqyeAdS2Z1wJbTqDw== X-Received: by 2002:a05:6870:799:b0:11b:b0d4:81dd with SMTP id en25-20020a056870079900b0011bb0d481ddmr2980916oab.138.1662151207191; Fri, 02 Sep 2022 13:40:07 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:dfed:72d1:946c:4eb1:ce5f]) by smtp.gmail.com with ESMTPSA id i27-20020a4a6f5b000000b00425678b9c4bsm1107902oof.0.2022.09.02.13.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:07 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 13/17] hppa: Add string-fzb.h and string-fzi.h Date: Fri, 2 Sep 2022 17:39:36 -0300 Message-Id: <20220902203940.2385967-14-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> References: <20220902203940.2385967-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, T_SCC_BODY_TEXT_LINE 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 Cc: Richard Henderson , Joseph Myers , caiyinyu Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson Use UXOR,SBZ to test for a zero byte within a word. While we can get semi-decent code out of asm-goto, we would do slightly better with a compiler builtin. For index_zero et al, sequential testing of bytes is less expensive than any tricks that involve a count-leading-zeros insn that we don't have. Checked on hppa-linux-gnu. --- sysdeps/hppa/string-fzb.h | 69 +++++++++++++++++++ sysdeps/hppa/string-fzi.h | 135 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 sysdeps/hppa/string-fzb.h create mode 100644 sysdeps/hppa/string-fzi.h diff --git a/sysdeps/hppa/string-fzb.h b/sysdeps/hppa/string-fzb.h new file mode 100644 index 0000000000..dc02757522 --- /dev/null +++ b/sysdeps/hppa/string-fzb.h @@ -0,0 +1,69 @@ +/* Zero byte detection, boolean. HPPA version. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_FZB_H +#define _STRING_FZB_H 1 + +#include + +/* Determine if any byte within X is zero. This is a pure boolean test. */ + +static inline _Bool +has_zero (op_t x) +{ + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* It's more useful to expose a control transfer to the compiler + than to expose a proper boolean result. */ + asm goto ("uxor,sbz %%r0,%0,%%r0\n\t" + "b,n %l1" : : "r"(x) : : nbz); + return 1; + nbz: + return 0; +} + +/* Likewise, but for byte equality between X1 and X2. */ + +static inline _Bool +has_eq (op_t x1, op_t x2) +{ + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + asm goto ("uxor,sbz %0,%1,%%r0\n\t" + "b,n %l2" : : "r"(x1), "r"(x2) : : nbz); + return 1; + nbz: + return 0; +} + +/* Likewise, but for zeros in X1 and equal bytes between X1 and X2. */ + +static inline _Bool +has_zero_eq (op_t x1, op_t x2) +{ + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + asm goto ("uxor,sbz %%r0,%0,%%r0\n\t" + "uxor,nbz %0,%1,%%r0\n\t" + "b,n %l2" : : "r"(x1), "r"(x2) : : sbz); + return 0; + sbz: + return 1; +} + +#endif /* _STRING_FZB_H */ diff --git a/sysdeps/hppa/string-fzi.h b/sysdeps/hppa/string-fzi.h new file mode 100644 index 0000000000..2b8747ddbd --- /dev/null +++ b/sysdeps/hppa/string-fzi.h @@ -0,0 +1,135 @@ +/* string-fzi.h -- zero byte detection; indexes. HPPA version. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_FZI_H +#define _STRING_FZI_H 1 + +#include + +/* Given a word X that is known to contain a zero byte, return the + index of the first such within the long in memory order. */ + +static inline unsigned int +index_first_zero (op_t x) +{ + unsigned int ret; + + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* Since we have no clz insn, direct tests of the bytes is faster + than loading up the constants to do the masking. */ + asm ("extrw,u,<> %1,23,8,%%r0\n\t" + "ldi 2,%0\n\t" + "extrw,u,<> %1,15,8,%%r0\n\t" + "ldi 1,%0\n\t" + "extrw,u,<> %1,7,8,%%r0\n\t" + "ldi 0,%0" + : "=r"(ret) : "r"(x), "0"(3)); + + return ret; +} + +/* Similarly, but perform the search for byte equality between X1 and X2. */ + +static inline unsigned int +index_first_eq (op_t x1, op_t x2) +{ + return index_first_zero (x1 ^ x2); +} + +/* Similarly, but perform the search for zero within X1 or + equality between X1 and X2. */ + +static inline unsigned int +index_first_zero_eq (op_t x1, op_t x2) +{ + unsigned int ret; + + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* Since we have no clz insn, direct tests of the bytes is faster + than loading up the constants to do the masking. */ + asm ("extrw,u,= %1,23,8,%%r0\n\t" + "extrw,u,<> %2,23,8,%%r0\n\t" + "ldi 2,%0\n\t" + "extrw,u,= %1,15,8,%%r0\n\t" + "extrw,u,<> %2,15,8,%%r0\n\t" + "ldi 1,%0\n\t" + "extrw,u,= %1,7,8,%%r0\n\t" + "extrw,u,<> %2,7,8,%%r0\n\t" + "ldi 0,%0" + : "=r"(ret) : "r"(x1), "r"(x1 ^ x2), "0"(3)); + + return ret; +} + +/* Similarly, but perform the search for zero within X1 or + inequality between X1 and X2. */ + +static inline unsigned int +index_first_zero_ne (op_t x1, op_t x2) +{ + unsigned int ret; + + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* Since we have no clz insn, direct tests of the bytes is faster + than loading up the constants to do the masking. */ + asm ("extrw,u,<> %2,23,8,%%r0\n\t" + "extrw,u,<> %1,23,8,%%r0\n\t" + "ldi 2,%0\n\t" + "extrw,u,<> %2,15,8,%%r0\n\t" + "extrw,u,<> %1,15,8,%%r0\n\t" + "ldi 1,%0\n\t" + "extrw,u,<> %2,7,8,%%r0\n\t" + "extrw,u,<> %1,7,8,%%r0\n\t" + "ldi 0,%0" + : "=r"(ret) : "r"(x1), "r"(x1 ^ x2), "0"(3)); + + return ret; +} + +/* Similarly, but search for the last zero within X. */ + +static inline unsigned int +index_last_zero (op_t x) +{ + unsigned int ret; + + _Static_assert (sizeof (op_t) == 4, "64-bit not supported"); + + /* Since we have no ctz insn, direct tests of the bytes is faster + than loading up the constants to do the masking. */ + asm ("extrw,u,<> %1,15,8,%%r0\n\t" + "ldi 1,%0\n\t" + "extrw,u,<> %1,23,8,%%r0\n\t" + "ldi 2,%0\n\t" + "extrw,u,<> %1,31,8,%%r0\n\t" + "ldi 3,%0" + : "=r"(ret) : "r"(x), "0"(0)); + + return ret; +} + +static inline unsigned int +index_last_eq (op_t x1, op_t x2) +{ + return index_last_zero (x1 ^ x2); +} + +#endif /* _STRING_FZI_H */ From patchwork Fri Sep 2 20:39:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 602184 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1790415mae; Fri, 2 Sep 2022 13:42:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR5AV6uMDiMeCFxuB8cia1ttGIq2g0gbbyZUsozKYy3vVV8U7UiuKPkqCeem7LPs5d7K7e1P X-Received: by 2002:a17:907:2c41:b0:741:4906:482b with SMTP id hf1-20020a1709072c4100b007414906482bmr21351676ejc.239.1662151335794; Fri, 02 Sep 2022 13:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662151335; cv=none; d=google.com; s=arc-20160816; b=hEPyMwkYVxykUWhERo5wdlWCXjzt9C4kveAjlLnWn45C2NFQIM+FSeyEfRV3jYzPw1 KYN+QoZpn8w9fF/kuDqWbS8qOlZ4Y3z2AnIgPaiOEFsUmaapUh7WPQeN0qYea8gZQLAp d401m1vvlxV1sQB6aDWjwHuBqNZXQv3RrY9rKftumfeEOQIwdA7d0d1AnJXPMo4GTv89 tMzL4VUdWpuwHKY+lY99vmLOZtes/gOcc6ozftwqTBmP09Td6zgj5UJf6eET80YIBWcH u3PIweCIWF7Mj9mtAquJkEZiyzVKqSCIPn5mi8VC5/Zfv6UArED03nJRVyN0XbgqDAnD lReA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=VPl5idg7nmu4rl+u9SzggIv0yZg5ORisPUXbpJXo8Kk=; b=vPRUSHfH1vIvu3cWBvSFJNDWEd/pGX3vjIGAHXMhE1y9zMRc0LHhkV5JvsFLZ3nbhz +KyeT2aJEfW/iUlTdCtakGN3QxPNrwYJQpCW4FdiWsIjZ3uVKeRA6cufytrRJ82aMFfU NuLsTX9jQCzTyd72wxRC7gW4vcWQ3yVA0Z91PMmBjSURwG5AWeNeJJ0PXlc8es95+oWX S1Zvmh8JTOR+8DDI+HpQ1L0Fk7gOZdJMASeerhx2GgRfXlj+fFHHCCEGjJWgiGRJwC5+ ewXOrO37ARFyof1ClTVUwNxUbRP/u/1RzsJXkCIJbjw0pXhWLmoHk4F7UO+Po7d5pjdb 8VXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=TUjeHDYa; 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 dn21-20020a17090794d500b0072b4adf5c0fsi2738724ejc.77.2022.09.02.13.42.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:42:15 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=TUjeHDYa; 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 82CC7385140A for ; Fri, 2 Sep 2022 20:42:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82CC7385140A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662151334; bh=VPl5idg7nmu4rl+u9SzggIv0yZg5ORisPUXbpJXo8Kk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=TUjeHDYaUsKMuzj3XgkFIrxedetKZnRtBNIld+0tz3AniD6ThU+f90bA61mS8WI7X 2BpkhHM6iYDGh3yAIMkX6riAecLmaxHFDKySPXISHD8XMuOtTQn6Rnmk5h3QvYROAz M15/han97i9SH5Lt2RjNL87Fad2+PXuqFXYCp7RU= 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 CDC5E3857BAE for ; Fri, 2 Sep 2022 20:40:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CDC5E3857BAE Received: by mail-ot1-x334.google.com with SMTP id y25-20020a056830109900b0063b3c1fe018so2237195oto.2 for ; Fri, 02 Sep 2022 13:40:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=VPl5idg7nmu4rl+u9SzggIv0yZg5ORisPUXbpJXo8Kk=; b=RuLXYugTC5hlf633OaMTD7tho467bhAmnEEZJuUI0zIS5RLyCmSeoufxMjvXl6P7pl ECB7qHWrG3H52d204juUl0BJCaIPqQ9zwJlpDa8zOh74qHYuabG3k4QJqxfxliz3CLPh YQlN5E5d3dWXvw39fby0Ji1vLJjuL8omiT+eb4LBNbp7oDbOn6TPSl8F/ZUNHqj6nJpS uiteW9cnRnHqkELoVvS4uTculfk7VCpPeJ37+D+1xcS2e6Ahk1E8SkjYl1t2Kv6WuIcf iQxooccsP/JbRkIpmoOt0LitxJusCuiWMIV95zgeRIQK/BwxEiJPyRZbjbqIR8rUE/5R 0Tlg== X-Gm-Message-State: ACgBeo1hkoaNc9ueDcpMPlhvTQFIezw52j4EAQD4WYythBjYj21Mgh1O ib2O+sEQCFBO+ZYh9C1hjGItFafNIGeOAA== X-Received: by 2002:a05:6830:d0f:b0:63b:439d:3631 with SMTP id bu15-20020a0568300d0f00b0063b439d3631mr6338951otb.2.1662151208765; Fri, 02 Sep 2022 13:40:08 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:dfed:72d1:946c:4eb1:ce5f]) by smtp.gmail.com with ESMTPSA id i27-20020a4a6f5b000000b00425678b9c4bsm1107902oof.0.2022.09.02.13.40.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:08 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 14/17] alpha: Add string-fzb.h and string-fzi.h Date: Fri, 2 Sep 2022 17:39:37 -0300 Message-Id: <20220902203940.2385967-15-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> References: <20220902203940.2385967-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, T_SCC_BODY_TEXT_LINE 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 Cc: Richard Henderson , Joseph Myers , caiyinyu Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While alpha has the more important string functions in assembly, there are still a few for find the generic routines are used. Use the CMPBGE insn, via the builtin, for testing of zeros. Use a simplified expansion of __builtin_ctz when the insn isn't available. Checked on alpha-linux-gnu. --- sysdeps/alpha/string-fzb.h | 51 +++++++++++++++++ sysdeps/alpha/string-fzi.h | 113 +++++++++++++++++++++++++++++++++++++ 2 files changed, 164 insertions(+) create mode 100644 sysdeps/alpha/string-fzb.h create mode 100644 sysdeps/alpha/string-fzi.h diff --git a/sysdeps/alpha/string-fzb.h b/sysdeps/alpha/string-fzb.h new file mode 100644 index 0000000000..6b19a2106c --- /dev/null +++ b/sysdeps/alpha/string-fzb.h @@ -0,0 +1,51 @@ +/* Zero byte detection; boolean. Alpha version. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_FZB_H +#define _STRING_FZB_H 1 + +#include + +/* Note that since CMPBGE creates a bit mask rather than a byte mask, + we cannot simply provide a target-specific string-fza.h. */ + +/* Determine if any byte within X is zero. This is a pure boolean test. */ + +static inline _Bool +has_zero (op_t x) +{ + return __builtin_alpha_cmpbge (0, x) != 0; +} + +/* Likewise, but for byte equality between X1 and X2. */ + +static inline _Bool +has_eq (op_t x1, op_t x2) +{ + return has_zero (x1 ^ x2); +} + +/* Likewise, but for zeros in X1 and equal bytes between X1 and X2. */ + +static inline _Bool +has_zero_eq (op_t x1, op_t x2) +{ + return has_zero (x1) | has_eq (x1, x2); +} + +#endif /* _STRING_FZB_H */ diff --git a/sysdeps/alpha/string-fzi.h b/sysdeps/alpha/string-fzi.h new file mode 100644 index 0000000000..c1a4683590 --- /dev/null +++ b/sysdeps/alpha/string-fzi.h @@ -0,0 +1,113 @@ +/* string-fzi.h -- zero byte detection; indices. Alpha version. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_FZI_H +#define _STRING_FZI_H + +#include +#include + +/* Note that since CMPBGE creates a bit mask rather than a byte mask, + we cannot simply provide a target-specific string-fza.h. */ + +/* A subroutine for the index_zero functions. Given a bitmask C, + return the index of the first bit set in memory order. */ + +static inline unsigned int +index_first_ (unsigned long int c) +{ +#ifdef __alpha_cix__ + return __builtin_ctzl (c); +#else + c = c & -c; + return (c & 0xf0 ? 4 : 0) + (c & 0xcc ? 2 : 0) + (c & 0xaa ? 1 : 0); +#endif +} + +/* Similarly, but return the (memory order) index of the last bit + that is non-zero. Note that only the least 8 bits may be nonzero. */ + +static inline unsigned int +index_last_ (unsigned long int x) +{ +#ifdef __alpha_cix__ + return __builtin_clzl (x) ^ 63; +#else + unsigned r = 0; + if (x & 0xf0) + r += 4; + if (x & (0xc << r)) + r += 2; + if (x & (0x2 << r)) + r += 1; + return r; +#endif +} + +/* Given a word X that is known to contain a zero byte, return the + index of the first such within the word in memory order. */ + +static inline unsigned int +index_first_zero (op_t x) +{ + return index_first_ (__builtin_alpha_cmpbge (0, x)); +} + +/* Similarly, but perform the test for byte equality between X1 and X2. */ + +static inline unsigned int +index_first_eq (op_t x1, op_t x2) +{ + return index_first_zero (x1 ^ x2); +} + +/* Similarly, but perform the search for zero within X1 or + equality between X1 and X2. */ + +static inline unsigned int +index_first_zero_eq (op_t x1, op_t x2) +{ + return index_first_ (__builtin_alpha_cmpbge (0, x1) + | __builtin_alpha_cmpbge (0, x1 ^ x2)); +} + +/* Similarly, but perform the search for zero within X1 or + inequality between X1 and X2. */ + +static inline unsigned int +index_first_zero_ne (op_t x1, op_t x2) +{ + return index_first_ (__builtin_alpha_cmpbge (0, x1) + | (__builtin_alpha_cmpbge (0, x1 ^ x2) ^ 0xFF)); +} + +/* Similarly, but search for the last zero within X. */ + +static inline unsigned int +index_last_zero (op_t x) +{ + return index_last_ (__builtin_alpha_cmpbge (0, x)); +} + +static inline unsigned int +index_last_eq (op_t x1, op_t x2) +{ + return index_last_zero (x1 ^ x2); +} + +#endif /* _STRING_FZI_H */ From patchwork Fri Sep 2 20:39:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 602185 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1790851mae; Fri, 2 Sep 2022 13:42:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR4EvqnxnKi1dE0N3hOKP3l3e/Wue2AZgTiq3h/kGoMGj49H2FsQQzXnRNgWflM3DdoHxNNr X-Received: by 2002:aa7:d348:0:b0:447:d2b4:78fd with SMTP id m8-20020aa7d348000000b00447d2b478fdmr31652514edr.201.1662151377810; Fri, 02 Sep 2022 13:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662151377; cv=none; d=google.com; s=arc-20160816; b=xD+NzEJC3oEQ+8ZUdjNxtYqDJat1VUw0S3KQ/2EvPImIn/VOZFfzahgt4TbGuNR83A IXpcZcQE+EKqTY3tUllBx2HN/4chQPJoG7r8A2Codj4oG/7mz5sOVeA+c1mqRC6FCUYY flKjFsmAT+edGD623zUp9cf3JuaeA/C3a2flkkywT050LkuCAa9gbu/y5oiSYMWu9HFP WoG5+kWznNiHIZS40bMchdu1WIEzFrUnLqczZY28C8MABR1ojNL8OgqA7OzuTXUJlmaQ 1R1hmD8vZDKR560ZLcPx09vYRg/s9V4MEcP1iS1gh5QTkrBj2GHNbecMlsrgBJGGG5/7 1xOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; b=KgvXKoucXwBuiemKC4yQoGl0+Tm4aVqGI+sY/wGI1mjEDwiqIkGfYsmhYQzUF2D6Ge JFfbQUwZdlslhbRtkOsB0XwsY8Jqs6Kviz7CxsCvwyrqk9IOmNTLk0XlKYDHrAjrRkhD VjpqzafE5ah+w/gAoXyz7s49l1bSUqamsLlyvVf4BRBcZyd4ARYAjFuPBMMjP0WSbCXf /JwfZxjjgkI20zk0pS0OUm5XPDmqn0mO1o/pg4PNVhcrNuyBVW5ogPasEzsT9P9J8tD6 kgxIyq4y09x8egWYIBad5HNQWO3oMFimJxIsIGc0xIZE70GsqlA4SLBB9iXW9W3FcrZr GqEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qF7BMOMc; 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 eb8-20020a0564020d0800b0043e1c8af8c8si3046252edb.241.2022.09.02.13.42.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:42:57 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=qF7BMOMc; 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 88677382DA71 for ; Fri, 2 Sep 2022 20:42:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88677382DA71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662151376; bh=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=qF7BMOMcN+cvj0hrr+lAaJLZApn2knkwehv/VSjIAS1u2l6jqxRpbl8RIzC0/Rejs AbTifjn8dU8wSrw6wv2t1h7y5HfjW5Wz+fABWRX4hG0+NHJIJeK70m9tgfPMned/zA /k3K4xPYctGfs0R147jTcjobyYrjllyXAvwEbUWI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by sourceware.org (Postfix) with ESMTPS id 2E0DC3858016 for ; Fri, 2 Sep 2022 20:40:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E0DC3858016 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-11f4e634072so7509082fac.13 for ; Fri, 02 Sep 2022 13:40:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=cEX4mn9dD+zxUkAlo6G2AXMP/kIG2QGFgEBaPo+yW0A=; b=xhEHMY7m8tNgeJaeK2/Kn1ZBP6Z6Zq3XzV+QWAwGmdscLf1cyNu82dpHzepsaJAbRz DVIkqw30X4Qz9ykbOj6ykbbdJOxQEgzzkmJvqa/Nc6w9CQOXt7SHFcXN0BoPAy07RwfW zKBzQ5m8ifOUYVHqJFF0fHSCINp0dYt921j/oDFjozojka8Ag0nY/OwgrvLZKfX9fD2Q xtl1EvMJU8SPQ302ymyZ3sKhXtY/QWw5H+VqcSRHmv8EhYicHnuEGL8cNgae7H/fkmbD jKQP/Rnee8yWfygvN4iBfS/6Z3z3F9UZzzgpCKBOwRKiOl/o757f4LLosvvfqOUwCpal pCXg== X-Gm-Message-State: ACgBeo0XFTyuUdBPof+L3ygohz8bvWoLbbcuyY/9g5vOnbpjX6DgTLro 1IofhGAzTquWSF81WTzc1+oFreKbiK7CRg== X-Received: by 2002:a05:6870:79e:b0:101:48bf:7fa8 with SMTP id en30-20020a056870079e00b0010148bf7fa8mr3073469oab.291.1662151210377; Fri, 02 Sep 2022 13:40:10 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:dfed:72d1:946c:4eb1:ce5f]) by smtp.gmail.com with ESMTPSA id i27-20020a4a6f5b000000b00425678b9c4bsm1107902oof.0.2022.09.02.13.40.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:10 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 15/17] arm: Add string-fza.h Date: Fri, 2 Sep 2022 17:39:38 -0300 Message-Id: <20220902203940.2385967-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> References: <20220902203940.2385967-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, T_SCC_BODY_TEXT_LINE 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 Cc: Richard Henderson , Joseph Myers , caiyinyu Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While arm has the more important string functions in assembly, there are still a few generic routines used. Use the UQSUB8 insn for testing of zeros. Checked on armv7-linux-gnueabihf --- sysdeps/arm/armv6t2/string-fza.h | 70 ++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sysdeps/arm/armv6t2/string-fza.h diff --git a/sysdeps/arm/armv6t2/string-fza.h b/sysdeps/arm/armv6t2/string-fza.h new file mode 100644 index 0000000000..4fe2e8383f --- /dev/null +++ b/sysdeps/arm/armv6t2/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. ARM version. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _STRING_FZA_H +#define _STRING_FZA_H 1 + +#include +#include + +/* This function returns at least one bit set within every byte + of X that is zero. */ + +static inline op_t +find_zero_all (op_t x) +{ + /* Use unsigned saturated subtraction from 1 in each byte. + That leaves 1 for every byte that was zero. */ + op_t ret, ones = repeat_bytes (0x01); + asm ("uqsub8 %0,%1,%2" : "=r"(ret) : "r"(ones), "r"(x)); + return ret; +} + +/* Identify bytes that are equal between X1 and X2. */ + +static inline op_t +find_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or equality between X1 and X2. */ + +static inline op_t +find_zero_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or inequality between X1 and X2. */ + +static inline op_t +find_zero_ne_all (op_t x1, op_t x2) +{ + /* Make use of the fact that we'll already have ONES in a register. */ + op_t ones = repeat_bytes (0x01); + return find_zero_all (x1) | (find_zero_all (x1 ^ x2) ^ ones); +} + +/* Define the "inexact" versions in terms of the exact versions. */ +#define find_zero_low find_zero_all +#define find_eq_low find_eq_all +#define find_zero_eq_low find_zero_eq_all +#define find_zero_ne_low find_zero_ne_all + +#endif /* _STRING_FZA_H */ From patchwork Fri Sep 2 20:39:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 602187 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1791694mae; Fri, 2 Sep 2022 13:44:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR6XNVtpm4bdcplwg8ZVGH96CmZkQZYrvUX9Il9nlOBCpKB7MMgATffG3/kIZC8b/PeXFzDt X-Received: by 2002:a50:8e11:0:b0:447:cf39:10a1 with SMTP id 17-20020a508e11000000b00447cf3910a1mr32393921edw.382.1662151478297; Fri, 02 Sep 2022 13:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662151478; cv=none; d=google.com; s=arc-20160816; b=GC/IX0piL78NoMQtFiPoqhTB0zBH8dxan+44/0a1974d8O+bLJDBYYSsuuMtu7VgWa 93RKT0+hHvbI353/DWRbydidujKTNwt77VPCzHG3zPv/oe0pKLMaH6tXDpcCGM70K5r9 qF+9UepD+VxTzuhYnnFc3U7CkD3rZxNspVjz7t+bgHIctxKedOouCSFjfxabGRTVe5cw w1rBGSa6NOOqIUhoGdF15oCiu6aF2OGYUh3w1oL6GYXn3FlktEydtEi8wCX+JF6m9Fga jAgof5HTyyhxUNo4hC6sJqby3r4ynrIM01Z07MZpCo5G1IPSQrDFeNzUNcRepNN47OBw SGxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:dmarc-filter:delivered-to:dkim-signature :dkim-filter; bh=/uCRcF9qUCajChP7TLbUSNFzBkE0RzW5ftlKjiF8tuM=; b=Ovp9UBmgUwClUrORv3e1YHHUuc1MRQ7Ddr0SaXcWsX+T/g5Z8w3lfnPnQGGIC5Cswm 5AUcN8Iqsax6czrlhlcUuxBM1Tfu2m0ITwcs0ZWPtYR42/m9lKpzB2tbTgQct2Xc+3Wn MPgSV9av/xwQwkeNgOaeM/JSISZ8I9v1+KLekenAf3//wvnnIiMq0hUvklpDVDq2kZ+L Wx4n2XaduuETWLOoLZDtNBt2QddPkLxbxW03hbcq5U8YhHB9SOhk/D5KX5KQo6q9R3dd H6eC5cCCwKmv+t+kZREaW4NQygiy/c8gjU6GYR5i12tmsU7wpSCx0FPcFKqu4XPsHEgc 22hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=aO1XnfIV; spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Return-Path: Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y4-20020a170906558400b00741a05cb703si2363123ejp.534.2022.09.02.13.44.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:44:38 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=aO1XnfIV; 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 1929C382DB0E for ; Fri, 2 Sep 2022 20:44:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1929C382DB0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1662151477; bh=/uCRcF9qUCajChP7TLbUSNFzBkE0RzW5ftlKjiF8tuM=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=aO1XnfIVOLpf6A/OtWAv0bgqnpPDTOs+xmrMdGqc+ofLRf40cfuYm+Gr9aiFLchrY afUS0SIg+h8t5J+npwBHU7alL1sHqIF9o0TtSVunYeYiBiZldrLHQ/E1X5b6qOcxbG NspZX80QYVyeQq+ZfgkwPjelG9beyaPp2Bane8N0= 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 A5301385700C for ; Fri, 2 Sep 2022 20:40:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A5301385700C Received: by mail-ot1-x334.google.com with SMTP id 92-20020a9d0be5000000b0063946111607so2219221oth.10 for ; Fri, 02 Sep 2022 13:40:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=/uCRcF9qUCajChP7TLbUSNFzBkE0RzW5ftlKjiF8tuM=; b=xP24fhmsb2dEvpIv+Yj867BtwDtDz5c4wLpKnTNAcPLLfXeyqoR1akXKt7sK6dI5x7 b4XHHqs+69aOrQBE+8TxIyEyQ4NV4nxC8OOn4HS+9aTWu3cumZUNvlzLKe45yg7D0A2c 6+BaKp9oaCpWsUvyH248HQFZYIprIBoeGL7Jsdk68e3Kf272hxcOnGIu6E4DHaYIehdz B4jOz1h4rR1jszEufP8tPyUpF0zkzq9lUEgSHfeB9PYIySQUcPUVRJ897Zkg2AV/N8SQ cSVWjPocf8xLQQ5hvhq1XI6sQ5dEiM4J1CXep8sRvQv/PgwnMvdk0fXlCkO9KDDdxryU ep5g== X-Gm-Message-State: ACgBeo37tAbFC7jSLPmDZze6G2StDJQf82x1izrWbmIMxFCadlap/Hiy z+KYBbLSfEgXi9IlEH1EWenY7WGzJUT3og== X-Received: by 2002:a9d:d83:0:b0:639:c1a4:4d78 with SMTP id 3-20020a9d0d83000000b00639c1a44d78mr13344104ots.100.1662151211923; Fri, 02 Sep 2022 13:40:11 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:dfed:72d1:946c:4eb1:ce5f]) by smtp.gmail.com with ESMTPSA id i27-20020a4a6f5b000000b00425678b9c4bsm1107902oof.0.2022.09.02.13.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 13:40:11 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH 16/17] powerpc: Add string-fza.h Date: Fri, 2 Sep 2022 17:39:39 -0300 Message-Id: <20220902203940.2385967-17-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> References: <20220902203940.2385967-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, T_SCC_BODY_TEXT_LINE 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 Cc: Richard Henderson , Joseph Myers , caiyinyu Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org Sender: "Libc-alpha" From: Richard Henderson While ppc has the more important string functions in assembly, there are still a few generic routines used. Use the Power 6 CMPB insn for testing of zeros. Checked on powerpc64le-linux-gnu. --- sysdeps/powerpc/string-fza.h | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 sysdeps/powerpc/string-fza.h diff --git a/sysdeps/powerpc/string-fza.h b/sysdeps/powerpc/string-fza.h new file mode 100644 index 0000000000..5f7e9c5cbe --- /dev/null +++ b/sysdeps/powerpc/string-fza.h @@ -0,0 +1,70 @@ +/* Zero byte detection; basics. PowerPC version. + Copyright (C) 2022 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef POWERPC_STRING_FZA_H +#define POWERPC_STRING_FZA_H 1 + +/* PowerISA 2.03 (POWER6) provides cmpb instruction. */ +#ifdef _ARCH_PWR6 +# include + +/* This function returns 0xff for each byte that is + equal between X1 and X2. */ + +static inline op_t +find_eq_all (op_t x1, op_t x2) +{ + op_t ret; + asm ("cmpb %0,%1,%2" : "=r"(ret) : "r"(x1), "r"(x2)); + return ret; +} + +/* This function returns 0xff for each byte that is zero in X. */ + +static inline op_t +find_zero_all (op_t x) +{ + return find_eq_all (x, 0); +} + +/* Identify zero bytes in X1 or equality between X1 and X2. */ + +static inline op_t +find_zero_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | find_eq_all (x1, x2); +} + +/* Identify zero bytes in X1 or inequality between X1 and X2. */ + +static inline op_t +find_zero_ne_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | ~find_eq_all (x1, x2); +} + +/* Define the "inexact" versions in terms of the exact versions. */ +# define find_zero_low find_zero_all +# define find_eq_low find_eq_all +# define find_zero_eq_low find_zero_eq_all +# define find_zero_ne_low find_zero_ne_all +#else +# include +#endif /* _ARCH_PWR6 */ + +#endif /* STRING_FZA_H */