Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5429018rwb; Wed, 7 Sep 2022 02:42:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR6rZO8yt4TsaY0wHmCdLh7BS7lE2wcO9P914a/2wBC6ZlE0ZoTNnEg9TTe8b3xHxNoiXipO X-Received: by 2002:a17:90b:4c08:b0:200:512e:de26 with SMTP id na8-20020a17090b4c0800b00200512ede26mr16545270pjb.227.1662543729400; Wed, 07 Sep 2022 02:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662543729; cv=none; d=google.com; s=arc-20160816; b=Wow4wSDtGi4NqVzolaPimCV4AEvHMi174Ut82iaFpiBwvQqO4IK73zaq7oOU0EUQmR YzZuwQv/bPahnCMQZl9fmaoCowk5Il1g8REAaCBQJoQZZuGTeNPsKqHMjEa3aY9tf1TQ OXrk0c8gBvTp/6rUtjQnn5PCdQp/cl3aRC7dKukcLSV228XCMOaz06MVKB1mHFHbFNOd HE8Xcohf/SiIt/rWLTgRawDY4vra1e2oOfYl2ao4CywhpWX6hbziytLLm22hSflyyxnr qsKvIHzgnEIz2JKsGvBCkz3ZFbpaEm9wZE8/J5TbksabJ/b7XIG7c8FLuuGrXkMuaIKW iO5w== 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=Xp7hEi4p44/YaMgw6I5ghs8SKRBZzu64Qfp4lEGDVUE=; b=OYf8quDGoD/L87LEt2dByzrnoVckJrnA0DEEoZpBzb0nqkW28JIHfKyV2sHsGgWCAr geIreOqp2fyHdIO2ADXOvpcoKLtMpAr3XVRH0mwmoR95RFv0dMoVofstzKAENL4zB1tF 23lx0nxYEPsJyo3Wrng3eqsRk4x/cZBsDWovg9310RZNWIudx8OzhIq3WNTtVEcb3BBo tOY4j+mFnSnkyYOEBJhpgAOKEZziSug1nyinmWVMi9a3jq55bj8T8SI2LE2+YaI06fHU PF0/Wwpqx6usDpjHXCL9RTekhHogsU3sgwG7v/i5TN+u6HYR7Bad253AxE8j5lso/AXQ di4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=rdnbgqVq; 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 t19-20020a63d253000000b0042b4a196e65si15931869pgi.470.2022.09.07.02.41.58; Wed, 07 Sep 2022 02:42:09 -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=rdnbgqVq; 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 S229853AbiIGIuv (ORCPT + 99 others); Wed, 7 Sep 2022 04:50:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229818AbiIGIup (ORCPT ); Wed, 7 Sep 2022 04:50:45 -0400 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB99D40561 for ; Wed, 7 Sep 2022 01:50:43 -0700 (PDT) Received: from nazgul.tnic (unknown [84.201.196.28]) (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 163A41EC04F0; Wed, 7 Sep 2022 10:50:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1662540638; 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=Xp7hEi4p44/YaMgw6I5ghs8SKRBZzu64Qfp4lEGDVUE=; b=rdnbgqVqTpHwwG1pYwF2zHuScR2Z1tHcze6vuIuRCEbTr5UMuW4JmyssZgyMjlWc/uT4lw rBKsLyw3Xhj3Y5hKJqKhjqyj7eRxbGSH3pmSaHEDNGosWXgdYG5zf8cYf1EO45r5pNTO7T ylGrelCoW526O3cMffELufeIKytaqIs= Date: Wed, 7 Sep 2022 10:50:47 +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 , Yury Norov Subject: Re: [PATCH v5 2/2] x86/asm/bitops: __ffs,ffz: use __builtin_ctzl to evaluate constant expressions Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 Wed, Sep 07, 2022 at 02:35:41PM +0900, Vincent MAILHOL wrote: > I rephrased the beginning of the commit message as below: > > > If x is not 0, __ffs(x) is equivalent to: > (unsigned long)__builtin_ctzl(x) > And if x is not ~0UL, ffz(x) is equivalent to: > (unsigned long)__builtin_ctzl(~x) > Because __builting_ctzl() returns an int, a cast to (unsigned long) is > necessary to avoid potential warnings on implicit casts. > > Concerning the edge cases, __builtin_ctzl(0) is always undefined, > whereas __ffs(0) and ffz(~0UL) may or may not be defined, depending on > the processor. Regardless, for both functions, developers are asked to > check against 0 or ~0UL so replacing __ffs() or ffz() by > __builting_ctzl() is safe. > > > > Does this solve the issue? Yes, that sounds better. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette