From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 40A483858C2B for ; Thu, 24 Aug 2023 19:44:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40A483858C2B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1bc83a96067so2455385ad.0 for ; Thu, 24 Aug 2023 12:44:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692906255; x=1693511055; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=YKuTc/pz4dQLmb6n9p1W2daC2Z1Po2q9E8bPmZeK41o=; b=XrBr67TlzgDI5tGBhjjLfIxmPNOSQCSN08c4KxXw1cv9XmuoTXp1AdQICTohPOfWrK lDcmocVL2WNJ3N4cavDXYPr5Th3PkOXqCu8EsyTk2AB7cCtssyCULhpCwYtxMpZrSJPJ Ozzc+TwAVh49Palkqx1Hv0dh5sxD3lCkGsMoM74f7uL2PTORo10K1+RqykBf6d4LmH4z RN1HuPqm7AqUPGC6DkBi2CI3y9vV4Cx4lijJ/IKuCZc2pf+iRBTJrB/4foBaX9FKgoTm Hjgv5gO/I7MUE5uttMvQBEcJt3MjkujhZA/lolcp450XqeFHsODh08ZLDuWdVpSSJK+F cDFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692906255; x=1693511055; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=YKuTc/pz4dQLmb6n9p1W2daC2Z1Po2q9E8bPmZeK41o=; b=IE8Xlq3TwEvjqoNUFyzTCU9CJ+0/xaeSb5HAubkVDGo+pEy5UlK7aqPcqV4Wj1YEux oPu6aR4JsjY1Hvq56ek0hTf8cWxAELbThro98eRMObn7I5YR3/PFJgtMM1rxmu5+bMEp Lh/vage/Kpp1pqDswi4USElE8As2X3grC/JD95mFMwKMJQtSOlP4HosOrLKadED84P3R QOmi/a0WlXl8/mWL3d5kur8czairoa5UkHYGbv5U0agNQKhI+R/wXdswBMOVt/y5ycNM c4Ov2Wm7eM4n+jXS3zeCQrueQCs8dSeiK8tx6WDwgHpoCTFqE7q/EFK/6vw/GlU43pwu uAGg== X-Gm-Message-State: AOJu0Yytd45GKkZd9GctMK+ydghApWSJjTWlFsssd8gIGKat3GIlIOMV Z8DW9vDcRMq8hJSVxhQNH1U8pJ5yHMZgZOOnwoY= X-Google-Smtp-Source: AGHT+IEnnjqqB84u5M3HWLV0G6qZbpKWQDISeLCv+yercq26eqcg8DayzinJ6lxkPnf8HJpLG9tA1Q== X-Received: by 2002:a17:902:eb45:b0:1b8:9552:ca with SMTP id i5-20020a170902eb4500b001b8955200camr14590243pli.45.1692906255159; Thu, 24 Aug 2023 12:44:15 -0700 (PDT) Received: from ?IPV6:2602:47:d483:7301:5418:3064:bd46:c048? ([2602:47:d483:7301:5418:3064:bd46:c048]) by smtp.gmail.com with ESMTPSA id jk19-20020a170903331300b001b5247cac3dsm36245plb.110.2023.08.24.12.44.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Aug 2023 12:44:14 -0700 (PDT) Message-ID: <38c1d139-3a56-8593-1050-f2516b83d9a0@linaro.org> Date: Thu, 24 Aug 2023 12:44:12 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2] string: Use builtins for ffs and ffsll Content-Language: en-US To: Adhemerval Zanella , libc-alpha@sourceware.org References: <20230824171333.1032744-1-adhemerval.zanella@linaro.org> From: Richard Henderson In-Reply-To: <20230824171333.1032744-1-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,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 List-Id: On 8/24/23 10:13, Adhemerval Zanella via Libc-alpha wrote: > diff --git a/string/ffsll.c b/string/ffsll.c > index 0cc461a1cf..2315fe1bd7 100644 > --- a/string/ffsll.c > +++ b/string/ffsll.c > @@ -18,20 +18,26 @@ > #include > #define ffsl __something_else > #include > - > #undef ffsll > +#include > +#include > > /* Find the first bit set in I. */ > int > -ffsll (long long int i) > +__ffsll (long long int i) > { > +#if USE_FFSLL_BUILTIN > + return __builtin_ffsll (i); > +#else > unsigned long long int x = i & -i; > > if (x <= 0xffffffff) > return ffs (i); > else > return 32 + ffs (i >> 32); > +#endif > } It seems like you also need #if USE_FFS_BUILTIN # define ffs __builtin_ffs #endif in order to avoid a function call for the 32-bit host case, e.g. > diff --git a/sysdeps/arm/armv6t2/ffsll.S b/sysdeps/arm/armv6t2/ffsll.S > deleted file mode 100644 > index bc3cbf81b0..0000000000 > --- a/sysdeps/arm/armv6t2/ffsll.S > +++ /dev/null > @@ -1,50 +0,0 @@ > -/* ffsll -- find first set bit in a long long, from least significant end. > - Copyright (C) 2013-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 > - > - .syntax unified > - .text > - > -ENTRY (ffsll) > - @ If low part is 0, operate on the high part. Ensure that the > - @ word on which we operate is in r0. Set r2 to the bit offset > - @ of the word being considered. Set the flags for the word > - @ being operated on. > -#ifdef __ARMEL__ > - cmp r0, #0 > - itee ne > - movne r2, #0 > - moveq r2, #32 > - movseq r0, r1 > -#else > - cmp r1, #0 > - ittee ne > - movne r2, #0 > - movne r0, r1 > - moveq r2, #32 > - cmpeq r0, #0 > -#endif > - @ Perform the ffs on r0. > - rbit r0, r0 > - ittt ne > - clzne r0, r0 > - addne r2, r2, #1 > - addne r0, r0, r2 > - bx lr > -END (ffsll) > diff --git a/sysdeps/arm/math-use-builtins-ffs.h b/sysdeps/arm/math-use-builtins-ffs.h > new file mode 100644 > index 0000000000..c0f108c264 > --- /dev/null > +++ b/sysdeps/arm/math-use-builtins-ffs.h > @@ -0,0 +1,2 @@ > +#define USE_FFS_BUILTIN 1 > +#define USE_FFSLL_BUILTIN 0 Here. Also, this file is misplaced wrt the armv6t2 files you're removing. This will work, I suppose, but you'll get the libgcc implementation. If you're willing to settle for that, you might as well drop all of this extra use-builtins stuff and unconditionally use __builtin_ffs*. r~