From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 765813850849 for ; Tue, 6 Sep 2022 14:48:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 765813850849 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 286EgDYS028432; Tue, 6 Sep 2022 14:48:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pp1; bh=moj7ftYLHh4Uih2kplMWsvyA8E2GdHHY2E0yZ8kMMbA=; b=n82F1BU7Tn8E9tLlRwaXskh0138HS0TI/Xi2WOEf70YiZ3Qjr8hpn1O2W7pwyxNyFeF7 dk+Nt38r5XdQQV5yA+JOrDPSpusbzWocNF/2gCr0mAVZN+boZ10/0SldBZTG4RrK6TMr gCb8fxSgUUi2IPHs2EkFV0SU3L4wWszyvLnQbl3PBYW/t2Z1GeC6CzMVh/o5euV/Pn6F rnA46qUZ9uh7RckbPG5WODF22QeZKb1WtbX6aVxV7EZ6bza3k/DH7hAkTSrMlf9nuna7 89L3fzjq1yH46ErS/V8E/V74TDz2FCZc7BhjbRWO567O270QIsYBPMJy12rh8F2HFDRv AA== Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3je86vrawf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 14:48:34 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 286EaVgP025187; Tue, 6 Sep 2022 14:48:33 GMT Received: from b03cxnp07028.gho.boulder.ibm.com (b03cxnp07028.gho.boulder.ibm.com [9.17.130.15]) by ppma02dal.us.ibm.com with ESMTP id 3jbxja92wa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 06 Sep 2022 14:48:33 +0000 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 286EmXqa53739804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Sep 2022 14:48:33 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 99E9A6E053; Tue, 6 Sep 2022 14:48:32 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F25326E052; Tue, 6 Sep 2022 14:48:31 +0000 (GMT) Received: from [9.160.64.165] (unknown [9.160.64.165]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Tue, 6 Sep 2022 14:48:31 +0000 (GMT) Message-ID: <496d9efc-6d13-7391-a70c-4a9b5ff18ed9@linux.ibm.com> Date: Tue, 6 Sep 2022 09:48:31 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 Subject: Re: [PATCH 16/17] powerpc: Add string-fza.h To: Adhemerval Zanella , libc-alpha@sourceware.org Cc: Richard Henderson , Joseph Myers , caiyinyu References: <20220902203940.2385967-1-adhemerval.zanella@linaro.org> <20220902203940.2385967-17-adhemerval.zanella@linaro.org> Content-Language: en-US From: Paul E Murphy In-Reply-To: <20220902203940.2385967-17-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed X-TM-AS-GCONF: 00 X-Proofpoint-GUID: cNfEKL1aYLoZGVb_hIm3wYURwTgnaeRd X-Proofpoint-ORIG-GUID: cNfEKL1aYLoZGVb_hIm3wYURwTgnaeRd Content-Transfer-Encoding: 7bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-06_07,2022-09-06_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 malwarescore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 phishscore=0 mlxscore=0 spamscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2207270000 definitions=main-2209060070 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,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 List-Id: On 9/2/22 3:39 PM, Adhemerval Zanella via Libc-alpha wrote: > 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. */ Should this read "PowerISA 2.05"? cmpb is listed as implemented from v2.05 in ISA 3.1. > +#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)); Is it possible to use the gcc builtin __builtin_cmpb? Otherwise, LGTM. > + 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 *