Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2204263pxb; Sat, 21 Nov 2020 12:53:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJztUnWS+RaJi/rpLErYOsp494Diz/BGATkBjrsHxe1o1p5a2x2CTixLDE0FeP4bA2tlFFTK X-Received: by 2002:a17:906:3a4e:: with SMTP id a14mr37521726ejf.140.1605991991350; Sat, 21 Nov 2020 12:53:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605991991; cv=none; d=google.com; s=arc-20160816; b=GfjOyXMW5XeB0So187CSO3IOKcYFaa0K1+3wNHTcDWIV5zB1mZebauSTmImj8mdCty aUXFqqyiLuGtElvms/YzwkuDDf3YakBwsh3Grd9ph7DR81XM7tQJ7Jwg/ppSxyaGnnJi nGe/7EdbeGUO8mk36eABnEDCFc9xpylHFFarH00xea4EGgem8ImXvvIwEATM+9hLg982 XdqsX9bYRb0T2M2kZNSg+14oGqcoruA39Y33hOnUQPfsIgH0w86WaQVn3I2p58iNUVc4 CY01cowxdvwEbLIViX0CWXgFoeHWpkD9scoRmJx8/87iXOqKzR+ZVM2i8BFeCkWXhnBg IEHg== 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=7wS3kdSR65IlFtOolDLVBXI5oumbFV3Gfqst8d2FUck=; b=TzhEnavNm5lfQ9GxsW2O7Psd16loYE+iynXMZZl2AZBnY2s9KFGJUE8KUI7CLOUzJk AiNXFPY/8Z538njHYanItnvfGb2CYLGo0gd/rw9AB9TPZE2X9vPxwk4VZGbZxiwWcPQn VICsiT7w1Lh3uXv05vO1cH4amQ5lMr8d5cV2xgGk294JBYXWcDSIAb6ZY4LFDqxrAlmK 47Xg2/l7cqUR4xtlVCJ0D3dWzEhEyjnZY5vpDuaIr3LGypbdjIU4IZyj2ggEpAk9cOnR ufcBtp/idBSU7UvrZ+iDNokpVKJ38/rodyUqrhajp+PddTCT7wPINWAYGIVBqGLi9mzi hwSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FFQgnNmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si3700896ejc.524.2020.11.21.12.52.47; Sat, 21 Nov 2020 12:53:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FFQgnNmM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728522AbgKUUqc (ORCPT + 99 others); Sat, 21 Nov 2020 15:46:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728402AbgKUUqc (ORCPT ); Sat, 21 Nov 2020 15:46:32 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E681C0613CF for ; Sat, 21 Nov 2020 12:46:32 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id 10so14244490wml.2 for ; Sat, 21 Nov 2020 12:46:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=7wS3kdSR65IlFtOolDLVBXI5oumbFV3Gfqst8d2FUck=; b=FFQgnNmMGY+sIs7hjUrr+VOpxcPKGZKuOBcUY7VdxlKcY9vGTdZhaEYPuuCbE9AzXn lW6BPQfOTbX5NioUgyZDwvvm5HJSOGYig5GXshWJNG+dROLbC7T7AqMEOoCkKau+BR9a gbRfizr6Rz3VIShg9KJI3LSww9ZLE0XLwUtv5tqh7h3S9wH1vkcsXWD3OqNTfk834e+D e9i6NuBClCBb5NKSK4MZy+1HnOP9OnDgchHymoljOr2mNTRsfIsyyVod9kXmcguBJCRR j4ZBMxZq89BQCbiuhJnQPAItcD685c5ko9H/AY0B2+H4gJz5a/LcvWPr7HokyVwtobEQ dXKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7wS3kdSR65IlFtOolDLVBXI5oumbFV3Gfqst8d2FUck=; b=thmLtvYEaUzKUp9BgZojwBX5K+eT0Y89tZR0dZpFmC2q3TNyve8tUCcDWAwupg/nrF o9PtpiftZ4DAMrhkqqokASHGeKzFPHCKLKo7FJiIbKmT94xx53kXGlmF1lzsPkuDvN99 r2NqwGE6xcsU8bI1o34O694I+1xJlg2AYP+6OrwmJw8sx3jbDRgGF3myemZOtE+xQ8g9 ZSKgdpu26g23u4XaIYXN9wWgBl9TLyBnT/crWpvNYlw4uem5yYEvnjJDAMEybjFhTrl3 rm+nySnB9Y+34D2HT41PXK6dymvqM3dtVA0CruaHtZ4/W2ykv34VdiTdWv5zyzGwfJi1 Ok1Q== X-Gm-Message-State: AOAM530s2hjc7Soxl0+YxNQS2WWo4ICAEpEifER9tNGkVvbpRwJcLQMT 62JjPXyk3e83qOSqX99IxjM3PPCfz/M= X-Received: by 2002:a1c:e442:: with SMTP id b63mr16883437wmh.10.1605991590882; Sat, 21 Nov 2020 12:46:30 -0800 (PST) Received: from ltop.local ([2a02:a03f:b7fe:f700:dcb6:7e9c:ccbf:c450]) by smtp.gmail.com with ESMTPSA id h17sm12762072wrp.54.2020.11.21.12.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 12:46:30 -0800 (PST) Date: Sat, 21 Nov 2020 21:46:26 +0100 From: Luc Van Oostenryck To: Jakub Jelinek Cc: Peter Zijlstra , Andrew Morton , Linus Torvalds , linux-kernel@vger.kernel.org, christophe.leroy@csgroup.eu, rdunlap@infradead.org Subject: Re: [PATCH] ilog2: Improve ilog2 for constant arguments Message-ID: <20201121204626.tw3jribsz326e3ag@ltop.local> References: <20201120125154.GB3040@hirez.programming.kicks-ass.net> <20201121202310.lx2iqqebal3fmmmo@ltop.local> <20201121202954.GW3788@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201121202954.GW3788@tucnak> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Nov 21, 2020 at 09:29:54PM +0100, Jakub Jelinek wrote: > On Sat, Nov 21, 2020 at 09:23:10PM +0100, Luc Van Oostenryck wrote: > > On Fri, Nov 20, 2020 at 01:51:54PM +0100, Peter Zijlstra wrote: > > > > > > Other option would be to change the const_ilog2 macro, though as the > > > description says it is meant to be used also in C constant expressions, > > > and while GCC will fold it to constant with constant argument even in > > > those, perhaps it is better to avoid using extensions in that case. > > > > Just for info, the description is outdated and Sparse is just fine with > > __builtin_clzll() and friends in constant expressions (since Feb 2017) > > Why is the description outdated? It is still an extension that not every > compiler might fold in constant expressions. And, the large expressions > aren't really a problem in constant expressions, they will be folded there > to constant or error. > The problem the patch was trying to solve is that the large expressions are > a problem at least for GCC in runtime code when guarded by > __builtin_constant_p, because __builtin_constant_p is folded quite late > (intentionally so, so that more constants can be propagated into it, e.g. > after inlining etc.), and the large expressions might confuse inliner > heuristics. I was only talking about the part "Use this where *sparse* expects a true constant expression, e.g. for array 75 indices." and wanted to say that __builtin_clzll() with a constant argument is now also expanded to a constant, like GCC does (it wasn't the case before 2017 and I think it was the main reason why const_ilog2() is written as it is). -- Luc