Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp732705imb; Fri, 1 Mar 2019 12:29:12 -0800 (PST) X-Google-Smtp-Source: APXvYqxvXaMUZoV0F8VEJsXPKLcfXWpd3XCB41sihhxTlDtuGYL0AVEEKOsFdme+cYrbU1bJdyF3 X-Received: by 2002:a63:144:: with SMTP id 65mr6746661pgb.38.1551472152493; Fri, 01 Mar 2019 12:29:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551472152; cv=none; d=google.com; s=arc-20160816; b=N1NBUO1vDgNf7DhGWDjuMRnoPcLh4Bne3DACojg3Pw2W5VFPobzsL/YC5H0M2t7IIn WdAZ8jMG+1LIAn/AqeW3l9QGlAWwJ3NiqFc8SSdCd+ZkXTnu8GuU/ikMWfJ3O4RwPgn9 5tSPlWJaTJRDBoDqpuvQaLjjF6kHWL0alUgL4O1JtPH3pVQjDX63sXGCYYdxEZNJXdks 49BmtG2vF+rPXP9mswqE/yCtuCUhpLmYjrR5ShmAiyuho31e8WArPUGcSX9TCzDSttpQ ucXILR6CAcpB5JYukYxBoRAWBXpJN3STczy1AQ/KDD1o0qEMmzl4RqFEvm/MBKKzYT+8 6pSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=d0dY2pZIiSxUVJTmkev3F4oI4OLYS5EYwcPnU1X/34o=; b=bp4elj/9MhPdojZMwNgjtdRkcYWT3/sVXpk09+kUPH09KB9pJW57w9MJnaUheeResS LCvRMLUhn5uEmGMpeJM5EkAId7BdOcOoRXaJBECfGK6fSQJeU1xsyVr+k1iK271RQG57 q6clYbhMkZnSLGajlmP8zvxtDNPliMQKRMpXgBpH5KFRnX5NckDJJyDeSGDOuRfLKTEM 7WVYR7Vidr3sXRegY97np9F+SjaQBbNV/pKFxzAoTCPojroTfZ5M/kh8CAeWZ+hN25tM pI1rDM19g7gWdbo3H00Eiteq1fdioicKw7NQ2kB4W0274ZGtr6hts7Km7Glgr9ItyQk+ 7rUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t13si21338583pgh.159.2019.03.01.12.28.56; Fri, 01 Mar 2019 12:29:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726226AbfCAU1B (ORCPT + 99 others); Fri, 1 Mar 2019 15:27:01 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:53344 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbfCAU1B (ORCPT ); Fri, 1 Mar 2019 15:27:01 -0500 Received: from akpm3.svl.corp.google.com (unknown [104.133.8.65]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 629DCB4BA; Fri, 1 Mar 2019 20:27:00 +0000 (UTC) Date: Fri, 1 Mar 2019 12:26:59 -0800 From: Andrew Morton To: Jani Nikula Cc: linux-kernel@vger.kernel.org, Chris Wilson Subject: Re: [PATCH] log2: make is_power_of_2() integer constant expression when possible Message-Id: <20190301122659.1776b678fadcc16c1fb2ab61@linux-foundation.org> In-Reply-To: <20190301125207.30973-1-jani.nikula@intel.com> References: <20190301125207.30973-1-jani.nikula@intel.com> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 Mar 2019 14:52:07 +0200 Jani Nikula wrote: > While is_power_of_2() is an inline function and likely gets optimized > for compile time constant arguments, it still doesn't produce an integer > constant expression that could be used in, say, static data > initialization or case labels. hm, what code wants to do these things? > Make is_power_of_2() an integer constant expression when possible, > otherwise using the inline function to avoid multiple evaluation of the > parameter. Spose so. But I fear that some gcc versions will get it right and others will mess it up. While this patch is under test I think it would be best to also have at least one or two callsites which actually use the compile-time evaluation feature. Possible?