Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3893240rwa; Tue, 23 Aug 2022 12:02:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR78oAHnvFtcWnflGt+gqLfGzRobBvJk8Ul74I4JekRIgTsB7lnl/jHA/SD7wPSda3pn3yxZ X-Received: by 2002:a17:90b:154:b0:1fa:f007:b72e with SMTP id em20-20020a17090b015400b001faf007b72emr4578132pjb.135.1661281342076; Tue, 23 Aug 2022 12:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661281342; cv=none; d=google.com; s=arc-20160816; b=SBRdowcz25R8OBsNsd2bwSQAZj5UzaJmUK12rir+gtcfKqkjPWpq7Nc3jWI17/HFqa vB1+TXnAsPNZ88N2WYkhqsaq/cnytmD6pvQ6lZ9QKYWm54IyuKKp0AmfJ/wEQG/sONf6 unxEsdAV3Azq3CR1jfxCXQbAi/g5JZTOjOuNM8dP5ijpVR09mjATYwTfVn0n9CYf+TIA 5GwFmy6XlqcMuVRcn4TPgX433FmxXzVLqH5OtZaSwDC2EbzWAr7gEs7Wrf8IbHdUJ1+6 uGN5oZP+sdfr08LMKXgY1I24JGrz7MfD7tCJrsb+4rTRLWL5hDamd5Ov//lNX7EaWANq 057w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2YdN7I7EJkAjB7pRvLwBmHF9rFEsbFHXYh/pr0t1L0M=; b=jjSLmV4r2wCNH5n7xBsbEzShSV4aD+VvAkj4Au3oZvd3/4YT0HCWITO0Cb0eMzYkXa BqaxnSwJHj5ttiXlFB4sAgSObEO4ct4HYgBLfJr+NZnZLCKYBVAgkfpg2uwFnSAchFUW dYXBvVAq3vnx9SRUtn+BNOJ5+W6A6YITr7Lay383qeljBfppe8YmhUncD0O2176kM4M3 p9mr1LPxUlgTYW3/LXGuWEGBEPQWwndnDvb+9WC1kmMqiGoXdzLLhS93aE1iE3SZ4gFA nt1g/dIb63w6ZbtqW7gu4nweGjiV0kjyuu0Q3LDy8nuFk3EBYORLgFBucsi1A65DSt26 Y5Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=kKohZL3G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d17-20020a170903231100b001729bbf257fsi1895111plh.112.2022.08.23.12.02.09; Tue, 23 Aug 2022 12:02:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=kKohZL3G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231502AbiHWSLt (ORCPT + 99 others); Tue, 23 Aug 2022 14:11:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231338AbiHWSLZ (ORCPT ); Tue, 23 Aug 2022 14:11:25 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70FCA90815 for ; Tue, 23 Aug 2022 09:23:09 -0700 (PDT) Received: from zn.tnic (p200300ea971b9893329c23fffea6a903.dip0.t-ipconnect.de [IPv6:2003:ea:971b:9893:329c:23ff:fea6:a903]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 7586E1EC068B; Tue, 23 Aug 2022 18:23:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1661271784; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=2YdN7I7EJkAjB7pRvLwBmHF9rFEsbFHXYh/pr0t1L0M=; b=kKohZL3GTd4xwIo/TOImx2hDG3yPJrGf2P3IhJjAslpJz1hrhr8629stu026rh9U17pmvH LfsMlcMORzLuwANlJ4qt5A2fs51SzvyT+mRkb3g42O35OpY9xlwAo/pgXZaueeD5wWPT+w 2i/yadC/ub1nzjT80dmwNTMF0MZfdkU= Date: Tue, 23 Aug 2022 18:23:00 +0200 From: Borislav Petkov To: Vincent Mailhol Cc: Nick Desaulniers , Thomas Gleixner , Ingo Molnar , x86@kernel.org, Peter Zijlstra , Dave Hansen , "H . Peter Anvin" , Nathan Chancellor , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, David Howells , Jan Beulich , Christophe Jaillet , Joe Perches , Josh Poimboeuf Subject: Re: [PATCH v5 2/2] x86/asm/bitops: __ffs,ffz: use __builtin_ctzl to evaluate constant expressions Message-ID: References: <20220511160319.1045812-1-mailhol.vincent@wanadoo.fr> <20220812114438.1574-1-mailhol.vincent@wanadoo.fr> <20220812114438.1574-3-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220812114438.1574-3-mailhol.vincent@wanadoo.fr> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 12, 2022 at 08:44:38PM +0900, Vincent Mailhol wrote: > __ffs(x) is equivalent to (unsigned long)__builtin_ctzl(x) Are you sure about this? My gcc documentation says: "Built-in Function: int __builtin_ctz (unsigned int x) Returns the number of trailing 0-bits in x, starting at the least significant bit position. If x is 0, the result is undefined." Note the undefined part. Also, __builtin_ctzl(0): 0x40 ffs(0): 0x0 I'm using the kernel ffs() version in a small program which is basically a wrapper around BSF. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette