Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2330169imb; Mon, 4 Mar 2019 02:15:01 -0800 (PST) X-Google-Smtp-Source: AHgI3IZiyLZvB1CONga8oran7XsDhYEMIFXgQPU59b/iWrhd4KqdlbR2My+EP+HCBqI0OP9zne8g X-Received: by 2002:a62:e214:: with SMTP id a20mr18912707pfi.192.1551694500960; Mon, 04 Mar 2019 02:15:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551694500; cv=none; d=google.com; s=arc-20160816; b=I/gcwkyPIUS0LrATRQok7HnnLjLCn7+cOD4A0SErf4x/rxn6bn2smw0UtYmR3oQKtY CySAvkMElt351j09u8r3NXVWyfawobRb8aPT4/FOkIvludsXLuT82ivBY9BrEmJ6bSH0 /pkuLPEYQolb9D5wXsWPEQJK3DZXQPUioFZVnTJOtjSK8IB/ZyWZOn2pZtvTyVli/4yK +2mI1XeO/HigFJhyIaD6xglU5L/hNPsv55meOVOGhzmIVadNFSTdL9UVz8GMSRGYhpXM /yp65a1sdLjS+HDTmEQTXvSOxRnIpYEcO8O+r9hAlomgfGwKv0WjU7G3y0avhLC5UgzU hAiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=kmafwQPQaKs7EddszvgGLM1rt8oDPg34jDIQ80aTDH4=; b=oG78BjCW38UDaG7AP5HHot92qZRTykFT2zD62kR3jClpF5ss2ZDtT/N6uUG6sxziGT ftqZ4Ck1mZAGoeawJYclq+Y5V0Xwr4jriMJAjDOtEagaV0RNW+2FYB9UpIglfluCMkd9 25J4C1hdpIYG82QvEgN0aI0lvpz4lDuRdDdXK5CBmJqLjpx27OeFPizS/9AvqeqsGslb 2q1vrva6xaVUBft/No1VX/PZbGrLY6boVXicxrLIYoadNnP6o5Wp/Dc6WLrDZAgU53XH Q8bXGjSldIlgJMMru4iLVjjm/aVg72YTM8MwHnvTMnH11SHl3kjj4bo6+TBg5Sw5W/6V 6/gg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay10si5101549plb.372.2019.03.04.02.14.45; Mon, 04 Mar 2019 02:15:00 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726091AbfCDKOG (ORCPT + 99 others); Mon, 4 Mar 2019 05:14:06 -0500 Received: from mga01.intel.com ([192.55.52.88]:15413 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726032AbfCDKOG (ORCPT ); Mon, 4 Mar 2019 05:14:06 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 02:14:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,439,1544515200"; d="scan'208";a="151834657" Received: from jnikula-mobl3.fi.intel.com (HELO localhost) ([10.237.66.172]) by fmsmga001.fm.intel.com with ESMTP; 04 Mar 2019 02:14:04 -0800 From: Jani Nikula To: Andrew Morton Cc: linux-kernel@vger.kernel.org, Chris Wilson Subject: Re: [PATCH] log2: make is_power_of_2() integer constant expression when possible In-Reply-To: <20190301122659.1776b678fadcc16c1fb2ab61@linux-foundation.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20190301125207.30973-1-jani.nikula@intel.com> <20190301122659.1776b678fadcc16c1fb2ab61@linux-foundation.org> Date: Mon, 04 Mar 2019 12:16:02 +0200 Message-ID: <875zszndwd.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 01 Mar 2019, Andrew Morton wrote: > 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? I have some drm/i915 patches that have a local compile-time version of IS_POWER_OF_2(). It'll take a while before they hit Linus' master. This can wait. BR, Jani. -- Jani Nikula, Intel Open Source Graphics Center