From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6D8B543270; Thu, 2 Nov 2023 16:27:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D55C40262; Thu, 2 Nov 2023 16:27:40 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 0B28B40144 for ; Thu, 2 Nov 2023 16:27:38 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 2EE4820B74C0; Thu, 2 Nov 2023 08:27:37 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2EE4820B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1698938857; bh=MZKErOG6Ygh3VCG6Xo9DFFTKpu6ku4S+SijIbm+TetI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=D4jWzkV94eLyMr5xgCLzaWoadkH00lUvatainhEg9U31nqSoFSmVS6enLBxm7s8lS 39ev9PqvaFwr6Php+IBELzVkknoTAv5OEcmEXo6ydIS4032nQ6Eo8dtcnm/vl0xjXj ux1NdCDOPGtKY472uR4m3Rpc0S67lkono2+bCnZs= Date: Thu, 2 Nov 2023 08:27:37 -0700 From: Tyler Retzlaff To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: dev@dpdk.org, Bruce Richardson , Cristian Dumitrescu , David Hunt , Honnappa Nagarahalli , Ruifeng Wang , Sameh Gobriel , Vladimir Medvedkin , Yipeng Wang Subject: Re: [PATCH 0/5] use abstracted bit count functions Message-ID: <20231102152737.GA27149@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1698887132-5347-1-git-send-email-roretzla@linux.microsoft.com> <98CBD80474FA8B44BF855DF32C47DC35E9EFC6@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9EFC6@smartserver.smartshare.dk> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Thu, Nov 02, 2023 at 08:39:04AM +0100, Morten Brørup wrote: > > From: Tyler Retzlaff [mailto:roretzla@linux.microsoft.com] > > Sent: Thursday, 2 November 2023 02.05 > > > > The first set of conversions missed the long 'l' versions of the > > builtins that were being used. This series completes the conversion > > of remaining libraries from __builtin_ctzl and __builtin_clzl. > > NAK to blind search/replace of __builtin_clzl()/clzl(). > > Although the size of long is 64 bit on 64 bit architectures, it only 32 bit on 32 bit architectures. > > You need to look at the types these builtins operate on: > - E.g. in the hash library (patch 3/5) prim_hitmask[i]/sec_hitmask[i] are uint32_t, so rte_ctz32() would be the correct replacement. (I am now asking myself why they were using __builtin_ctzl() instead of __builtin_ctz() here... Probably by mistake.) > - And if the type is "long", you need conditional compiling (or a wrapper macro) to choose between the 32 bit or 64 bit variants. > > NB: You can blindly replace __builtin_ctzll()/clzll(), if any, by 64 bit functions. they haven't been blindly replaced. but i would like you to validate my thinking. in the case of counting trailing 0s it seems fine if the type is promoted to 64-bits, in the case of leading i checked the type to make sure it was already operating on a 64-bit type. too naive?