All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: [PATCH] log2: make is_power_of_2() integer constant expression when possible
Date: Mon, 04 Mar 2019 12:16:02 +0200	[thread overview]
Message-ID: <875zszndwd.fsf@intel.com> (raw)
In-Reply-To: <20190301122659.1776b678fadcc16c1fb2ab61@linux-foundation.org>

On Fri, 01 Mar 2019, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Fri,  1 Mar 2019 14:52:07 +0200 Jani Nikula <jani.nikula@intel.com> 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

  reply	other threads:[~2019-03-04 10:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-01 12:52 [PATCH] log2: make is_power_of_2() integer constant expression when possible Jani Nikula
2019-03-01 13:07 ` Chris Wilson
2019-03-01 20:26 ` Andrew Morton
2019-03-04 10:16   ` Jani Nikula [this message]
     [not found] ` <201903041956.eLAFVhUK%fengguang.wu@intel.com>
2019-03-04 11:47   ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875zszndwd.fsf@intel.com \
    --to=jani.nikula@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.